Ejemplo n.º 1
0
 /**
  * @return Row
  */
 public function current()
 {
     if (array_key_exists($this->position, $this->cache)) {
         return $this->cache[$this->position];
     } else {
         return $this->cache[$this->position] = $this->processor->loadDataObject($this->result->fetch(\PDO::FETCH_ASSOC));
     }
 }
Ejemplo n.º 2
0
 public function fetch($fetchMode = null)
 {
     $fetchMode = $fetchMode ?: $this->defaultFetchMode;
     $row = $this->stmt->fetch($fetchMode);
     $row = $this->fixRow($row, $this->portability & (Connection::PORTABILITY_EMPTY_TO_NULL | Connection::PORTABILITY_RTRIM), !is_null($this->case) && ($fetchMode == PDO::FETCH_ASSOC || $fetchMode == PDO::FETCH_BOTH) && $this->portability & Connection::PORTABILITY_FIX_CASE);
     return $row;
 }
Ejemplo n.º 3
0
 /**
  * fetch
  *
  * @see Query::HYDRATE_* constants
  * @param integer $fetchStyle           Controls how the next row will be returned to the caller.
  *                                      This value must be one of the Query::HYDRATE_* constants,
  *                                      defaulting to Query::HYDRATE_BOTH
  *
  * @param integer $cursorOrientation    For a PDOStatement object representing a scrollable cursor,
  *                                      this value determines which row will be returned to the caller.
  *                                      This value must be one of the Query::HYDRATE_ORI_* constants, defaulting to
  *                                      Query::HYDRATE_ORI_NEXT. To request a scrollable cursor for your
  *                                      PDOStatement object,
  *                                      you must set the PDO::ATTR_CURSOR attribute to Doctrine::CURSOR_SCROLL when you
  *                                      prepare the SQL statement with Doctrine_Adapter_Interface->prepare().
  *
  * @param integer $cursorOffset         For a PDOStatement object representing a scrollable cursor for which the
  *                                      $cursorOrientation parameter is set to Query::HYDRATE_ORI_ABS, this value specifies
  *                                      the absolute number of the row in the result set that shall be fetched.
  *
  *                                      For a PDOStatement object representing a scrollable cursor for
  *                                      which the $cursorOrientation parameter is set to Query::HYDRATE_ORI_REL, this value
  *                                      specifies the row to fetch relative to the cursor position before
  *                                      PDOStatement->fetch() was called.
  *
  * @return mixed
  */
 public function fetch($fetchStyle = PDO::FETCH_BOTH)
 {
     if ($this->data === null) {
         $this->data = array();
     }
     $row = $this->statement->fetch(PDO::FETCH_ASSOC);
     if ($row) {
         $this->data[] = $row;
         if ($fetchStyle == PDO::FETCH_ASSOC) {
             return $row;
         } else {
             if ($fetchStyle == PDO::FETCH_NUM) {
                 return array_values($row);
             } else {
                 if ($fetchStyle == PDO::FETCH_BOTH) {
                     return array_merge($row, array_values($row));
                 } else {
                     throw new \InvalidArgumentException("Invalid fetch-style given for caching result.");
                 }
             }
         }
     }
     $this->emptied = true;
     return false;
 }
Ejemplo n.º 4
0
 /**
  * Hydrates a single row returned by the current statement instance during
  * row-by-row hydration with {@link iterate()}.
  *
  * @return mixed
  */
 public function hydrateRow()
 {
     $row = $this->_stmt->fetch(PDO::FETCH_ASSOC);
     if (!$row) {
         $this->cleanup();
         return false;
     }
     $result = array();
     $this->hydrateRowData($row, $this->_cache, $result);
     return $result;
 }
Ejemplo n.º 5
0
 /**
  * Implementation of Iterator.
  *
  * @link  http://php.net/manual/en/class.iterator.php
  */
 public function valid()
 {
     if (isset($this->results[$this->position])) {
         return true;
     }
     $result = $this->stmt->fetch(PDO::FETCH_ASSOC);
     if ($result) {
         $this->results[$this->position] = $result;
         return true;
     }
     return false;
 }
 protected function assertTableKeys($expected, Statement $query, $keyName)
 {
     $query->execute();
     $users = array();
     while ($row = $query->fetch()) {
         $users[] = $row[$keyName];
     }
     $query->closeCursor();
     $users = array_unique($users);
     sort($users);
     sort($expected);
     $this->assertEquals($expected, $users);
 }
Ejemplo n.º 7
0
 public function fetch($fetchMode = null)
 {
     $this->rows++;
     return $this->wrapped->fetch($fetchMode);
 }
Ejemplo n.º 8
0
 /**
  * Fetches the next row from a result set.
  *
  * @param integer|null $fetchMode
  *
  * @return mixed The return value of this function on success depends on the fetch type.
  *               In all cases, FALSE is returned on failure.
  */
 public function fetch($fetchMode = null)
 {
     return $this->stmt->fetch($fetchMode);
 }
