獲取數據對象原始數據:getData()
所謂數據對象原始數據,就是對象的$data=[ ]數組的值
* * * * *
think
class model
getData()方法代碼如下:
~~~
/**
* 獲取對象原始數據 如果不存在指定字段返回false
* @access public
* @param string $name 字段名 留空獲取全部
* @return mixed
* @throws InvalidArgumentException
*/
public function getData($name = null)
{
if (is_null($name)) {
return $this->data;
} elseif (array_key_exists($name, $this->data)) {
return $this->data[$name];
} else {
throw new InvalidArgumentException('property not exists:' . $this->class . '->' . $name);
}
}
~~~
源碼分析:如果該方法有參數,則把參數做為數組鍵名,返回對應的值;如果不傳入任何參數,則返回整個$data數組
更多詳細介紹參看http://www.php.cn/php/php-getData.html