开发者

Kohana 2 database insert - insert id is returned but it is protected?

So this code:

 $db = Database::instance();
 $result = $db->query("insert into parser_log (sent)
                       values (".sizeof($jobs).")");

returns an object with the insert id, but when I try to access it:

 Fatal error: Cannot access protected 开发者_运维百科property Mysql_Result::$insert_id

What is up with that? Must I run a separate query to get the id? seems like a waste since the id is right there.


  1. your code is invalid, you have to pass at least 2 arguments to the query method:

    $db->query(Database::INSERT, 'insert into ...');

  2. query method returns an array with last insert id and count of affected rows

  3. You have not specified the line that throws such error

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