I agree. For a DBMS it's not necessary to return the auto increment value after an insertion. But for PHP it is. The code I pasted is part of a DB abstraction class I've written and using for a few years and which I'm currently extending to sybase. Here's the whole method:
function Write($qry, $id = "") {
if ($this->link && $this->valid) {
if (@sybase_query($qry, $this->link) == false) {
$this->set_error(1009);
} else {
@$id = mysql_insert_id($this->link); // HOW TO DO THIS IN SYBASE?
@$this->rowcount = sybase_affected_rows($this->link);
if (!$id) {
$id = $this->rowcount;
}
}
} elseif ($this->link == false) {
$this->set_error(1005);
}
return $this->valid;
}
Explanation: As the methods name suggests, it is only used for writing queries, not for queries returning a resultset. Note that $id is passed to the method as parameter by reference. In doing that the method can 'return' the inserted id through the passed parameter and still return [ true | false ] regarding of success which is done through $this->valid ($this->valid is altered in method set_error(), among other things).
Back to my problem: There are many cases where the PHP application needs to know what was the last inserted id to act according to it. As said in my earlier post I don't want to rely on the existance of a trigger.
Maybe now it's a little clearer.
TIA as always,
Dominique