Example #1
0
 /**
  * Constructor
  *
  * @param array $array
  * @return Model
  * @author Justin Palmer
  **/
 public function __construct($array = array())
 {
     $Adapter = Adapter::getDriverClass();
     //Generate the table name if it is not set.
     if ($this->table_name === null) {
         $this->table_name = Inflections::tableize(get_class($this));
     }
     //
     $this->schema = new Schema($this);
     $this->alias = Inflections::singularize($this->table_name);
     $this->errors = new Hash();
     //Store the db adapter.
     self::$db = new $Adapter($this);
     //Set the default database name;
     $config = $this->db()->getConfig();
     $this->database_name = $config->database;
     $this->props = new Hash();
     //Hold the columns from the db to make sure properties, rules and relationships set actually exist.
     $this->columns = $this->prepareShowColumns($this->showColumns());
     $this->setProperties($array);
     $this->init();
 }