当前位置: 首页>>代码示例>>PHP>>正文


PHP resource::fetch方法代码示例

本文整理汇总了PHP中resource::fetch方法的典型用法代码示例。如果您正苦于以下问题:PHP resource::fetch方法的具体用法?PHP resource::fetch怎么用?PHP resource::fetch使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在resource的用法示例。


在下文中一共展示了resource::fetch方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getAssertionsByEmailAddress

 /**
  * Get assertions by email address
  * 
  * @param   mixed  $emailAddresses  String (for single user) or array (for multiple users) of user email addresses
  * @return  array
  */
 public function getAssertionsByEmailAddress($emailAddresses)
 {
     if (!$this->credentialsSet()) {
         throw new \Exception('You need to set the credentials first.');
     }
     if (!is_array($emailAddresses)) {
         $emailAddresses = array($emailAddresses);
     }
     $query_params = implode('%20', $emailAddresses);
     $url = self::PASSPORT_API_ENDPOINT . "assertions?emailAddresses=" . $query_params;
     if ($this->request_type == 'oauth' && is_a($this->request, 'oauth')) {
         $this->request->setAuthType(OAUTH_AUTH_TYPE_URI);
         try {
             $this->request->fetch($url, null, OAUTH_HTTP_METHOD_GET, array('Content-Type' => 'application/json'));
         } catch (Exception $e) {
             error_log($e->getCode());
         }
         $response = json_decode($this->request->getLastResponse());
     } else {
         if ($this->request_type == 'curl' && get_resource_type($this->request) == 'curl') {
             curl_setopt($this->request, CURLOPT_POST, false);
             curl_setopt($this->request, CURLOPT_URL, $url);
             curl_setopt($this->request, CURLOPT_RETURNTRANSFER, true);
             $response = curl_exec($this->request);
             $response = json_decode($response);
         } else {
             throw new Exception('Unsupported request type');
         }
     }
     return $response;
 }
开发者ID:mined-gatech,项目名称:framework,代码行数:37,代码来源:Passport.php

示例2: fetchAssoc

 /**
  * Method to fetch a row from the result set cursor as an associative array.
  *
  * @param   mixed  $cursor  The optional result set cursor from which to fetch the row.
  *
  * @return  mixed  Either the next row from the result set or false if there are no more rows.
  *
  * @since   1.0
  */
 protected function fetchAssoc($cursor = null)
 {
     if (!empty($cursor) && $cursor instanceof \PDOStatement) {
         return $cursor->fetch(\PDO::FETCH_ASSOC);
     }
     if ($this->prepared instanceof \PDOStatement) {
         return $this->prepared->fetch(\PDO::FETCH_ASSOC);
     }
 }
开发者ID:akeeba,项目名称:angie,代码行数:18,代码来源:pdo.php

示例3: db_driver_result

/**
 * Get the result from the database.
 *
 * @param resource $resource
 *
 * @return array
 */
function db_driver_result($resource)
{
    global $_db;
    $results = array();
    while ($data = $resource->fetch(PDO::FETCH_ASSOC)) {
        $results[] = $data;
    }
    return $results;
}
开发者ID:refirio,项目名称:levis,代码行数:16,代码来源:db_pdo.php

示例4: _fetchResource

 /**
  * Fetches the result from the resource.
  *
  * @return boolean Return `true` on success or `false` if it is not valid.
  */
 protected function _fetchResource()
 {
     try {
         if ($result = $this->_resource->fetch($this->_fetch)) {
             $this->_key = $this->_iterator++;
             $this->_current = $result;
             return true;
         }
     } catch (PDOException $e) {
         return false;
     }
     return false;
 }
开发者ID:crysalead,项目名称:chaos-database,代码行数:18,代码来源:Cursor.php

示例5: _parseResults

 /**
  * @method  _parseResults()
  * @access  private
  * @throws  Exception
  * @desc    Parsea los resultados obtenidos en cualquier ejecución de consultas SQL.
  * @see     self::_throwModelException()
  */
 private function _parseResults()
 {
     $this->_resultSet = array();
     $statementWords = explode(' ', $this->_sqlQuery);
     if (preg_match('/SELECT/', strtoupper($statementWords[0]))) {
         $statement = $this->_PDOmySQLConn->prepare($this->_sqlQuery);
         $statement->execute();
         $this->_numRows = $statement->rowCount();
         if ((int) $this->_numRows > 0) {
             while ($row = $this->_resource->fetch(PDO::FETCH_ASSOC)) {
                 array_push($this->_resultSet, $row);
             }
         }
     } else {
         $this->_numRows = $this->_resource->rowCount();
     }
 }
