/** * fetch one row * * you can provide one of the PDB::* constants to set the type * PDB::FETCH_BOTH * PDB::FETCH_ASSOC * PDB::FETCH_NUM * PDB::FETCH_OBJ * * @param mixed $style * @return mixed */ public function fetch($style = false) { if (!$this->result) { return false; } switch ($style) { case PDB::FETCH_BOTH: default: $res = $this->result->fetch_array(MYSQL_BOTH); break; case PDB::FETCH_ASSOC: $res = $this->result->fetch_array(MYSQL_ASSOC); break; case PDB::FETCH_NUM: $res = $this->result->fetch_array(MYSQL_NUM); break; case PDB::FETCH_OBJ: $res = $this->result->fetch_object(); break; } if ($res) { $this->pos++; } return $res; }
/** * return array of result * * @access public * @param string $type */ function getArray($type = '') { if (is_resource($this->connId->resId) || is_object($this->connId->resId)) { $tabOut = array(); while ($row = $this->connId->fetch_array(null, $type == '' ? SQLITE_ASSOC : $type)) { $tabOut[] = $row; } return $tabOut; } else { return false; } }
/** * 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; }
/** * Return an array with the data to send * * @access private * @return array */ function _getRecord() { if (isset($GLOBALS['TableListImpact'])) { $tableList = explode(',', $GLOBALS['TableListImpact']); if (count($tableList) > 1) { $withTableName = true; } else { $withTableName = false; } foreach ($tableList as $tableImpact) { if (!empty($tableImpact) && !preg_match('#\\.#', $tableImpact)) { $tempInfoTable = $this->SQLiteConnId->array_query('PRAGMA table_info(' . brackets(trim($tableImpact)) . ');'); if (is_array($tempInfoTable)) { foreach ($tempInfoTable as $infoTable) { if ($withTableName) { $this->NullInfo[trim($tableImpact) . '.' . $infoTable['name']] = $infoTable['notnull']; } else { $this->NullInfo[$infoTable['name']] = $infoTable['notnull']; } } } } } } if (strpos(trim($this->order), ' ')) { $order = '"' . $this->order . '"'; } else { $order = $this->order; } $query = $this->query . ($this->order ? ' ORDER BY ' . $order . ' ' . $this->orderSens : ''); if (!preg_match('#pragma#i', $this->query) && !preg_match('#limit#i', $this->query)) { $query .= ' LIMIT ' . $this->indexStart . ', ' . $this->recordPerPage; } if ($this->SQLiteConnId->query($query)) { unset($tabRecord); $tabRecord = array(); while ($ligne = $this->SQLiteConnId->fetch_array(null, SQLITE_NUM)) { $tabRecord[] = $ligne; } } $this->realQuery = $query; return $tabRecord; }
/** * Get one row data as associate array from resultset. * * @param resource $query * The result resource that is being evaluated. This result comes from a call to mysql_query(). * @param int[optional] $result_type * The type of array that is to be fetched. It's a constant and can take the following values: MYSQLI_ASSOC, MYSQLI_NUM, and MYSQLI_BOTH. * @return array * One row data in $query, or FALSE if there are no more rows */ function fetch_array($query, $result_type = MYSQLI_ASSOC) { if ($query instanceof mysqli_result) { return $query->fetch_array($result_type); } return FALSE; }
/** * Fetch a result row as an associative, a numeric array, or both. * * Returns an array of strings that corresponds to the fetched row or NULL * if there are no more rows in resultset. * * @param object|resource $result * A result returned by self::query(); * @param int $resultType * This optional parameter is a constant indicating what type of array * should be produced from the current row data. The possible values * for this parameter are the constants MYSQL_ASSOC, MYSQL_NUM, or * MYSQL_BOTH. * * @return array|null */ public function fetch($result, $resultType = null) { return $result->fetch_array($resultType); }
/** * Fetch a result row as an associative, a numeric array, or both. * * Returns an array of strings that corresponds to the fetched row or NULL * if there are no more rows in resultset. * * @param object|resource $result * A result returned by self::query(); * @param int $resultType * This optional parameter is a constant indicating what type of array * should be produced from the current row data. The possible values * for this parameter are the constants MYSQL_ASSOC, MYSQL_NUM, or * MYSQL_BOTH. * * @return array|null */ public function fetch($result, $resultType = MYSQLI_BOTH) { return $result->fetch_array($resultType); }
/** * 获取结果集 * @return array */ protected function fetch() { return $this->rs->fetch_array($this->fetch_mode); }