本文整理汇总了PHP中PDOStatement::fetchAll方法的典型用法代码示例。如果您正苦于以下问题:PHP PDOStatement::fetchAll方法的具体用法?PHP PDOStatement::fetchAll怎么用?PHP PDOStatement::fetchAll使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PDOStatement
的用法示例。
在下文中一共展示了PDOStatement::fetchAll方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fetchAll
/**
* 获取所有
* @param string $fetchStyle
* @throws \HuiLib\Error\Exception
* @return array|object
*/
public function fetchAll()
{
if ($this->innerStatment == NULL) {
throw new \HuiLib\Error\Exception('fetchAll必须先调用Query::query');
}
return $this->innerStatment->fetchAll($this->fetchStyle);
}
示例2: rows
/**
* Fetches all of the rows returned by the query.
*
* @return array
*/
protected function rows()
{
if ($this->rows === null) {
$this->rows = $this->pdoStatement->fetchAll(PDO::FETCH_ASSOC);
}
return $this->rows;
}
示例3: findAll
/**
* <b>Não é passado com os Joins</b>
*
* @return array[Objetos]
*/
public function findAll()
{
$sql = "SELECT * FROM {$this->Table}";
$this->Stmt = Conn::prepare($sql);
$this->Stmt->execute();
return $this->Stmt->fetchAll();
}
示例4: fetchAll
/**
* @param string $dbObjectName
*
* @return array
*/
public function fetchAll($dbObjectName = '')
{
if ('' === $dbObjectName) {
$dbObjectName = $this->_objectName;
}
return $this->_statement->fetchAll(\PDO::FETCH_CLASS | \PDO::FETCH_PROPS_LATE, $dbObjectName);
}
示例5: fetchEntities
/**
* @param string $entity [null]
* @return array $entities
*/
public function fetchEntities($entity = null)
{
$entity = $entity ?: $this->entity;
if (is_null($entity)) {
$entity = 'stdClass';
}
return $this->statement->fetchAll(\PDO::FETCH_CLASS, $entity);
}
示例6: fetchAll
function fetchAll(PDOStatement $result, $result_type = Database::FETCH_ASSOC, $className = "stdClass", $classArgs = null)
{
if ($result_type == self::FETCH_CLASS) {
$rows = $result->fetchAll($result_type, $className, $classArgs);
} else {
$rows = $result->fetchAll($result_type);
}
return $rows;
}
示例7: __construct
/**
* @param \PDOStatement $statement
* @param MObject|null $parent
*/
public function __construct(\PDOStatement $statement, MObject $parent = null)
{
parent::__construct($parent);
$this->statement = $statement;
$this->rows = $this->statement->fetchAll(\PDO::FETCH_ASSOC);
$this->fields = empty($this->rows) ? array() : array_keys((array) $this->rows[0]);
$this->rowCount = count($this->rows);
$this->columnCount = count($this->fields);
}
示例8: all
public function all($param = null, $args = [])
{
if (is_callable($param)) {
return $this->statement->fetchAll(\PDO::FETCH_FUNC, $param);
}
if ($param !== null && is_string($param)) {
$this->bindToClass($param, $args);
}
return $this->statement->fetchAll();
}
示例9: all
/**
* Fetch all results
*
* @param boolean|string $object Fetch as object
* @return \stdClass[]
*/
public function all($object = TRUE)
{
if ($object) {
if ($object === TRUE) {
return $this->stmt->fetchAll(\PDO::FETCH_OBJ);
}
return $this->stmt->fetchAll(\PDO::FETCH_CLASS, $object);
}
return $this->stmt->fetchAll(\PDO::FETCH_ASSOC);
}
示例10: Execute
private function Execute()
{
$this->Connect();
try {
$this->getSyntax();
$this->read->execute();
$this->result = $this->read->fetchAll();
} catch (PDOException $e) {
echo "<b>Erro ao ler:</b> {$e->getMessage()}";
}
}
示例11: load
/**
* {@inheritdoc}
*/
public function load($locale)
{
$parameters = array_merge([$locale], $this->parameters);
$this->statement->execute($parameters);
$rows = $this->statement->fetchAll(\PDO::FETCH_NUM);
$result = [];
foreach ($rows as $row) {
$result[$row[0]] = $row[1];
}
return $result;
}
示例12: Execute
private function Execute()
{
$this->Connect();
try {
$this->getSyntax();
$this->Read->execute();
$this->Result = $this->Read->fetchAll();
} catch (PDOException $e) {
$this->Result = null;
WSErro("<b>Erro ao Ler:</b> {$e->getMessage()}", $e->getCode());
}
}
示例13: fetch
public function fetch()
{
$this->executeQuery();
if ($this->fetchResults === null) {
$this->fetchResults = $this->statement->fetchAll(PDO::FETCH_ASSOC);
$this->statement->closeCursor();
}
if (array_key_exists($this->currentFetchIndex, $this->fetchResults) && $this->fetchResults[$this->currentFetchIndex] !== null) {
return $this->fetchResults[$this->currentFetchIndex++];
}
return false;
}
示例14: Execute
private function Execute()
{
$this->getCon();
try {
$this->setParameters();
$this->read->execute();
$this->result = $this->read->fetchAll();
} catch (PDOException $ex) {
$this->result = false;
$erro = 'algo errado...' . $ex->getMessage();
}
}
示例15: __construct
public function __construct(PDOStatement $stm, $model = null, $fetchMode = PDO::FETCH_OBJ)
{
$this->offset = 0;
if (is_string($model)) {
$this->rows = $stm->fetchAll(PDO::FETCH_ASSOC);
$this->model = strtolower(str_ireplace('_model', '', $model));
} else {
$this->rows = $stm->fetchAll($fetchMode);
$this->model = null;
}
$this->rowCount = count($this->rows);
}