Exemple #1
0
 /**
  * Create a model that joins two or more tables
  *
  * @param string $name       A name for the model
  * @param string $startTable The base table for the model
  * @param mixed  $saveable   Will changes to this table be saved, true or a combination of SAVE_MODE constants
  */
 public function __construct($name, $startTable, $saveable = false)
 {
     parent::__construct($name);
     $alias = $this->_loadTable($startTable, $saveable);
     $table = $this->_tables[$alias];
     // Fix primary keys to those of the current table.
     $this->getKeys();
     $this->_select = new \Zend_Db_Select($table->getAdapter());
     $this->_select->from(array($alias => $this->_getTableName($table)), array());
 }
Exemple #2
0
 /**
  *
  * @param \Zend_Db_Table_Abstract $table An Zend abstract table or the table name
  * @param string $altName An alternative name to use, default is the name of the table itself
  */
 public function __construct($table, $altName = null)
 {
     if ($table instanceof \Zend_Db_Table_Abstract) {
         $this->_table = $table;
         $table_name = $this->_getTableName($table);
     } else {
         $this->_table = new \Zend_Db_Table($table);
         $table_name = $table;
     }
     parent::__construct(null === $altName ? $table_name : $altName);
     $this->_loadTableMetaData($this->_table);
 }
Exemple #3
0
 /**
  *
  * @param \Zend_Db_Select $select
  * @param string $name Optiona name
  */
 public function __construct(\Zend_Db_Select $select, $name = null)
 {
     $this->_select = $select;
     // Make sure the columns are known to the model
     foreach ($select->getPart(\Zend_Db_Select::COLUMNS) as $column) {
         if (isset($column[2])) {
             $this->set($column[2]);
         } elseif (is_string($column[1])) {
             $this->set($column[1]);
         }
     }
     if (null === $name) {
         $name = 'rnd' . rand(10000, 999999);
     }
     parent::__construct($name);
 }