Exemple #1
0
 public function save()
 {
     if ($this->_isNew) {
         Pii::app()->db->save($this);
     } else {
         Pii::app()->db->update($this);
     }
 }
Exemple #2
0
 private static function _getDbInfo($key)
 {
     $config = Pii::app()->config;
     $dbInfo = $config->getValue($key, 'db');
     if (!$dbInfo) {
         throw new PiiException('there is no db info in config');
     }
     return $dbInfo;
 }
Exemple #3
0
 private function _createTableInfo($tableName)
 {
     echobr('表的缓冲池没有表信息,开始实例化表信息');
     $tmp = Pii::app()->db->getTableInfo($tableName);
     $tableInfo = [];
     foreach ($tmp as $info) {
         $tableInfo[$info['Field']] = $info;
     }
     return $tableInfo;
 }
Exemple #4
0
 /**
  * 后期可能加入依赖注入
  */
 public function createObject($className)
 {
     $config = Pii::app()->config;
     $classPrefix = $config->getValue($className, 'core');
     if ($classPrefix) {
         echobr($classPrefix . '\\' . $className);
         return call_user_func([$classPrefix . '\\' . $className, 'getInstance']);
     } else {
         $className = $config->getValue($className, 'alias');
         if (!$className) {
             throw new PiiException('there is no exist config for this name');
         }
         return call_user_func([$className, 'getInstance']);
     }
 }
Exemple #5
0
function getClassFile($className)
{
    //echobr($className);
    $configs = \vendor\core\Pii::app()->config;
    foreach ($configs as $config) {
        var_dump($config);
        if (array_key_exists($className, $config)) {
            $fileName = dirname(__DIR__) . $config[$className] . $className . '.php';
            echobr($fileName);
            if (file_exists($fileName)) {
                return $fileName;
            }
        }
    }
    return false;
}