Source of file Result.php
Size: 6,247 Bytes - Last Modified: 2015-07-30T15:42:19-04:00
../src/Query/Drivers/Firebird/Result.php
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
Covered by 90 test(s):
65
Covered by 90 test(s):
66
Covered by 90 test(s):
67
Covered by 90 test(s):
68
Covered by 90 test(s):
6970717273
Covered by 90 test(s):
74
Covered by 90 test(s):
75
Covered by 81 test(s):
7677
Covered by 72 test(s):
78
Covered by 72 test(s):
798081
Covered by 81 test(s):
82
Covered by 81 test(s):
83
Covered by 90 test(s):
84858687888990919293949596979899
Covered by 1 test(s):
100101102103104105106107108109110111112113114115116
Covered by 1 test(s):
117118119120121122123124125126127128129130131
Covered by 1 test(s):
132133134135136137138139140141142143144145
Covered by 37 test(s):
146147148149150
Covered by 37 test(s):
151152
Covered by 37 test(s):
153154155156157158159160161162163164165166167168
Covered by 38 test(s):
169
Covered by 38 test(s):
170
Covered by 4 test(s):
171172173174
Covered by 38 test(s):
175176177
Covered by 38 test(s):
178
Covered by 38 test(s):
179
Covered by 37 test(s):
180181182183184
Covered by 38 test(s):
185
Covered by 1 test(s):
186
Covered by 1 test(s):
187188
Covered by 38 test(s):
189
Covered by 34 test(s):
190
Covered by 34 test(s):
191192
Covered by 10 test(s):
193
Covered by 10 test(s):
194
Covered by 10 test(s):
195
Covered by 10 test(s):
196197
Covered by 38 test(s):
198199200201202203204205206207208209210211212
Covered by 37 test(s):
213214
Covered by 37 test(s):
215216
Covered by 37 test(s):
217
Covered by 37 test(s):
218219
Covered by 37 test(s):
220221
Covered by 37 test(s):
222223224225226227228229230231232233234
Covered by 2 test(s):
235
Covered by 2 test(s):
236237238239240241242243244245246247248249
Covered by 1 test(s):
250251252253254255256257258259260261
Covered by 2 test(s):
262263264265266267268269270271272273
Covered by 1 test(s):
274275276277278279280281282283284285
Covered by 1 test(s):
286287288
Covered by 1 test(s):
| <?php /** * Query * * Free Query Builder / Database Abstraction Layer * * @package Query * @author Timothy J. Warren * @copyright Copyright (c) 2012 - 2014 * @link https://github.com/aviat4ion/Query * @license http://philsturgeon.co.uk/code/dbad-license */ // -------------------------------------------------------------------------- namespace Query\Drivers\Firebird; /** * Firebird result class to emulate PDOStatement Class - only implements * data-fetching methods * * @package Query * @subpackage Drivers */ class Result extends \PDOStatement { /** * Reference to fbird resource * * @var resource */ private $statement; /** * Current row in result array * * @var int */ private $row; /** * Data pulled from query * * @param mixed */ private $result = array(); /** * Reference to the db drive to de-duplicate error functions * * @var \Query\Drivers\Firebird\Driver */ private $db; /** * Create the object by passing the resource for * the query * * @param resource $link * @param Driver|null $db */ public function __construct($link, Driver $db = NULL) { if ( ! is_null($db)) $this->db = $db; $this->statement = $link; $this->setFetchMode(\PDO::FETCH_ASSOC); $this->row = -1; $this->result = array(); // Create the result array, so that we can get row counts // Check the resource type, because prepared statements are "interbase query" // but we only want "interbase result" types when attempting to fetch data if (\is_resource($link) && \get_resource_type($link) === "interbase result") { while($row = \fbird_fetch_assoc($link, \IBASE_FETCH_BLOBS)) { $this->result[] = $row; } // Free the result resource \fbird_free_result($link); } } // -------------------------------------------------------------------------- /** * Invalidate method for data consistency * * @param mixed $column * @param mixed $param * @param int $type * @param mixed $maxlen * @param array $driverdata * @return NULL */ public function bindColumn($column, &$param, $type=NULL, $maxlen=NULL, $driverdata=NULL) { return NULL; } // -------------------------------------------------------------------------- /** * Invalidate method for data consistency * * @param mixed $parameter * @param mixed $variable * @param int $data_type * @param mixed $maxlen * @param array $driverdata * @return NULL */ public function bindParam($parameter, &$variable, $data_type=NULL, $maxlen=NULL, $driverdata=NULL) { return NULL; } // -------------------------------------------------------------------------- /** * Invalidate method for data consistency * * @param mixed $parameter * @param mixed $variable * @param int $data_type * @return NULL */ public function bindValue($parameter, $variable, $data_type=NULL) { return NULL; } // -------------------------------------------------------------------------- /** * Run a prepared statement query * * @param array $args * @return Result */ public function execute($args = NULL) { //Add the prepared statement as the first parameter \array_unshift($args, $this->statement); // Let php do all the hard stuff in converting // the array of arguments into a list of arguments // Then pass the resource to the constructor $this->__construct(\call_user_func_array('fbird_execute', $args)); return $this; } // -------------------------------------------------------------------------- /** * Emulate PDO fetch public function * * @param int $fetch_style * @param mixed $cursor_orientation * @param mixed $cursor_offset * @return mixed */ public function fetch($fetch_style=\PDO::FETCH_ASSOC, $cursor_orientation = \PDO::FETCH_ORI_NEXT, $cursor_offset=NULL) { // If there is no result, continue if (empty($this->result)) { return NULL; } // Keep track of the current row being fetched ++$this->row; // return NULL if the next row doesn't exist if ( ! isset($this->result[$this->row])) { return NULL; } switch($fetch_style) { case \PDO::FETCH_OBJ: $row = (object) $this->result[$this->row]; break; case \PDO::FETCH_NUM: $row = \array_values($this->result[$this->row]); break; default: $row = $this->result[$this->row]; break; } return $row; } // -------------------------------------------------------------------------- /** * Emulate PDO fetchAll public function * * @param int $fetch_style * @param mixed $statement * @param mixed $ctor_args * @return mixed */ public function fetchAll($fetch_style=\PDO::FETCH_ASSOC, $statement=NULL, $ctor_args=NULL) { $all = array(); while($row = $this->fetch($fetch_style, $statement)) { $all[] = $row; } $this->result = $all; return $all; } // -------------------------------------------------------------------------- /** * Emulate PDOStatement::fetchColumn * * @param int $column_num * @return mixed */ public function fetchColumn($column_num=0) { $row = $this->fetch(\PDO::FETCH_NUM); return $row[$column_num]; } // -------------------------------------------------------------------------- /** * Emulate PDOStatement::fetchObject, but only for the default use * * @param string $class_name * @param array $ctor_args * @return stdClass */ public function fetchObject($class_name='stdClass', $ctor_args=array()) { return $this->fetch(\PDO::FETCH_OBJ); } // -------------------------------------------------------------------------- /** * Return the number of rows affected by the previous query * * @return int */ public function rowCount() { return \fbird_affected_rows(); } // -------------------------------------------------------------------------- /** * Method to emulate PDOStatement->errorCode * * @return string */ public function errorCode() { return $this->db->errorCode(); } // -------------------------------------------------------------------------- /** * Method to emulate PDO->errorInfo / PDOStatement->errorInfo * * @return array */ public function errorInfo() { return $this->db->errorInfo(); } } // End of firebird_result.php |