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.
your code is invalid, you have to pass at least 2 arguments to the
query
method:$db->query(Database::INSERT, 'insert into ...');
query
method returns an array with last insert id and count of affected rowsYou have not specified the line that throws such error
精彩评论