Exemplo n.º 1
0
 /**
  * @param array|\Traversable|\waModel $m model to use for saving
  * @param mixed $id id of existing record, as accepted by model; omit to create new record.
  */
 public function __construct(waModel $m, $id = null)
 {
     parent::__construct();
     $this->m = $m;
     if ($id) {
         $this->id = $id;
         $this->persistent[$this->m->getTableId()] = $id;
     } else {
         $this->setAll($this->getDefaultValues());
     }
 }
Exemplo n.º 2
0
 /**
  * @param waModel $m model to use for saving
  * @param mixed $id id of existing record, as accepted by model; omit to create new record.
  */
 public function __construct(waModel $m, $id = null)
 {
     parent::__construct();
     $this->m = $m;
     $table_id_field = $this->m->getTableId();
     if (!$table_id_field || !is_string($table_id_field)) {
         throw new waException('waDbRecord requires primary key and only supports simple (non-composite) primary keys');
     }
     if ($id) {
         $this->id = $id;
         $this->persistent[$table_id_field] = $id;
     } else {
         $this->setAll($this->getDefaultValues());
     }
 }