0
我試圖創建其結果mysql_fetch_assoc返回查找表的ID,這是我的代碼至今:的MySQL/PHP 5 - 獲取最後讀取行
protected function dumpResultAsHash($primaryKey)
{
if (empty($primaryKey) || !isset($primaryKey))
throw new Exception("Primary key cannot be null or not defined!");
$resultset = array();
while ($result = mysql_fetch_assoc($this->m_result))
$resultset[$result[$primaryKey]] =$result;
return $resultset;
}
但是,我不喜歡我必須指定主鍵的列名並將其提供給函數的事實。有沒有一種方法可以確定每個記錄的主鍵的值,如mysql_insert_id,但對於我的情況類似於最後一次獲取的ID?