예제 #1
0
 /**
  * Construct Dataset Table from Zend_Db_Table object
  *
  * @param \Zend\Db\Table\AbstractTable        $table
  * @param string|\Zend\Db\Select|null    $where
  * @param string|null                   $order
  * @param int                           $count
  * @param int                           $offset
  */
 public function __construct(\Zend\Db\Table\AbstractTable $table, $where = null, $order = null, $count = null, $offset = null)
 {
     $this->tableName = $table->info('name');
     $this->_columns = $table->info('cols');
     $this->_table = $table;
     $this->_where = $where;
     $this->_order = $order;
     $this->_count = $count;
     $this->_offset = $offset;
 }
예제 #2
0
 /**
  * Set the table object, to re-establish a live connection
  * to the database for a Row that has been de-serialized.
  *
  * @param \Zend\DB\Table\AbstractTable $table
  * @return boolean
  * @throws \Zend\DB\Table\Row\Exception
  */
 public function setTable(Table\AbstractTable $table = null)
 {
     if ($table == null) {
         $this->_table = null;
         $this->_connected = false;
         return false;
     }
     $tableClass = get_class($table);
     if (!$table instanceof $this->_tableClass) {
         throw new Exception("The specified Table is of class {$tableClass}, expecting class to be instance of {$this->_tableClass}");
     }
     $this->_table = $table;
     $this->_tableClass = $tableClass;
     $info = $this->_table->info();
     if ($info['cols'] != array_keys($this->_data)) {
         throw new Exception('The specified Table does not have the same columns as the Row');
     }
     if (!array_intersect((array) $this->_primary, $info['primary']) == (array) $this->_primary) {
         throw new Exception("The specified Table '{$tableClass}' does not have the same primary key as the Row");
     }
     $this->_connected = true;
     return true;
 }
예제 #3
0
 /**
 * Adds a FROM table and optional columns to the query.
 *
 * The table name can be expressed
 *
 * @param  array|string|Zend_Db_Expr|\Zend\Db\Table\AbstractTable $name The table name or an
                                                                  associative array relating
                                                                  table name to correlation
                                                                  name.
 * @param  array|string|\Zend\Db\Expr $cols The columns to select from this table.
 * @param  string $schema The schema name to specify, if any.
 * @return \Zend\Db\Table\Select This \Zend\Db\Table\Select object.
 */
 public function from($name, $cols = self::SQL_WILDCARD, $schema = null)
 {
     if ($name instanceof AbstractTable) {
         $info = $name->info();
         $name = $info[AbstractTable::NAME];
         if (isset($info[AbstractTable::SCHEMA])) {
             $schema = $info[AbstractTable::SCHEMA];
         }
     }
     return $this->joinInner($name, null, $cols, $schema);
 }
예제 #4
0
 /**
  * Add a Table dataset representation by specifiying an arbitrary select query.
  *
  * By default a select * will be done on the given tablename.
  *
  * @param \Zend\Db\Table\AbstractTable $table
  * @param string|\Zend\Db\Select $query
  * @param string $where
  * @param string $order
  * @param string $count
  * @param string $offset
  */
 public function addTable(\Zend\Db\Table\AbstractTable $table, $where = null, $order = null, $count = null, $offset = null)
 {
     $tableName = $table->info('name');
     $this->tables[$tableName] = new DbTable($table, $where, $order, $count, $offset);
 }