Home  >  Article  >  Backend Development  >  zend 获取插入数据的ID解决办法

zend 获取插入数据的ID解决办法

WBOY
WBOYOriginal
2016-06-13 10:11:04846browse

zend 获取插入数据的ID
怎么获得刚刚插入一条数据的主键id值?

------解决方案--------------------
$lastid=$db->lastInsertId();

这样就可以获得最近的id值了
------解决方案--------------------

探讨
怎么获得刚刚插入一条数据的主键id值?

------解决方案--------------------
PHP code
//// INSERT INTO round_table//     (noble_title, first_name, favorite_color)//     VALUES ("King", "Arthur", "blue");//// 创建一个 $db对象, 然后...// 以"列名"=>"数据"的格式格式构造插入数组,插入数据行$row = array (    'noble_title'    => 'King',    'first_name'     => 'Arthur',    'favorite_color' => 'blue',);// 插入数据的数据表$table = 'round_table';// i插入数据行并返回行数$rows_affected = $db->insert($table, $row);$last_insert_id = $db->lastInsertId();<div class="clear">
                 
              
              
        
            </div>
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn