Exemple #1
0
 /**
  * Creates a row instance.
  * @param array $data
  * @param Result $result
  */
 public function __construct(array $data, Result $result)
 {
     $this->data = $data;
     $this->connection = $result->getConnection();
     $this->table = $result->getTable();
     $this->primary = $result->getPrimaryKey();
     $this->frozen = !$this->table || !$this->primary || !isset($this->data[$this->primary]);
 }
Exemple #2
0
 /**
  * SELECT statement factory.
  * @param string|array $columns Array or comma-separated list (optional)
  * @param string $table
  * @return Result fluent interface
  */
 public function select($columns = null, $table = null)
 {
     $result = new Result($this->connection, $columns, $table);
     foreach ($this->observers as $observer) {
         $result->attachObserver($observer, $this->observers->getInfo());
     }
     return $result;
 }
Exemple #3
0
 /**
  * Implementation of SeekableIterator.
  * @param int $offset
  * @throws OutOfRangeException|DriverException
  */
 public function seek($offset)
 {
     try {
         $this->result->seek($offset);
     } catch (DriverException $e) {
         throw $e;
     } catch (NeevoException $e) {
         throw new OutOfRangeException("Cannot seek to offset {$offset}.", null, $e);
     }
     $this->row = $this->result->fetch();
     $this->pointer = $offset;
 }
Exemple #4
0
 public function testParseSourceJoinSubqueryAutoAlias()
 {
     $sq1 = new Result($this->connection, 'tab2');
     $sq2 = new Result($this->connection, 'tab3');
     $result = new Result($this->connection, 'tab1');
     $this->assertEquals("`tab1`\nLEFT JOIN (\n\tSELECT *\n\tFROM `tab2`\n) `_join_1` ON `foo`" . "\nLEFT JOIN (\n\tSELECT *\n\tFROM `tab3`\n) `_join_2` ON `bar`", $this->parser($result->leftJoin($sq1, ':foo')->leftJoin($sq2, ':bar'))->parseSource());
 }
Exemple #5
0
 public function testExplain()
 {
     $this->assertEquals(DummyResult::$dataExplain, $this->result->explain());
 }
Exemple #6
0
 protected function setUp()
 {
     $this->result = new Result(new Connection('driver=Dummy'), 'author');
     $this->row = new Row($this->result->getConnection()->getDriver()->getRow(0), $this->result);
 }