I am completely new to PHP and am attempting to make moodle work with Firebird.
I'm not getting very far.
Anyway, I need to return the primary key from an insert statement.
the code goes something like this
$sql = "INSERT INTO {$this->prefix}$table ($fields) VALUES($qms)";
$this->writes++; // what does this do?
if (!$rs = $this->adodb->Execute($sql, $params))
{
$this->report_error($sql, $params);
return false;
}
this works fine, except I need to know what is the generated primary key, so I tried the this
$sql = 'SELECT max(id) from '.$this->prefix.$table;
if (!$rs1 = $this->adodb->Execute($sql))
{
$this->report_error($sql);
}
error_log('JLJ fieldcount '.$rs1->FieldCount) ;
error_log('JLJ fieldvalue '.$rs1->fields[0]) ;
My problem is FieldCount and fields[0] is showing up as blank.
I assume the query executed as rs1 is assigned.
Is my query returning nothing because the insert is not committed?
Is there another way to retrieve the generated primary key?
Am I doing this completely wrong?
Any pointers or help would be greatly appreciated.
Jon