/** * Return All values of Results in one choose format * @param constant $type Format of return * @return array */ public function fetchAll($type = SQLAnywhereClient::FETCH_ASSOC) { $data = array(); if ($this->result) { switch ($type) { case 'array': while ($row = sasql_fetch_array($this->result)) { array_push($data, $row); } break; case 'assoc': while ($row = sasql_fetch_assoc($this->result)) { array_push($data, $row); } break; case 'row': while ($row = sasql_fetch_row($this->result)) { array_push($data, $row); } break; case 'field': while ($row = sasql_fetch_field($this->result)) { array_push($data, $row); } break; case 'object': while ($row = sasql_fetch_object($this->result)) { array_push($data, $row); } break; default: while ($row = sasql_fetch_array($this->result)) { array_push($data, $row); } break; } } return $data; }
/** * {@inheritdoc} * * @throws SQLAnywhereException */ public function fetch($fetchMode = null) { if (!is_resource($this->result) || get_resource_type($this->result) !== 'SQLAnywhere result') { return false; } $fetchMode = $fetchMode ?: $this->defaultFetchMode; switch ($fetchMode) { case PDO::FETCH_ASSOC: return sasql_fetch_assoc($this->result); case PDO::FETCH_BOTH: return sasql_fetch_array($this->result, SASQL_BOTH); case PDO::FETCH_CLASS: $className = $this->defaultFetchClass; $ctorArgs = $this->defaultFetchClassCtorArgs; if (func_num_args() >= 2) { $args = func_get_args(); $className = $args[1]; $ctorArgs = isset($args[2]) ? $args[2] : array(); } $result = sasql_fetch_object($this->result); if ($result instanceof \stdClass) { $result = $this->castObject($result, $className, $ctorArgs); } return $result; case PDO::FETCH_NUM: return sasql_fetch_row($this->result); case PDO::FETCH_OBJ: return sasql_fetch_object($this->result); default: throw new SQLAnywhereException('Fetch mode is not supported: ' . $fetchMode); } }
/** * Fetch a row as an array with numeric indices */ function db_fetch_row($qid = false) { if ($qid === false) { return false; } return sasql_fetch_row($qid); }