Insert_ID()
dans adodb
retours de valeur vide ou dans certains cas, il retourne 0.
Le postgresql
j'ai travaillé est en version 9.1.
$_sql = 'INSERT INTO '.$_table.' (';
$_sql .= implode(', ',$arr_fld_names);
$_sql .= ") VALUES ('";
$_sql .= implode("', '",$arr_fld_values);
$_sql .= "')";
if ($echo){
echo $_sql;
}
$_return = $this->Execute($_sql);
$this->mLastInsertedId = $this->mConn->Insert_ID(); // Keep track of the last inserted ID.
Edit: J'ai ajouté une façon sale:
$_sql = 'INSERT INTO '.$_table.' (';
$_sql .= implode(', ',$arr_fld_names);
$_sql .= ") VALUES ('";
$_sql .= implode("', '",$arr_fld_values);
$_sql .= "') RETURNING id";
if ($echo){
echo $_sql;
}
$_return = $this->Execute($_sql);
preg_match_all('/([\d]+)/', $_return, $ret_val);
$this->mLastInsertedId = $ret_val[0][0]; // Keep track of the last inserted ID.