本文整理汇总了PHP中PDOStatement::fetchObject方法的典型用法代码示例。如果您正苦于以下问题:PHP PDOStatement::fetchObject方法的具体用法?PHP PDOStatement::fetchObject怎么用?PHP PDOStatement::fetchObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PDOStatement
的用法示例。
在下文中一共展示了PDOStatement::fetchObject方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: next
/**
* Fetch next result
*
* @param boolean|string $object Fetch as object
* @return \stdClass
*/
public function next($object = TRUE)
{
if ($object) {
if ($object === TRUE) {
return $this->stmt->fetchObject();
}
return $this->stmt->fetchObject($object);
}
return $this->stmt->fetch(\PDO::FETCH_ASSOC);
}
示例2: fetch
public function fetch($class = null)
{
if (!$this->result) {
throw new Exception('Can\'t fetch result if no query!');
}
return $class === false ? $this->result->fetch(PDO::FETCH_ASSOC) : $this->result->fetchObject($class ?: self::config('fetch'));
}
示例3: fetchObject
/**
* {@inheritdoc}
*
* @throws \Orno\Db\Exception\NoResourceException
*/
public function fetchObject()
{
if (!$this->statement instanceof \PDOStatement) {
throw new Exception\NoResourceException(sprintf('%s expects a query to have been prepared and executed', __METHOD__));
}
return $this->statement->fetchObject();
}
示例4: getMinimumValue
/**
* @param \PDOStatement $statement
*
* @return \MongoId
*/
protected function getMinimumValue(\PDOStatement $statement)
{
$result = $statement->fetchObject();
if (!isset($result) || !isset($result->minimum)) {
return;
}
return new \MongoId($result->minimum);
}
示例5: fetchObject
/**
* 获得结果集中的下一行,同时根据设置的类返回如果没有设置则返回的使StdClass对象
*
* @param string $className 使用的类
* @param array $ctor_args 初始化参数
* @return object
*/
public function fetchObject($className = '', $ctor_args = array())
{
if ($className === '') {
return $this->_statement->fetchObject();
} else {
return $this->_statement->fetchObject($className, $ctor_args);
}
}
示例6: treat_success
/** @param PDOStatement $query_result */
private function treat_success($query_result)
{
$result_array = array();
while ($query_obj = $query_result->fetchObject()) {
$result_array[] = $query_obj;
}
parent::set_result('result_array', $result_array);
}
示例7: fetch
protected static function fetch(\PDOStatement $result)
{
$out = array();
while ($record = $result->fetchObject(get_called_class())) {
$out[] = $record;
}
return $out;
}
示例8: getMinimumValue
/**
* @param \PDOStatement $statement
*
* @return mixed $value
*/
protected function getMinimumValue(\PDOStatement $statement)
{
$result = $statement->fetchObject();
if (!isset($result) || !isset($result->minimum)) {
return $this->defaultValue;
}
return $result->minimum;
}
示例9: fetchObject
/**
* Return the current rowset as an object with columns set as members of the object.
*
* @param string $className OPTIONAL: The class of the object returned,
* defaults to 'stdClass'
* @param array $args OPTIONAL: Arguments to pass the the class constructor.
* @return object
*/
public function fetchObject($className = 'stdClass', $args = array())
{
try {
return $this->_stmt->fetchObject($className, $args);
} catch (PDOException $e) {
throw new DBALite_Exception("Error fetching row from result set", $e);
}
}
示例10: fetch
function fetch(PDOStatement $result, $result_type = Database::FETCH_ASSOC, $className = "stdClass", $classArgs = null)
{
if ($result_type == self::FETCH_CLASS) {
$row = $result->fetchObject($className, $classArgs);
} else {
$row = $result->fetch($result_type);
}
return $row;
}
示例11: asObject
/**
* Returns query result as an object based on the name of the called class.
*
* @param PDOStatement $q
*
* @return Model $object
*/
private static function asObject($q, $getFkAsObject)
{
while ($object = $q->fetchObject(get_called_class())) {
if ($getFkAsObject) {
self::getFkAsObject($object);
}
return $object;
}
}
示例12: fetchObject
/**
* Fetches the next row and returns it as an object.
*
* @param string $class OPTIONAL Name of the class to create.
* @param array $config OPTIONAL Constructor arguments for the class.
* @return mixed One object instance of the specified class.
* @throws Zend_Db_Statement_Exception
*/
public function fetchObject($class = 'stdClass', array $config = array())
{
try {
return $this->_stmt->fetchObject($class, $config);
} catch (PDOException $e) {
require_once 'Zend/Db/Statement/Exception.php';
throw new Zend_Db_Statement_Exception($e->getMessage());
}
}
示例13: single
/**
* Executes statement and returns result as DataObject
*
* @return DataObject
*/
public function single()
{
$this->execute();
$data = $this->stmt->fetchObject('\\Core\\Data\\DataObject');
if (!empty($data)) {
$data = $this->executeCallbackAndSchemeHandler($data);
}
return $data;
}
示例14: onCommandLartinfo
/**
* Returns information about a definition.
*
* @param string $term Term about which to return information
*
* @return void
*/
public function onCommandLartinfo($term)
{
$this->select->execute(array(':name' => $term));
$row = $this->select->fetchObject();
$msg = $this->getEvent()->getNick() . ': ';
if (!$row) {
$msg .= 'Lart not found';
} else {
$msg .= 'Term: ' . $row->name . ', Definition: ' . $row->definition . ', User: ' . $row->hostmask . ', Added: ' . date('n/j/y g:i A', $row->tstamp);
}
$this->doNotice($this->getEvent()->getSource(), $msg);
}
示例15: getMinimumValue
/**
* @param \PDOStatement $statement
*
* @return \MongoDate
*/
protected function getMinimumValue(\PDOStatement $statement)
{
$result = $statement->fetchObject();
if (!isset($result) || !isset($result->minimum)) {
return new \MongoDate(strtotime($this->defaultValue));
}
if ($this->timezone) {
$date = $result->minimum . ' ' . $this->timezone;
} else {
$date = $result->minimum;
}
return new \MongoDate(strtotime($date));
}