Autor Zpráva
martix
Profil *
potřeboval bych poradit s použitím last_insert_id()

tento sql dotaz mi funguje
$sql = "select cas, id from tabulka1 where id = 3";

ale tento už ne
$sql = "select cas, id from tabulka1 where id = last_insert_id()";

potřebuju vypsat čas a id pro poslední záznam (last_insert_id)
Oswald
Profil
(update) Ono to funguje pouze tehdy, pokud je předtím něco vloženo. Viz:
http://dev.mysql.com/doc/refman/5.0/en/information-functions.html#fun c tion_last-insert-id

Můžeš taky použít PHP funkci mysql_insert_id.
roberta
Profil
$sql = "select cas, id from tabulka1 where id = " . mysql_insert_id();
notr
Profil *
tak na toto mi apache vypíše
Fatal error: Call to undefined function: last_insert_id()
notr
Profil *
tak předtím vloženo nic nemám, nejde nějak jinak zjistit jednoduše nejvyšší id?
roberta
Profil
$sql = "select cas, id from tabulka1 where id = max(id)";
notr
Profil *
roberta
díky moc

už mě napadlo nějakou funkci max hledat v helpu
nightfish
Profil
tak na toto mi apache vypíše
Fatal error: Call to undefined function: last_insert_id()

protože last_insert_id() je funkce mySQL, ne PHP
PHP varianta je mysql_insert_id()
Toto téma je uzamčeno. Odpověď nelze zaslat.

0