Date: 11/24/00
- Next message: Michael Zeidler: "[phplib] the "Group by" Function Problem"
- Previous message: Richard Quinn: "[phplib] db_mysql.inc Last Insert ID?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Hi,
Im new here, so please forgive any blatant stupidities.
I use the phplib extensively, its really great, especially the DB wrappers.
But, I was getting tired of still having to call
mysql_insert_id($QueryID)
prorammatically, so I extended the DB_Sql class to automatically store this
value after every insert:
Chanes I made to db_mysql.inc:
New class variable:
/* Last Insert ID */
var $lngLastInsertID=0;
Query modified:
/* public: perform a query */
function query($Query_String) {
$this->connect();
if ($this->Query_ID) {
<email protected>($this->Query_ID);
$this->Query_ID = 0;
}
if ($this->Debug)
printf("Debug: query = %s<br>\n", $Query_String);
$this->Query_ID = <email protected>($Query_String,$this->Link_ID);
$this->Row = 0;
if (!$this->Query_ID) {
$this->halt("Invalid SQL: ".$Query_String);
}else{
$strQueryFirstWord=strtolower(substr(trim($Query_String),0,6));
if ($strQueryFirstWord=="insert")
{
$this->lngLastInsertID= <email protected>();
}
}
$this->Errno = mysql_errno();
$this->Error = mysql_error();
return $this->Query_ID;
}
Basically, if the query was successful I look to see if the first word in it
was "insert", if it was I then ask mysql to ive me the insert if, if
available.
So, do the changes merit inclusion into the libraray? Do you think the
changes are at all useful, or have I missed the point somewehere?
Cheers,
Richard Quinn
------------------------------------
Richard Quinn, Project Lead mailto://richard.quinn <email protected>
IT-Choice Software AG http://www.it-choice.de/
Kaiserstr. 160-162
D-76133 Karlsruhe, Germany (+49)
Tel.: 0721 85006-0
Fax: 0721 85006-77
0173 - 664 1468
24h: Voicebox:0180/505254647774 Fax:0180/505254647774
---------------------------------------------------------------------
To unsubscribe, e-mail: phplib-unsubscribe <email protected>
For additional commands, e-mail: phplib-help <email protected>
- Next message: Michael Zeidler: "[phplib] the "Group by" Function Problem"
- Previous message: Richard Quinn: "[phplib] db_mysql.inc Last Insert ID?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

