Ejemplo n.º 1
0
 /**
  * Returns the table name. If the property Model::isPlural is not overridden, then the singular form of the classname is used.
  *
  * @return string
  */
 public function getTableName()
 {
     if (isset($this->table)) {
         return $this->table;
     }
     return TableHelper::getTableName($this);
 }
Ejemplo n.º 2
0
 /**
  * Sets meta data for the object.
  *
  * @param $resource object An instance of p810\MySQL\Connection.
  * @param $table object|string An instance of p810\Model\Model or the table name as a string.
  * @param $data array Data returned by the query.
  * @return void
  */
 function __construct(Connection $resource, $table, $data)
 {
     $this->resource = $resource;
     $this->data = $data;
     if (is_object($table) && $table instanceof Model) {
         $this->table = $table->getTableName();
         $this->identifyBy($table->getPrimaryKey());
     } else {
         $this->table = TableHelper::getTableName($table);
         $primaryKey = TableHelper::getPrimaryKey($table);
         // Attempt to find the primary key so that most tables won't require a manual call to Row::identifyBy()
         if (array_key_exists($primaryKey, $data)) {
             $this->identifyBy($primaryKey);
         }
     }
 }