Example #1
0
 /**
  * This function is meant to be called from the derived constructor
  * with the name of the Table in the database to setup the simple ORM.
  */
 protected function alias($name = null)
 {
     $this->table = Table::fromDb($name, $this->db);
     if ($this->table == null) {
         return;
     }
     $this->fields = $this->table->fieldNames();
     foreach ($this->table->fieldDetails() as $field) {
         if ($this->pk == null) {
             if (isset($field['primary'])) {
                 if ($field['primary']) {
                     $this->pk = $field['name'];
                 }
             }
         }
     }
     $this->name = $name;
 }