Bin will be removed on June 1, 2014 in favor of http://gist.github.com. Please save all your pastes before then. So long, and thanks for all the fish!×
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
cakephp 1.17 & 1.18
 
<?php
$query = 'INSERT INTO experiment_tools SET '.$fields;
$this->Experiment->execute($query);
echo $query;
$db =& ConnectionManager::getDataSource('cnm_experiments');
$tool_id = $db->lastInsertId();
var_dump($tool_id);
$tool_id = $this->Experiment->query('SELECT LAST_INSERT_ID() AS insertID');
pr($tool_id[0][0]);
?>
 
outputs:
 
INSERT INTO experiment_tools SET experiment_id=1, tool_name="Lightsaber", manufacturer="Jedi Alliance", safeguards="test", inactive_flag="N"
 
string(1) "0"
 
Array
(
    [insertID] => 8
)