コード例 #1
0
 public function __construct()
 {
     /*
      * If this were a larger project this function should
      * have automatically pluralized the table name correctly.
      */
     if (empty($this->tableName)) {
         $this->tableName = strtolower(get_class($this));
         if (substr($this->tableName, -1) != 's') {
             $this->tableName .= 's';
         }
     }
     //		$this->belongs_to = ARExpect::expectAssocArray($this->belongs_to);
     //		$this->has_many = ARExpect::expectAssocArray((array)$this->has_many);
     $this->serialize = ARExpect::expectArray($this->serialize);
     $this->_adapter =& self::$adapter;
     if ($this->getCache('$tableFields$') === null) {
         $this->fields = $this->getTableFields();
         $this->setCache('$tableFields$', $this->fields);
     } else {
         $this->fields = $this->getCache('$tableFields$');
     }
     if (func_num_args() == 1) {
         $arg = func_get_arg(0);
         if (is_array($arg)) {
             $this->initWithArray($arg);
         } else {
             $this->initFromId($arg);
         }
     } elseif (func_num_args() == 2) {
         $arg1 = func_get_arg(0);
         $arg2 = func_get_arg(1);
         $this->initFromKVP($arg1, $arg2);
     } elseif (func_num_args() == 0) {
         $this->isNew = true;
     } else {
         throw new Exception('Invalid number of arguments to initialization of ' . get_class($this));
     }
 }
コード例 #2
0
 function testStringToArray()
 {
     $this->assertEqual(serialize(array('test', 'test2')), serialize(ARExpect::expectArray('test,test2')));
 }