Example #1
0
 /**
  * DBRecord is not intended to be used on it's own and should be implemented as a subclass for the specific model.
  * However, in the case of quick and/or simple tasks, the class may be instantiated as a standalone object as such:
  *
  *		$o = new DBRecord('TableName');
  *
  * If the DBRecord is implemented as a subclass which defines the table name, the constructor does one of two things
  * depending on the data passed to it.  If the argument is an array the argument is used as the initial record; otherwise
  * the value is converted to a string and passed to the load() function as the primary key value.
  * 
  * If the argument is absent, an empty record is instantiated.
  * 
  * @param array|integer|string $o optional
  */
 function __construct($o = null)
 {
     //set up our pdo link
     if (!$this->pdolink && is_callable('Database::Link')) {
         $this->pdolink = Database::Link();
     }
     if ($o) {
         if (is_array($o)) {
             parent::__construct($o);
             $this->_recordLoaded();
         } else {
             if ($this->tablename && $this->primary) {
                 $this->load($o);
             } elseif (is_string($o)) {
                 $this->tablename = $o;
                 $this->_loadKeys();
             }
         }
     }
 }