开发者ID:alfabrad,项目名称:kidzania-coupon,代码行数:24,代码来源:Model.php

示例6: fetch

 /**
  * 将数据查询的其中一行作为数组取出,其中字段名对应数组键值
  *
  * @param resource $resource 查询返回资源标识
  * @return array
  */
 public function fetch($resource)
 {
     return $resource->fetch(PDO::FETCH_ASSOC);
 }
开发者ID:menmenweiwei,项目名称:blog,代码行数:10,代码来源:Pdo.php

示例7: advanceCurrentRow

 /**
  * Gets the next row from the result and assigns it to the current row
  * 
  * @return void
  */
 private function advanceCurrentRow()
 {
     $type = $this->database->getType();
     switch ($this->extension) {
         case 'ibm_db2':
             $row = db2_fetch_assoc($this->result);
             break;
         case 'mssql':
             // For some reason the mssql extension will return an empty row even
             // when now rows were returned, so we have to explicitly check for this
             if ($this->pointer == 0 && !mssql_num_rows($this->result)) {
                 $row = FALSE;
             } else {
                 $row = mssql_fetch_assoc($this->result);
                 if (empty($row)) {
                     mssql_fetch_batch($this->result);
                     $row = mssql_fetch_assoc($this->result);
                 }
                 if (!empty($row)) {
                     $row = $this->fixDblibMSSQLDriver($row);
                 }
             }
             break;
         case 'mysql':
             $row = mysql_fetch_assoc($this->result);
             break;
         case 'mysqli':
             if (!$this->result instanceof stdClass) {
                 $row = mysqli_fetch_assoc($this->result);
             } else {
                 $meta = $this->result->statement->result_metadata();
                 $row_references = array();
                 while ($field = $meta->fetch_field()) {
                     $row_references[] =& $fetched_row[$field->name];
                 }
                 call_user_func_array(array($this->result->statement, 'bind_result'), $row_references);
                 $this->result->statement->fetch();
                 $row = array();
                 foreach ($fetched_row as $key => $val) {
                     $row[$key] = $val;
                 }
                 unset($row_references);
                 $meta->free_result();
             }
             break;
         case 'oci8':
             $row = oci_fetch_assoc($this->result);
             break;
         case 'pgsql':
             $row = pg_fetch_assoc($this->result);
             break;
         case 'sqlite':
             $row = sqlite_fetch_array($this->result, SQLITE_ASSOC);
             break;
         case 'sqlsrv':
             $resource = $this->result instanceof stdClass ? $this->result->statement : $this->result;
             $row = sqlsrv_fetch_array($resource, SQLSRV_FETCH_ASSOC);
             break;
         case 'pdo':
             $row = $this->result->fetch(PDO::FETCH_ASSOC);
             if (!empty($row) && $type == 'mssql') {
                 $row = $this->fixDblibMSSQLDriver($row);
             }
             break;
     }
     // Fix uppercase column names to lowercase
     if ($row && ($type == 'oracle' || $type == 'db2' && $this->extension != 'ibm_db2')) {
         $row = array_change_key_case($row);
     }
     // This is an unfortunate fix that required for databases that don't support limit
     // clauses with an offset. It prevents unrequested columns from being returned.
     if (isset($row['flourish__row__num'])) {
         unset($row['flourish__row__num']);
     }
     // This decodes the data coming out of MSSQL into UTF-8
     if ($row && $type == 'mssql') {
         if ($this->character_set) {
             foreach ($row as $key => $value) {
                 if (!is_string($value) || strpos($key, '__flourish_mssqln_') === 0 || isset($row['fmssqln__' . $key]) || preg_match('#[\\x0-\\x8\\xB\\xC\\xE-\\x1F]#', $value)) {
                     continue;
                 }
                 $row[$key] = self::iconv($this->character_set, 'UTF-8', $value);
             }
         }
         $row = $this->decodeMSSQLNationalColumns($row);
         // This resets the array pointer so that
         // current() will work as expected
         reset($row);
     }
     if ($this->unescape_map) {
         foreach ($this->unescape_map as $column => $type) {
             if (!isset($row[$column])) {
                 continue;
             }
             $row[$column] = $this->database->unescape($type, $row[$column]);
//.........这里部分代码省略.........
开发者ID:mrjwc,项目名称:printmaster,代码行数:101,代码来源:fUnbufferedResult.php

示例8: fetchRow

	/**
	 * Fetch row from query result
	 *
	 * @access public
	 * @param resource $resource
	 * @return array
	 */
	function fetchRow($resource) {
		return $resource->fetch(PDO::FETCH_ASSOC);
	} // fetchRow
开发者ID:Jtgadbois,项目名称:Pedadida,代码行数:10,代码来源:PdoMysqlDBAdapter.class.php

示例9: FetchRow

 /**
  * Returns the current row
  * @return array
  */
 function FetchRow()
 {
     return $this->recordset->fetch(PDO::FETCH_ASSOC);
 }
开发者ID:Arikito,项目名称:webking.xt,代码行数:8,代码来源:db_c.php

示例10: _fetch_assoc

 /**
  * Result - associative array
  *
  * Returns the result set as an array
  *
  * @return	array
  */
 protected function _fetch_assoc()
 {
     return $this->result_id->fetch(PDO::FETCH_ASSOC);
 }
开发者ID:xiehaowei,项目名称:php,代码行数:11,代码来源:MyResult.php

示例11: getArray

 /**
  * Get the next record as an associative array with fields names as keys.
  *
  * @return array(string=>mixed)
  * @access public
  */
 public function getArray($fetchMode = PDO::FETCH_BOTH)
 {
     return is_object($this->_result) ? $this->_result->fetch($fetchMode) : false;
 }
开发者ID:davidmottet,项目名称:automne,代码行数:10,代码来源:query.php

示例12: fetch_row

 /**
  * Return a single row from a query result. This method can be used
  * if a lot of rows have to be processed one by one, in which case the
  * DB_RETURN_ROWS and DB_RETURN_ASSOCS return types for the
  * {@link PhorumDBLayer::interact()} method might consume lots of memory.
  *
  * @param resource $res
  *     The result set resource handle. This is the return value of the
  *     method {@link PhorumDBLayer::interact()}, when running a query
  *     with the DB_RETURN_RES return type.
  *
  * @param integer $type
  *     A flag, which indicates what type of row has to be returned.
  *     One of {@link DB_RETURN_ASSOC} or {@link DB_RETURN_ROW}, which
  *     will let this method return respectively an associative array
  *     (field name -> value) or an array (field index -> value).
  *
  * @return mixed
  *     This method returns either an array containing a single row
  *     or NULL if there are no more rows to retrieve.
  */
 public function fetch_row($res, $type)
 {
     if ($type === DB_RETURN_ASSOC) {
         $row = $res->fetch(PDO::FETCH_ASSOC);
     } elseif ($type === DB_RETURN_ROW) {
         $row = $res->fetch(PDO::FETCH_NUM);
     } else {
         trigger_error(__METHOD__ . ': Internal error: ' . 'illegal \\$type parameter used', E_USER_ERROR);
     }
     return $row ? $row : NULL;
 }
开发者ID:samuell,项目名称:Core,代码行数:32,代码来源:PhorumSqliteDB.php

示例13: convertSqlResultKeyAndOneFieldToArray2

 /**
  * Convertie un résultat SQL en tableau PHP
  * La clef du tableau sera celle de la première colonne du résultat SQL
  * @param resource $paramResult
  * @return array Tableau PHP
  */
 public static function convertSqlResultKeyAndOneFieldToArray2($paramResult)
 {
     $return = NULL;
     if ($paramResult != NULL) {
         $paramResult->setFetchMode(PDO::FETCH_OBJ);
         while ($rows = $paramResult->fetch()) {
             $return[$rows[0]] = $rows[1];
         }
         return $return;
     }
 }
开发者ID:SalokineTerata,项目名称:intranet,代码行数:17,代码来源:DatabaseOperation.php

示例14: fetch

 /**
  * Returns next row from a query result.
  *
  * @param resource $sth
  *   PDOStatement resource.
  *
  * @return array
  */
 public function fetch($sth)
 {
     return $sth->fetch(\PDO::FETCH_ASSOC);
 }
开发者ID:xqus,项目名称:xstore,代码行数:12,代码来源:xstore.php

示例15: nextRow

 /**
  * Go to next row
  * @param mysqli_result|resource|PDOStatement $result
  * @return array
  */
 public function nextRow($result)
 {
     return $result->fetch(PDO::FETCH_ASSOC);
 }
开发者ID:manishkhanchandani,项目名称:mkgxy,代码行数:9,代码来源:LudoDBPDOOracle.php


注:本文中的resource::fetch方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。