Re: Last ID Problem
От | |
---|---|
Тема | Re: Last ID Problem |
Дата | |
Msg-id | 20050131233302.26671.qmail@web52407.mail.yahoo.com обсуждение исходный текст |
Ответ на | Re: Last ID Problem (Mitch Pirtle <mitch.pirtle@gmail.com>) |
Ответы |
Re: Last ID Problem
Re: Last ID Problem |
Список | pgsql-novice |
thanks mitch... i ahve the following code... $cust = $_POST['cust']; $cust = addslashes($cust); $db = &ADONewConnection('postgres'); $db -> Connect($db_string,$db_owner,$db_pw,$db_name); $sql = "INSERT INTO customer (customer_name) VALUES ('$cust')"; $result = $db->Execute($sql); $insert_id = $db->getone("select currval('cust_id')"); if ($result === false) { print $db->ErrorMsg(); exit(); } else { $dbreturn = 'Passed'; print $dbreturn; print $insert_id; exit(); } it prints $dbreturn as "Passed", but it does not print any value for insert_id. i'm trying to see this value and verify it is working correctly before trying anything more complex. --- Mitch Pirtle <mitch.pirtle@gmail.com> wrote: > This is the easiest way to do it: > > > http://ask.slashdot.org/article.pl?sid=05/01/31/1441200&from=rss > > This is using plain old SQL the PostgreSQL way ;-) > > Basically you: > > 1) get the next number from the sequence > 2) do the update > 3) use that number for related table insterts > > For an ADOdb example, this thread: > > > http://www.phparch.com/discuss/index.php/t/372/0/ > > Says to use this syntax: > > $insert_id = $db->getone("select > currval('sequence_name')"); > > -- Mitch > > ---------------------------(end of > broadcast)--------------------------- > TIP 9: the planner will ignore your desire to choose > an index scan if your > joining column's datatypes do not match > __________________________________ Do you Yahoo!? Yahoo! Mail - now with 250MB free storage. Learn more. http://info.mail.yahoo.com/mail_250
В списке pgsql-novice по дате отправления: