本文整理匯總了PHP中PDO::fetch方法的典型用法代碼示例。如果您正苦於以下問題:PHP PDO::fetch方法的具體用法?PHP PDO::fetch怎麽用?PHP PDO::fetch使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類PDO
的用法示例。
在下文中一共展示了PDO::fetch方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: fetch
/**
* Fetches a row from the result set.
*
* @param int $style OPTIONAL Fetch mode for this fetch operation.
* @param int $cursor OPTIONAL Absolute, relative, or other.
* @param int $offset OPTIONAL Number for absolute or relative cursors.
* @return mixed Array, object, or scalar depending on fetch mode.
* @throws \Zend\DB\Statement\Exception
*/
public function fetch($style = null, $cursor = null, $offset = null)
{
$row = parent::fetch($style, $cursor, $offset);
$remove = $this->_adapter->foldCase('zend_db_rownum');
if (is_array($row) && array_key_exists($remove, $row)) {
unset($row[$remove]);
}
return $row;
}
示例2: create
public function create()
{
$sql = "SHOW COLUMNS FROM " . $this->table_name() . " WHERE EXTRA NOT LIKE '%auto_increment%'";
$this->record = $this;
$this->result = $this->db->fetch($sql);
for ($i = 0; $i < count($this->result); $i++) {
$d = (string) $this->result[$i]->Field;
$this->record->{$d} = null;
}
return $this->record;
}