$insertId = self::$conn->insert($this->table)->cols($data)->query();
echo $insertId;
數(shù)據(jù)庫(kù)里面已經(jīng)有數(shù)據(jù)了,但是這個(gè)始終是返回0
解決了。是因?yàn)槲冶淼闹麈I是創(chuàng)建的全球ID,不是自增ID。
建議如下解決:
在官方的文件\workerman\mysql\src\Connection.php第1838行,源代碼如下。
if ($this->sQuery->rowCount() > 0) {
return $this->lastInsertId();
}
修改為:
if ($this->sQuery->rowCount() > 0) {
if( $this->lastInsertId() == 0 )
{
return true;
}
return $this->lastInsertId();
}