/** * Fetch rows of query result as associative array * * @param string $query * @param string $valueAsArrayIndex If not null you need to define a field name of the table * e.g. your table has {id, name, email} fields, if you set it to 'name' the key of resulting * array is the value of the field 'name' * @return array[] */ public function fetchAsAssoc($query, $valueAsArrayIndex = null) { $fetch = array(); $this->query($query); while ($row = $this->lastResult->fetch_assoc()) { if ($valueAsArrayIndex) { if (!isset($row[$valueAsArrayIndex])) { error("Field '{$valueAsArrayIndex}' does not exist in SQL Result"); } $fetch[$row[$valueAsArrayIndex]] = $row; } else { $fetch[] = $row; } } return $fetch; }
/** * Return the next row of results from the last query. * * @return array */ function getRow() { return $this->resid ? $this->resid->fetch_assoc() : false; }
/** * Returns the current row of a result set as an array * * @access private * @since 2.3 * @return array */ function _fetchArray() { return $this->resultId->fetch_assoc(); }
/** * Internal method to fetch the next row in a result set * * @return Array Returns the field values */ public function fetch() { return $this->result->fetch_assoc(); }
public function fetch_assoc($type_cast = false) { return $type_cast ? $this->type_cast(parent::fetch_assoc()) : parent::fetch_assoc(); }