Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/249.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/perl/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 如何获取symfony1.4中最后插入的记录_Php_Symfony 1.4 - Fatal编程技术网

Php 如何获取symfony1.4中最后插入的记录

Php 如何获取symfony1.4中最后插入的记录,php,symfony-1.4,Php,Symfony 1.4,如何获取symfony1.4中最后插入的记录 我对symfony不太了解。 我需要symfony1.4中最后一条插入记录的id,如果您有任何想法,请告诉我 public function executeAddquestion(sfWebRequest $request) { $q=$this->getUser()->getAttribute('quiz'); $qs=$this->getUser()->getAttribute('questions'); $t =

如何获取symfony1.4中最后插入的记录 我对symfony不太了解。 我需要symfony1.4中最后一条插入记录的id,如果您有任何想法,请告诉我

public function executeAddquestion(sfWebRequest $request)
{
$q=$this->getUser()->getAttribute('quiz');
    $qs=$this->getUser()->getAttribute('questions');
$t = new test();
$t->setTestName($q);
$t->setTestQuestions($qs);
$t->save();
$t->getId();
}
上面的代码,我可以试试。但什么都没有。
所以请帮帮我。

您正在获取id,但没有将其存储在任何地方

请尝试以下操作:

$lastId = $t->getId();
他们说:getId()只有在主键列名为“id”时才起作用。读到这里,人们面临着同样的问题: