Esempio n. 1
0
 public function __construct()
 {
     // automatically define table name (if not defined)
     if (!isset($this->_name)) {
         // delete prefix
         $className = preg_replace('`^.*Model_Table_`', '', get_class($this));
         // add slash after upper case letters
         $name = preg_replace('`[^_]([A-Z])`', '_$1', $className);
         // table name in lower case
         $this->_name = strtolower($name);
     }
     // load tables structure
     if (is_null(self::$_structure)) {
         self::$_structure = Days_Config::load('database')->get();
     }
     // check table definition
     if (!array_key_exists($this->_name, self::$_structure)) {
         throw new Days_Exception("Not defined table structure for `{$this->_name}`");
     }
     // set adapter for all tables
     if (!$this->_db) {
         $this->_db = Days_Db::factory();
         $this->_select = $this->_db->select();
     }
 }
Esempio n. 2
0
 /**
  * Delete variable (as array key).
  *
  * @param string $offset Int or string variable name
  */
 public final function offsetUnset($offset)
 {
     // magic field name
     $offset = $this->_table->column($offset);
     unset($this->_values[$offset]);
 }