about getInsertId() instead lastInsertId()

Notice: This thread is very old.
alnux
Member | 139
+
0
-

hi there, i was trying to use lastInsertId() but nette say me that it is deprecated that missing 1 argument

/**
376:         * @deprecated
377:         */
378:        public function lastInsertId($name) {
379:            return $this->getInsertId($name);
380:        }

instead of this i have to use getInsertId(), but with this i have the problem that its returns me always 0
but on the database it is a different number. Could you help me with this method why its return me 0 (zero)???

here the method that im using

public function getInsertId()
{
	return $this->context->getInsertId();
}

Last edited by alnux (2014-07-31 00:06)

Šaman
Member | 2634
+
0
-
<?php
$row = $database->table('table')->insert([…]);
$id = $row->id;
?>
alnux
Member | 139
+
0
-

Thanks Saman your comment help me. but do you know why happing this with getInsertId() ??

Šaman
Member | 2634
+
0
-

Dont know, sorry. I'm using Dibi database layer.