Пример #1
0
 /**
  * Get Tables List
  */
 private function _getTablesList()
 {
     $dir = ROOT_PATH . '/model/Structures/';
     $finder = new Finder\Finder();
     $finder->files()->in($dir);
     $tables = array();
     foreach ($finder as $file) {
         $fileName = @$file->getRelativePathname();
         $tmp = explode('.', $fileName);
         $table = Inflection::camelCaseToHungary($tmp[0]);
         if (!empty($this->_specialModels)) {
             if (true == in_array($table, $this->_specialModels)) {
                 $tables[] = $table;
             }
         } else {
             $tables[] = $table;
         }
     }
     return $tables;
 }
 public function __call($method, $params)
 {
     foreach ($this->_behaviors as $behavior) {
         if ($behavior->getEnable() && method_exists($behavior, $method)) {
             return call_user_func_array(array($behavior, $method), $params);
         }
     }
     if (strrpos($method, 'set') === 0 && isset($params[0]) && null !== $params[0]) {
         $name = Inflection::camelCaseToHungary(substr($method, 3, strlen($method)));
         if (isset(static::$_cols[$name])) {
             $this->_data[$name] = $this->fixData($params[0], static::$_schema[$name]);
             $this->_modifiedCols[$name] = true;
         } else {
             $this->{$name} = $params[0];
         }
         return true;
     }
     if (strpos($method, 'get') === 0) {
         $name = Inflection::camelCaseToHungary(substr($method, 3, strlen($method)));
         if (in_array($name, static::$_cols)) {
             return isset($this->_data[$name]) ? $this->_data[$name] : null;
         }
         return $this->{$name};
     }
     $lcMethod = strtolower($method);
     if (substr($lcMethod, 0, 6) == 'findby') {
         $by = substr($method, 6, strlen($method));
         $method = 'findBy';
         $one = false;
     } else {
         if (substr($lcMethod, 0, 9) == 'findoneby') {
             $by = substr($method, 9, strlen($method));
             $method = 'findOneBy';
             $one = true;
         }
     }
     if ($method == 'findBy' || $method == 'findOneBy') {
         if (isset($by)) {
             if (!isset($params[0])) {
                 throw new Exception('You must specify the value to ' . $method);
             }
             /*if ($one) {
                   $fieldName = static::_resolveFindByFieldsName($by);
                   if(false == $fieldName) {
                       throw new Exception('Column ' .$fieldName .' not found!');
                   }
               }*/
             return static::findBy($by, $params, $one);
         }
     }
     if (substr($lcMethod, 0, 10) == 'retrieveby') {
         $by = substr($method, 10, strlen($method));
         $method = 'retrieveBy';
         if (isset($by)) {
             if (!isset($params[0])) {
                 return false;
                 //@FIXED not need throw exception
                 //throw new Exception('You must specify the value to ' . $method);
             }
             return static::retrieveBy($by, $params);
         }
     }
     //        return parent::$method($params);
 }