コード例 #1
8
ファイル: Result.php プロジェクト: ian-Tr/le-huard
 /**
  * Internal method to fetch the next row from the result set
  *
  * @return array|null
  */
 protected function getNextRow()
 {
     # If the result resource is invalid then don't bother trying to fetch
     if (!$this->result) {
         return;
     }
     switch ($this->mode) {
         case "mysql":
             $row = $this->result->fetch_assoc();
             break;
         case "postgres":
         case "redshift":
             $row = pg_fetch_assoc($this->result);
             break;
         case "odbc":
             $row = odbc_fetch_array($this->result, $this->position + 1);
             break;
         case "sqlite":
             $row = $this->result->fetchArray(SQLITE3_ASSOC);
             break;
         case "mssql":
             $row = mssql_fetch_assoc($this->result);
             break;
     }
     # If the fetch fails then there are no rows left to retrieve
     if (!$row) {
         return;
     }
     $this->position++;
     return $row;
 }
コード例 #2
0
 /**
  * {@inheritdoc}
  */
 public function nextRecord()
 {
     if (is_object($this->handle) && ($data = $this->handle->fetch_assoc())) {
         return $data;
     } else {
         return false;
     }
 }
コード例 #3
0
ファイル: DB.php プロジェクト: thefkboss/openTracker
 /**
  * Get the nextRecord from the query.
  * @param string $result_type
  * @return resource 
  */
 public function nextRecord($result_type = "both")
 {
     if (!$this->query_id) {
         $this->halt("next_record() called with no pending query.");
         return false;
     }
     if ($this->db_type == "mysqli") {
         switch ($result_type) {
             case "assoc":
                 $this->record = $this->query_id->fetch_assoc();
                 break;
             case "num":
                 $this->record = $this->query_id->fetch_fetch_row();
                 break;
             case "both":
                 $this->record = $this->query_id->fetch_array();
                 break;
         }
     } else {
         if ($this->db_type == "mysql") {
             switch ($result_type) {
                 case "assoc":
                     $this->record = mysql_fetch_assoc($this->query_id);
                     break;
                 case "num":
                     $this->record = mysql_fetch_row($this->query_id);
                     break;
                 case "both":
                     $this->record = mysql_fetch_array($this->query_id);
                     break;
             }
         }
     }
     if ($this->db_type == "mysqli") {
         $this->errno = $this->link_id->errno;
         $this->error = $this->link_id->error;
     } else {
         if ($this->db_type == "mysql") {
             $this->errno = mysql_errno($this->link_id);
             $this->error = mysql_error($this->link_id);
         }
     }
     $status = is_array($this->record);
     if (!$status && $this->auto_free) {
         $this->freeResult();
     }
     return $status;
 }
コード例 #4
0
ファイル: class.DbMysqli.php プロジェクト: GavinLai/SimMatch
 /**
  * Fetch a result row as an associative array.
  *
  * @param resource $query
  *   The result resource that is being evaluated. This result comes from a call to mysql_query().
  * @return array
  *   Returns an associative array that corresponds to the fetched row and moves the internal data pointer ahead.
  */
 function fetch_assoc($query)
 {
     if ($query instanceof mysqli_result) {
         return $query->fetch_assoc();
     }
     return FALSE;
 }
コード例 #5
0
 /**
  * Gets an associative array from a SQL result (as returned by Database::query).
  * This method is equivalent to calling Database::fetch_array() with 'ASSOC' value for the optional second parameter.
  * @param resource $result	The result from a call to sql_query (e.g. Database::query).
  * @return array			Returns an associative array that corresponds to the fetched row and moves the internal data pointer ahead.
  */
 public static function fetch_assoc($result)
 {
     return $result->fetch_assoc();
 }
コード例 #6
0
ファイル: MySQLiHandler.php プロジェクト: GeneralCrime/code
 /**
  * Fetches a record from the database using the given result resource.
  *
  * @param resource $resultCursor The result resource returned by executeStatement() or executeTextStatement().
  * @param int $type The type the returned data should have. Use the static *_FETCH_MODE constants.
  *
  * @return string[] The associative result array. Returns false if no row was found.
  *
  * @author Christian Achatz
  * @version
  * Version 0.1, 09.03.2010<br />
  * Version 0.2, 30.07.2010 (Changed return value to false if no row was found, in order to follow the interface definition)<br />
  * Version 0.3, 08.08.2010 (Added optional second parameter) <br />
  */
 public function fetchData($resultCursor, $type = self::ASSOC_FETCH_MODE)
 {
     if ($resultCursor == null) {
         return false;
     }
     if ($type === self::ASSOC_FETCH_MODE) {
         $return = $resultCursor->fetch_assoc();
     } elseif ($type === self::OBJECT_FETCH_MODE) {
         $return = $resultCursor->fetch_object();
     } else {
         $return = $resultCursor->fetch_row();
     }
     if ($return === null) {
         return false;
     }
     return $return;
 }
コード例 #7
0
ファイル: Mysqli.php プロジェクト: djeraseit/quickbooks-php
 /**
  * Fetch an array from a database result set
  * 
  * @param resource $res
  * @return array
  */
 protected function _fetch($res)
 {
     return $res->fetch_assoc();
     // $res->fetch_assoc();
 }
コード例 #8
0
 /**
  * Return reference to next row in result set.
  * @param mysqli_result|resource|PDOStatement $result
  * @return array
  */
 public function nextRow($result)
 {
     return $result->fetch_assoc();
 }
コード例 #9
0
ファイル: DBIns.php プロジェクト: lanma121/superPrize
 /**
  * 针对query和execute的结果,进行数组话输出
  *
  * 仅对select查询有效
  *
  * @param resource $result
  *
  * @return array
  */
 public function fetchAll($result)
 {
     $ret = array();
     while ($row = $result->fetch_assoc()) {
         $ret[] = $row;
     }
     return $ret;
 }
コード例 #10
0
 /**
  * The result set setter
  * 
  * @access public
  * @param resource $rs A valid MySQLi result resource identifier
  */
 public function setResult($rs = false)
 {
     // A result identifier is a must have
     if (empty($rs)) {
         return false;
     }
     // Get multiple result sets from the MySQL query result if we can
     $recordSet = array();
     while ($row = $rs->fetch_assoc()) {
         $recordSet[] = $row;
     }
     // Add the record sets into the result set
     $this->_resultSet[] = $recordSet;
 }
コード例 #11
0
 /**
  * Devolvemos el array con los datos de la consulta
  * @param string $field Campo objetivo.
  * @param string $default Valor a retornar si el campo no existe o está vacío.
  * @return array|string Todos los campos o sólo uno
  */
 public function fetch($field = null, $default = null)
 {
     $this->result = $this->data->fetch_assoc();
     if ($field !== null) {
         return isset($this->result[$field]) ? $this->result[$field] : $default;
     } else {
         return $this->result;
     }
 }