Kevin
|
Posted: 05/12/2005, 2:10 PM |
|
I have been looking for a means to find the last ID inserted for a table and posted a support request informing support that I had found a simple way to run mysql_insert_id() - Support posted this back:
"We are using the Max(pk) as a SELECT statement to obtain the last inserted record. Please use this method as well.
CCDLookUp("MAX(ID)","table_name","where_condition",$DBConnection_name);"
---------------- I replied with ----------------------------------------------------
Using the group function MAX is invalid and a VERY poor method to provide as a means to fix your missing function. The mysql_insert_id() function retrieves the last ID used for an insert call, this is the ONLY means to get the LAST ID for that session/connection reliably. The MAX method only works if you're the only one inserting records into the table, that isn't how a web site works. I have urged you to look into providing the correct means to retrieve that LAST ID, in Common.php you have DB = "MySQL" so you can tell they type of DB in use so a CASE statement after an IF that tests for an insert would provide a LAST ID for the DB object for ALL databases, please look into this method for a future release as using MAX is not valid for a site with more then one user.
|
|
|
peterr
Posts: 5971
|
Posted: 05/12/2005, 2:24 PM |
|
Kevin,
This is only a simple, universal method that works with all databases. It is not reliable and the comments in our examples are specific about it:
//Retrieve the last inserted key
//Use a method compatible with all databases (unsafe when multiple users insert records at the same time)
$GetLastInsKey = CCDLookup("max(emp_id)", "employees", "", $DBIntranetDB);
You will need to refer to your own database's documentation to find the best method that works with it.
As it is not a CCS feature, the support doesn't support it and probably provided you with the above sample code, and you may need to find a programmer to help you with this, or read your database documentation.
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com |
|
|
peterr
Posts: 5971
|
Posted: 05/12/2005, 2:42 PM |
|
BTW, you're welcome to post feature suggestions to the Wishes forum, or the support as a "Wish/Request" (as a wish, not a complaint ).
I'm not saying that this one will or can be done, but those are places where YesSoftware is gathering information about what users want.
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com |
|
|
|