Ejemplo n.º 9
0
 /**
  * Returns an array containing all of the result set rows.
  *
  * @param int|null $fetchMode Controls how the next row will be returned to the caller.
  *                            The value must be one of the PDO::FETCH_* constants,
  *                            defaulting to PDO::FETCH_BOTH.
  *
  * @return \Narrowspark\Collection\Collection
  *
  * @see PDO::FETCH_* constants.
  */
 public function fetchAll(int $fetchMode = null) : Collection
 {
     return new Collection($this->statement->fetch($fetchMode));
 }
 /**
  * {@inheritdoc}
  */
 public function next()
 {
     $this->current = $this->statement->fetch(\PDO::FETCH_ASSOC);
     ++$this->position;
 }
Ejemplo n.º 11
0
    /**
     * Returns the list of items based on the input SQL result pointer
     * For each result row the internal var, $this->internal['currentRow'], is set with the row returned.
     * $this->pi_list_header() makes the header row for the list
     * $this->pi_list_row() is used for rendering each row
     * Notice that these two functions are typically ALWAYS defined in the extension class of the plugin since they are directly concerned with the specific layout for that plugins purpose.
     *
     * @param Statement $statement Result pointer to a SQL result which can be traversed.
     * @param string $tableParams Attributes for the table tag which is wrapped around the table rows containing the list
     * @return string Output HTML, wrapped in <div>-tags with a class attribute
     * @see pi_list_row(), pi_list_header()
     */
    public function pi_list_makelist($statement, $tableParams = '')
    {
        // Make list table header:
        $tRows = [];
        $this->internal['currentRow'] = '';
        $tRows[] = $this->pi_list_header();
        // Make list table rows
        $c = 0;
        while ($this->internal['currentRow'] = $statement->fetch()) {
            $tRows[] = $this->pi_list_row($c);
            $c++;
        }
        $out = '

		<!--
			Record list:
		-->
		<div' . $this->pi_classParam('listrow') . '>
			<' . rtrim('table ' . $tableParams) . '>
				' . implode('', $tRows) . '
			</table>
		</div>';
        return $out;
    }
Ejemplo n.º 12
0
 /**
  * fetch the next row of a result set
  *
  * @param Statement $result as returned by query
  *
  * @return mixed false on error
  */
 private function fetch(Statement $result)
 {
     return $result->fetch(\PDO::FETCH_ASSOC);
 }
Ejemplo n.º 13
0
 /**
  * Save results to storage.
  *
  * @param AbstractDiffItem $item
  * @param Statement        $results
  * @param string           $action
  */
 protected function saveResult(AbstractDiffItem $item, Statement $results, $action = 'U')
 {
     $storage = $this->getStorageFacility();
     while ($row = $results->fetch(AbstractQuery::HYDRATE_ARRAY)) {
         $storage->save($action, $row[JobTableFields::TYPE], $row[JobTableFields::ID], $item->getTimestamp(), $this->getShopIds());
     }
 }
Ejemplo n.º 14
0
 /**
  * @param Statement $preparedStatement
  * @param           $filename
  *
  * @return array
  */
 protected function findFileInfo(Statement $preparedStatement, $filename)
 {
     $preparedStatement->execute([':oldFileKey' => $filename]);
     $fileInfo = $preparedStatement->fetch(\PDO::FETCH_ASSOC);
     if (false === $fileInfo) {
         throw new \RuntimeException(sprintf('Unknown file %s', $filename));
     }
     return $fileInfo;
 }
Ejemplo n.º 15
0
 /**
  * Gets the array from a SQL result (as returned by Database::query) - help achieving database independence
  * @param  \Doctrine\DBAL\Driver\Statement    The result from a call to Database::query())
  * @return array        Array of results as returned by php
  */
 public static function fetch_row(\Doctrine\DBAL\Driver\Statement $result)
 {
     return $result->fetch(PDO::FETCH_NUM);
     //return mysql_fetch_row($result);
 }
Ejemplo n.º 16
0
 /**
  * Gets the array from a SQL result (as returned by Database::query)
  * help achieving database independence
  *
  * @param Statement $result
  *
  * @return mixed
  */
 public static function fetch_row(Statement $result)
 {
     return $result->fetch(PDO::FETCH_NUM);
 }
Ejemplo n.º 17
0
 /**
  * provide an alias for fetch
  *
  * @return mixed
  */
 public function fetchRow()
 {
     return $this->statement->fetch();
 }
Ejemplo n.º 18
0
 /**
  * {@inheritdoc}
  */
 public function getFields()
 {
     $this->stmt->execute();
     return array_keys($this->stmt->fetch(\PDO::FETCH_ASSOC));
 }