function rewind() { if (isset($this->queryId) && $this->_is_resource($this->queryId) && mysqli_num_rows($this->queryId)) { if (mysqli_data_seek($this->queryId, 0) === false) { $this->connection->_raiseError(); } } elseif (!$this->queryId) { $query = $this->query; if (is_array($this->sort_params)) { if (preg_match('~(?<=FROM).+\\s+ORDER\\s+BY\\s+~i', $query)) { $query .= ','; } else { $query .= ' ORDER BY '; } foreach ($this->sort_params as $field => $order) { $query .= $this->connection->quoteIdentifier($field) . " {$order},"; } $query = rtrim($query, ','); } if ($this->limit) { $query .= ' LIMIT ' . $this->offset . ',' . $this->limit; } $this->queryId = $this->connection->execute($query); } $this->key = 0; $this->next(); }
/** * Seek * * @param int offset * @return bool success * @throws rdbms.SQLException */ public function seek($offset) { if (!mysqli_data_seek($this->handle, $offset)) { throw new SQLException('Cannot seek to offset ' . $offset); } return true; }
/** * Fonction basée sur l'api mysqli et * simulant la fonction mysql_result() * Copyright 2014 Marc Leygnac * * @param type $result résultat après requête * @param integer $row numéro de la ligne * @param string/integer $field indice ou nom du champ * @return type valeur du champ ou false si erreur */ function old_mysql_result($result, $row, $field = 0) { if ($result === false) { return false; } if ($row >= mysqli_num_rows($result)) { return false; } if (is_string($field) && !(strpos($field, ".") === false)) { // si $field est de la forme table.field ou alias.field // on convertit $field en indice numérique $t_field = explode(".", $field); $field = -1; $t_fields = mysqli_fetch_fields($result); for ($id = 0; $id < mysqli_num_fields($result); $id++) { if ($t_fields[$id]->table == $t_field[0] && $t_fields[$id]->name == $t_field[1]) { $field = $id; break; } } if ($field == -1) { return false; } } mysqli_data_seek($result, $row); $line = mysqli_fetch_array($result); return isset($line[$field]) ? $line[$field] : false; }
function getAllScheduleTimeslotsBetween($startTime, $endTime) { $timeslots = array(); $result = openConnection("Call get_all_schedule_timeslots();"); //var_dump($result); //$result = openConnection("get_all_schedule_timeslots_between(".$startTime.", ".$endTime.");"); $timeslots; if ($result->num_rows > 0) { mysqli_data_seek($result, 0); while ($row = $result->fetch_assoc()) { $startTime = $row['startTime']; $endTime = $row['endTime']; $timeslotId = $row['timeslotId']; $firefighterId = $row['firefighterId']; $firstName = $row['firstName']; $lastName = $row['lastName']; $email = $row['email']; $phone = $row['phone']; $secondaryPhone = $row['secondaryPhone']; $carrier = $row['phoneProvider']; $scheduleTimeslotId = $row['scheduleTimeslotId']; $firefighter = new Firefighter($firefighterId, $firstName, $lastName, $email, $phone, $secondaryPhone, $carrier); $timeslot = new TimeSlot($timeslotId, $startTime, $endTime, $firefighter); $scheduleTimeslot = new ScheduleTimeslot($timeslot, $scheduleTimeslotId); array_push($timeslots, $scheduleTimeslot); } } return $timeslots; }
public function rewind() { if ($this->index > 0) { @mysqli_data_seek($this->resource, 0); $this->index = 0; } $this->next(); }
/** * Moves the internal pointer to the specified row position. * * @param int $row Row position; zero-based and set to 0 by default * * @return bool Boolean true on success, false otherwise */ public function seek($row = 0) { if (is_int($row) && $row >= 0 && $row < $this->num_rows) { return mysqli_data_seek($this->result, $row); } else { return false; } }
public function rowSeek($rowNum) { $re = @mysqli_data_seek($this->query_result, $rowNum); if (!$re) { throw new Exception($this->errorInfo()); } return $re; }
function fetch_result($result, $row, $param) { if (mysqli_data_seek($result, $row)) { $line = mysqli_fetch_assoc($result); return $line[$param]; } return false; }
function reset() { if ($this->row > 0) { mysqli_data_seek($this->id, 0); } $this->row = -1; return TRUE; }
function Reset() { if ($this->ctype == 'mysqli') { mysqli_data_seek($this->result, 0); } else { mysql_data_seek($this->result, 0); } return TRUE; }
function next() { $this->cur++; if ($this->cur > $this->max) { return false; } mysqli_data_seek($this->res, $this->cur); return mysqli_fetch_assoc($this->res); }
public function seek($offset) { if ($this->offsetExists($offset) && \mysqli_data_seek($this->_result, $offset)) { $this->_current_row = $this->_internal_row = $offset; return true; } else { return false; } }
/** * Constructor method for the adapter. This constructor implements the setting of the * 3 required properties for the object. * * @param resource $d The datasource resource */ function mysqliAdapter($d) { parent::RecordSetAdapter($d); $fieldcount = mysqli_num_fields($d); $ob = ""; $be = $this->isBigEndian; $fc = pack('N', $fieldcount); if (mysqli_num_rows($d) > 0) { mysqli_data_seek($d, 0); while ($line = mysqli_fetch_row($d)) { // write all of the array elements $ob .= "\n" . $fc; foreach ($line as $value) { // write all of the array elements if (is_string($value)) { // type as string $os = $this->_directCharsetHandler->transliterate($value); //string flag, string length, and string $len = strlen($os); if ($len < 65536) { $ob .= "" . pack('n', $len) . $os; } else { $ob .= "\f" . pack('N', $len) . $os; } } elseif (is_float($value) || is_int($value)) { // type as double $b = pack('d', $value); // pack the bytes if ($be) { // if we are a big-endian processor $r = strrev($b); } else { // add the bytes to the output $r = $b; } $ob .= "" . $r; } elseif (is_bool($value)) { //type as bool $ob .= ""; $ob .= pack('c', $value); } elseif (is_null($value)) { // null $ob .= ""; } } } } $this->serializedData = $ob; // loop over all of the fields while ($field = mysqli_fetch_field($d)) { // decode each field name ready for encoding when it goes through serialization // and save each field name into the array $this->columnNames[] = $this->_directCharsetHandler->transliterate($field->name); } $this->numRows = mysqli_num_rows($d); }
function data_seek($result, $row = 0, $dbtype = 'mysql') { if ($dbtype == 'mysql') { mysqli_data_seek($result, $row); } else { if ($dbtype == 'postgres') { pg_result_seek($result, $row); } } }
public function seek($offset) { if ($this->offsetExists($offset) and mysqli_data_seek($this->_result, $offset)) { // Set the current row to the offset $this->_current_row = $this->_internal_row = $offset; return TRUE; } else { return FALSE; } }
/** * @see ResultSet::seek() */ public function seek($rownum) { // MySQL rows start w/ 0, but this works, because we are // looking to move the position _before_ the next desired position if (!@mysqli_data_seek($this->result, $rownum)) { return false; } $this->cursorPos = $rownum; return true; }
/** * function to override mysql_result */ function mysqlresult($res,$row=0,$col=0){ $numrows = mysqli_num_rows($res); if ($numrows && $row <= ($numrows-1) && $row >=0){ mysqli_data_seek($res,$row); $resrow = (is_numeric($col)) ? mysqli_fetch_row($res) : mysqli_fetch_assoc($res); if (isset($resrow[$col])){ return $resrow[$col]; } } return false; }
function get_result_as_arrays($result) { for ($i = 0; $i < $result->num_rows; $i++) { if (!mysqli_data_seek($result, $i)) { return false; } else { $data[] = mysqli_fetch_row($result); } } return $data; }
function MysqliResultQualtiva($res, $row = 0, $col = 0) { $numrows = MysqliNumRowsQualtiva($res); if ($numrows && $row <= $numrows - 1 && $row >= 0) { mysqli_data_seek($res, $row); $resrow = is_numeric($col) ? mysqli_fetch_row($res) : mysqli_fetch_assoc($res); if (isset($resrow[$col])) { return $resrow[$col]; } } return false; }
function result($query_id = 0, $row = 0) { if ($query_id) { if ($row) { @mysqli_data_seek($query_id, $row); } $cur_row = @mysqli_fetch_row($query_id); return $cur_row[0]; } else { return false; } }
public function next() { if ($this->current_row < $this->total_rows) { if (mysqli_data_seek($this->result, $this->current_row)) { $this->current_row++; return mysqli_fetch_assoc($this->result); } else { return false; } } else { return false; } }
function xtc_db_data_seek($db_query, $row_number, $cq = false) { if (DB_CACHE == 'true' && $cq) { if (!count($db_query)) { return; } return $db_query[$row_number]; } else { if (!is_array($db_query)) { return mysqli_data_seek($db_query, $row_number); } } }
function mysqli_result($res, $row = 0, $col = 0) { // aceasta functie face acelasi lucru ca mysql_result, dorim folosirea acestei functii deoarece mysql_result nu va mai fi folosit in versiunile viitoare $numrows = mysqli_num_rows($res); if ($numrows && $row <= $numrows - 1 && $row >= 0) { mysqli_data_seek($res, $row); $resrow = is_numeric($col) ? mysqli_fetch_row($res) : mysqli_fetch_assoc($res); if (isset($resrow[$col])) { return $resrow[$col]; } } return false; }
function mysql_fetch_rowsarr($result, $numass = MYSQLI_BOTH) { $i = 0; $keys = array_keys(mysqli_fetch_array($result, $numass)); mysqli_data_seek($result, 0); while ($row = mysqli_fetch_array($result, $numass)) { foreach ($keys as $speckey) { $got[$i][$speckey] = $row[$speckey]; } $i++; } return $got; }
/** * Constructor method for the adapter. This constructor implements the setting of the * 3 required properties for the object. * * @param resource $d The datasource resource */ function mysqliAdapter($d) { parent::RecordSetAdapter($d); while ($field = mysqli_fetch_field($d)) { $this->columns[] = $field->name; } if (mysqli_num_rows($d) > 0) { mysqli_data_seek($d, 0); while ($line = mysqli_fetch_row($d)) { $this->rows[] = $line; } } }
function output_widget($region, $place, $themeobject, $template, $request, $qa_content) { $temp = qa_db_query_sub('SELECT BINARY title as title, postid, netvotes, acount FROM ^posts WHERE type=$', 'Q'); $max = mysqli_num_rows($temp); if (!$max) { return; } $themeobject->output('<h2>' . qa_opt('random_question_title') . '</h2>'); for ($i = 0; $i < qa_opt('random_question_number'); $i++) { $rand = rand() / getrandmax() * $max; $check = mysqli_data_seek($temp, $rand); if (!$check) { $i--; } else { $random_question = qa_db_read_one_assoc($temp, true); } if (is_array($random_question)) { $votes = (int) $random_question['netvotes']; if ($votes > 0) { if ($votes > 1) { $votes = str_replace('^', '+' . $votes, qa_lang('main/x_votes')); } else { $votes = str_replace('1', '+1', qa_lang('main/1_vote')); } } else { if ($votes < 0) { if ($votes < -1) { $votes = str_replace('^', $votes, qa_lang('main/x_votes')); } else { $votes = str_replace('1', '-1', qa_lang('main/1_vote')); } } else { $votes = ''; } } $answers = (int) $random_question['acount']; if ($answers > 0) { if ($answers > 1) { $answers = str_replace('^', '+' . $answers, qa_lang('main/x_answers')); } else { $answers = qa_lang('main/1_answer'); } } else { $answers = ''; } $themeobject->output('<div class="random-question" style="padding-bottom:4px;"><a href="' . qa_path_html(qa_q_request($random_question['postid'], $random_question['title'])) . '">' . $random_question['title'] . '</a></div><div class="random-question-meta" style="padding-bottom:4px; border-bottom:1px solid; margin-bottom:2px;">' . $votes . ($votes && $answers ? ', ' : '') . $answers . '</div>'); } } }
function _getField($field, $connect) { global $table_name_student; $myquery = sprintf("SELECT %s FROM %s WHERE id='%s'", $field, $table_student, $_SESSION['id']); if ($resQuery = mysqli_query($connect, $myquery)) { mysqli_data_seek($resQuery, 0); if ($myValue = mysqli_fetch_row($resQuery)) { return $myValue[0]; } else { return NULL; } } else { return NULL; } }
function result($query_id = 0, $row = 0, $col = 0) { if ($query_id) { if ($row !== 0 && @mysqli_data_seek($query_id, $row) === false) { return false; } $cur_row = @mysqli_fetch_row($query_id); if ($cur_row === false) { return false; } return $cur_row[$col]; } else { return false; } }
function result_to_array($query_result, $key_column = null, $value_column = null) { $array = array(); if (!mysqli_num_rows($query_result)) { return $array; } mysqli_data_seek($query_result, 0); while ($r = mysqli_fetch_assoc($query_result)) { if ($key_column) { $array[$r[$key_column]] = $value_column ? $r[$value_column] : $r; } else { $array[] = $value_column ? $r[$value_column] : $r; } } return $array; }
/** * Fetches a row from the result * @return object */ public function fetch() { if (!$this->query) { return false; } if ($row = mysqli_fetch_object($this->query)) { return $row; } else { if ($this->size() > 0) { mysqli_data_seek($this->query, 0); return false; } else { return false; } } }