本文整理汇总了PHP中object::fetchAll方法的典型用法代码示例。如果您正苦于以下问题:PHP object::fetchAll方法的具体用法?PHP object::fetchAll怎么用?PHP object::fetchAll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类object
的用法示例。
在下文中一共展示了object::fetchAll方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fetch
/**
* Fetch results from PDO statement object
* @param object $statement Prepared PDO statement object
* @param string $fetchStyle Style of returned row(s)
* @return mixed Returned row(s)
*/
public function fetch($statement, $fetchStyle)
{
if ($fetchStyle === PDO::FETCH_CLASS) {
return $statement->fetchAll(PDO::FETCH_CLASS, 'stdClass');
} else {
return $statement->fetchAll($fetchStyle);
}
}
示例2: fetchAll
/**
* Fetches the results of the executed statement
* @static
* @param string $sql A string of the sql query
* @param array $params An array of the parameter
* @param int $method The code for the fetch Method to be used, defaulst to FETCH_ASSOC
* @return array Returns an array of rows from the database
* @since version 2.0
*/
public static function fetchAll($sql, $params = array(), $method = PDO::FETCH_ASSOC)
{
try {
return self::execute($sql, $params) ? self::$stmt->fetchAll($method) : false;
} catch (PDOException $e) {
return self::pdoException($e);
}
}
示例3: fetchAll
public function fetchAll($mode = \PDO::FETCH_ASSOC, $argument = null)
{
if ($argument) {
return $this->statement->fetchAll($mode, $argument);
} else {
return $this->statement->fetchAll($mode);
}
}
示例4: handleRequest
/**
* Call this method from the appropriate action method
*
* @return ApiProblemResponse|JsonModel
*/
public function handleRequest()
{
$request = $this->getRequest();
if ($request->getMethod() != $request::METHOD_GET) {
return new ApiProblemResponse(new ApiProblem(405, 'Only the GET method is allowed for this URI'));
}
$model = new JsonModel([$this->property => $this->model->fetchAll()]);
$model->setTerminal(true);
return $model;
}
示例5: fetch
/**
* method for fetching rows which we created with our query
* @return array $rows assoc array of rows
*/
public static function fetch()
{
try {
self::$debug[] = self::$query;
self::init();
self::$stmt = self::$dbh->prepare(self::$query);
self::prepare();
self::$stmt->execute();
$rows = self::$stmt->fetchAll(PDO::FETCH_ASSOC);
if (self::$method == 'select_one') {
if (!empty($rows)) {
$rows = $rows[0];
}
}
self::unsetVars();
} catch (Exception $e) {
$message = $e->getTraceAsString();
log::error($message);
$last = self::getLastDebug();
log::error($last);
die;
}
if (self::$method == 'num_rows') {
return $rows[0]['num_rows'];
}
return $rows;
}
示例6: getCol
/**
* helper to retrieve sigle column from result
*
* @param string the column to be retrieved
* @return array result
*/
protected function getCol($colName = '')
{
$all = $this->statement->fetchAll();
if (empty($colName)) {
$colName = key($all[0]);
}
return array_column($all, $colName);
}
示例7: checkTID
/**
* Check for a twitter id in the database
* @access private
* @param integer $tid a twitter id(required)
* @return boolean
*/
private function checkTID($tid) {
$this->db->setFetchMode(Zend_Db::FETCH_OBJ);
$result = $this->db->fetchAll('SELECT * FROM '.$this->table_name.' WHERE tid = ?', $tid);
return $result;
}
示例8: getTagCount
/**
* Get count of all ids in the database - since they're unique this is the total tweets for that hash tag
* @access public
* @return object
*/
public function getTagCount() {
$this->db->setFetchMode(Zend_Db::FETCH_ASSOC);
$result = $this->db->fetchAll('SELECT COUNT(*) as "tweet_count" FROM '.$this->table_name);
return $result[0];
}
示例9: _isNotExist
/**
* Check existing of hash
*
* @static
* @param string $hash
* @param object $db
* @param string $table
* @return bool
*/
protected static function _isNotExist($hash, $db, $table)
{
$select = $db->select()->from($table)->where('hash=?', $hash);
$records = $db->fetchAll($select);
if (empty($records)) {
return true;
}
return false;
}
示例10: renderDefault
public function renderDefault()
{
$this->pager->itemCount = $this->gallery->getCount();
$this->pager->itemsPerPage = $this->onPage;
$this->page = $this->pager->getPage();
$this->template->list = $this->gallery->fetchAll($this->page, $this->onPage, $this->orderBy, $this->sort);
$this->template->sort = $this->sort;
$this->template->orderBy = $this->orderBy;
$this->template->title = $this->documentName;
if (isset($this->mainSession->filter)) {
$this['filterForm']->setDefaults($this->mainSession->filter);
}
$this->template->showFilter = null;
//$this->mainSession->filterName;
$this->template->showSavedFilters = $this->gallery->getSavedFilters();
$trash = $this->gallery->getTrash();
$this->template->trashCount = $trash['count'];
$this->template->trash = $trash['items'];
}
示例11: result_set
/**
This method executes the prepared query
@access public
@throws PDOException object
@return array or object
*/
public function result_set()
{
try {
self::execute();
$result = $this->Stmt->fetchAll(PDO::FETCH_OBJ);
self::close_cursor();
return $result;
} catch (PDOException $e) {
throw $e;
}
}
示例12: getLatestTweet
/**
* Get latest tweet from database and output the json
* @access public
* @return object
*/
public function getLatestTweet() {
$this->db->setFetchMode(Zend_Db::FETCH_ASSOC);
$result = $this->db->fetchAll('SELECT profile_img, name, username, text FROM '.$this->table_name.' ORDER BY id DESC LIMIT 1');
// echo '<pre>';
// print_r($result);
return $result;
}
示例13: getAll
/**
* 获得所有的查询数据
* @param string $sql 要执行的SQL指令
* @param boolean $primkey 是否以主键为下标。使用主键下标,可以返回以数据库主键的值为下标的二维数组
* @return array 查询得到的数据集,失败返回false
* @access public
*/
public function getAll($sql, $primkey = false)
{
$this->query($sql);
if ($primkey) {
$result = $this->PDOStatement->fetchAll(PDO::FETCH_GROUP | PDO::FETCH_ASSOC);
$result = array_map('reset', $result);
} else {
$result = $this->PDOStatement->fetchAll(PDO::FETCH_ASSOC);
}
$this->PDOStatement = null;
return $result;
}
示例14: determineAutoIncrement
/**
* determineAutoIncrement()
* Determines Autoincrement Field if not set
* @access private
* @return void
*/
private function determineAutoIncrement()
{
if (!$this->orderByField) {
$query = "DESCRIBE " . $this->table;
$result = $this->db->fetchAll($query);
foreach ($result as $row) {
if ($row['Extra'] == 'auto_increment') {
$this->orderByField = $row['Field'];
}
}
}
}
示例15: getFields
/**
* Return Table Fields of Requested Table
*
* @param string $sTable
* @return array Field Type and Field Name
*/
public function getFields($sTable = '')
{
$sSql = "DESC {$sTable};";
$this->_oSTH = $this->prepare($sSql);
$this->_oSTH->execute();
$aColList = $this->_oSTH->fetchAll();
foreach ($aColList as $key) {
$aField[] = $key['Field'];
$aType[] = $key['Type'];
}
return array_combine($aField, $aType);
}