Parcourir la source

项目里边的文件都以小写为准,不使用大写

Zhu Jinhui il y a 7 ans
Parent
commit
4f5a11cbea
3 fichiers modifiés avec 226 ajouts et 218 suppressions
  1. 208 196
      Qii/Driver/Model.php
  2. 13 13
      _cli.php
  3. 5 9
      _cli/app.ini

+ 208 - 196
Qii/Driver/Model.php

@@ -7,14 +7,13 @@
  * namespace Model;
  *
  * use \Qii\Model;
-
  * class comments extends Model
  * {
- * 		public function __construct()
- * 		{
- * 			parent::__construct();
- * 			$this->setRules(new \Qii\Driver\Rules(\Qii\Autoloader\Import::includes('configure/table/adcycle.comments.config.php')));
- * 		}
+ *        public function __construct()
+ *        {
+ *            parent::__construct();
+ *            $this->setRules(new \Qii\Driver\Rules(\Qii\Autoloader\Import::includes('configure/table/adcycle.comments.config.php')));
+ *        }
  * }
  * 2.
  * $test = _M(new \Qii\Driver\Rules(\Qii\Autoloader\Import::includes('configure/table/test.config.php')));
@@ -25,198 +24,211 @@ namespace Qii\Driver;
 
 class Model
 {
-	const VERSION = '1.2';
-	/**
-	 * @var $_allow 允许使用的数据库驱动类新
-	 */
-	protected $_allow = array('pdo', 'mysql', 'mysqli');
-	/**
-	 * @var $db 数据库实例
-	 */
-	public $db = null;
-	/**
-	 * 数据库配置文件
-	 */
-	protected $_dbInfo;
-	/**
-	 * 数据库驱动
-	 */
-	protected $_driver = 'pdo';
-	/**
-	 * @var $_load 加载类
-	 */
-	public $_load;
-
-	/**
-	 * @var $_language 语言包
-	 */
-	public $_language;
-	/**
-	 * @var array $rules 数据表规则
-	 */
-	private $rules = null;
-	/**
-	 * @var \Qii_Driver_Easy $model
-	 */
-	private $model = array();
-	/**
-	 * @var Qii_Request_Abstract $_request 请求类
-	 */
-	protected $_request;
-	/**
-	 * @var $_helper helper类
-	 */
-	protected $_helper;
-
-	public function __construct()
-	{
-		$this->_load = \Qii\Autoloader\Psr4::getInstance()->loadClass('\Qii\Autoloader\Loader');
-		$this->_language = \Qii\Autoloader\Psr4::getInstance()->loadClass('\Qii\Language\Loader');
-		$this->_request = \Qii\Autoloader\Psr4::getInstance()->loadClass('Qii\Request\Http');
-		$this->_helper = \Qii\Autoloader\Psr4::getInstance()->loadClass('Qii\Autoloader\Helper');
-		$this->_dbInfo = \Qii\Config\Register::getAppConfigure(\Qii\Config\Register::get(\Qii\Config\Consts::APP_DB));
-		if (isset($this->_dbInfo['driver'])) {
-			$this->_driver = $this->_dbInfo['driver'];
-		}
-		if (!in_array($this->_driver, $this->_allow)) {
-			$this->_driver = array_shift($this->_allow);
-		}
-		\Qii\Autoloader\Import::requires(array(
-			Qii_DIR . DS . 'Qii' . DS . 'Driver' . DS . 'Base.php',
-			Qii_DIR . DS . 'Qii' . DS . 'Driver' . DS . 'ConnBase.php',
-			Qii_DIR . DS . 'Qii' . DS . 'Driver' . DS . 'ConnIntf.php',
-			Qii_DIR . DS . 'Qii' . DS . 'Driver' . DS . ucWords($this->_driver) . DS . 'Connection.php',
-			Qii_DIR . DS . 'Qii' . DS . 'Driver' . DS . ucWords($this->_driver) . DS . 'Driver.php',
-		));
-		$this->db = \Qii\Autoloader\Psr4::getInstance()->loadClass(
-		    '\Qii\Driver\\' . ucWords($this->_driver) . '\Driver',
+    const VERSION = '1.2';
+    /**
+     * @var $_allow 允许使用的数据库驱动类新
+     */
+    protected $_allow = array('pdo', 'mysql', 'mysqli');
+    /**
+     * @var $db 数据库实例
+     */
+    public $db = null;
+    /**
+     * 数据库配置文件
+     */
+    protected $_dbInfo;
+    /**
+     * 数据库驱动
+     */
+    protected $_driver = 'pdo';
+    /**
+     * @var $_load 加载类
+     */
+    public $_load;
+
+    /**
+     * @var $_language 语言包
+     */
+    public $_language;
+    /**
+     * @var array $rules 数据表规则
+     */
+    private $rules = null;
+    /**
+     * @var \Qii_Driver_Easy $model
+     */
+    private $model = array();
+    /**
+     * @var Qii_Request_Abstract $_request 请求类
+     */
+    protected $_request;
+    /**
+     * @var $_helper helper类
+     */
+    protected $_helper;
+
+    public function __construct()
+    {
+        $this->_load = \Qii\Autoloader\Psr4::getInstance()->loadClass('\Qii\Autoloader\Loader');
+        $this->_language = \Qii\Autoloader\Psr4::getInstance()->loadClass('\Qii\Language\Loader');
+        $this->_request = \Qii\Autoloader\Psr4::getInstance()->loadClass('Qii\Request\Http');
+        $this->_helper = \Qii\Autoloader\Psr4::getInstance()->loadClass('Qii\Autoloader\Helper');
+        $this->_dbInfo = \Qii\Config\Register::getAppConfigure(\Qii\Config\Register::get(\Qii\Config\Consts::APP_DB));
+        if (isset($this->_dbInfo['driver'])) {
+            $this->_driver = $this->_dbInfo['driver'];
+        }
+        if (!in_array($this->_driver, $this->_allow)) {
+            $this->_driver = array_shift($this->_allow);
+        }
+        \Qii\Autoloader\Import::requires(array(
+            Qii_DIR . DS . 'Qii' . DS . 'Driver' . DS . 'Base.php',
+            Qii_DIR . DS . 'Qii' . DS . 'Driver' . DS . 'ConnBase.php',
+            Qii_DIR . DS . 'Qii' . DS . 'Driver' . DS . 'ConnIntf.php',
+            Qii_DIR . DS . 'Qii' . DS . 'Driver' . DS . ucWords($this->_driver) . DS . 'Connection.php',
+            Qii_DIR . DS . 'Qii' . DS . 'Driver' . DS . ucWords($this->_driver) . DS . 'Driver.php',
+        ));
+        $this->db = \Qii\Autoloader\Psr4::getInstance()->loadClass(
+            '\Qii\Driver\\' . ucWords($this->_driver) . '\Driver',
             \Qii\Autoloader\Psr4::getInstance()->loadClass(
                 '\Qii\Driver\\' . ucWords($this->_driver) . '\Connection'
             )
         );
-		$this->db->_debugSQL = isset($this->_dbInfo['debug']) ? $this->_dbInfo['debug'] : false;
-		return $this;
-	}
-	/**
-	 * 将属性转到DB类中去
-	 */
-	public function __get($attr)
-	{
-		if($this->db)
-		{
-			return $this->db->$attr;
-		}
-		return null;
-	}
-
-	/**
-	 * 获取当前使用的数据库
-	 */
-	public function getUseDB()
-	{
-		return $this->db->useDB;
-	}
-
-	/**
-	 * 设置规则
-	 * @param array $rules
-	 */
-	public function setRules(\Qii\Driver\Rules $rules)
-	{
-		if (empty($rules)) throw new \Exception(\Qii::i('Please set rules first'), __LINE__);
-		$this->rules = $rules;
-		return $this;
-	}
-
-	/**
-	 * 生成数据库结构
-	 */
-	public function tableStruct()
-	{
-		$this->checkRulesInstance();
-		$struct = array_flip($this->rules->getFields());
-		foreach ($struct AS $key => $val) {
-			$struct[$key] = '';
-		}
-		return $struct;
-	}
-
-	/**
-	 * 检查是否已经设置规则
-	 */
-	final public function checkRulesInstance()
-	{
-		if ($this->rules == null) throw new \Exception(\Qii::i('Please set rules first'), __LINE__);
-	}
-	/**
-	 * 获取当前初始化的model
-	 * @return \Qii_Driver_Easy
-	 */
-	final public function getInstance()
-	{
-		$this->checkRulesInstance();
-		$tableName = $this->rules->getTableName();
-		if(!isset($this->model[$tableName])) $this->model[$tableName] = _DBDriver($this->rules);
-		return $this->model[$tableName];
-	}
-	/**
-	 * 设置主键
-	 * @param array $privateKey  设置主键
-	 * @return Object
-	 */
-	final public function setPrivateKey($privateKey = array())
-	{
-		$this->getInstance()->setPrivateKey($privateKey);
-		return $this;
-	}
-
-	/**
-	 * 检查数据是否存在
-	 * @param array $fields 数据
-	 * @return \Qii\Driver\Response
-	 */
-	final public function _exist($fields, $privateKey = array())
-	{
-		return $this->getInstance()->setPrivateKey($privateKey)->setFieldsVal($fields)->_exist();
-	}
-
-	/**
-	 * 保存数据
-	 * @param array $fields 数据
-	 * @return \Qii\Driver\Response
-	 */
-	final public function _save($fields, $privateKey = array())
-	{
-		return $this->getInstance()->setPrivateKey($privateKey)->setFieldsVal($fields)->_save();
-	}
-
-	/**
-	 * 更新数据
-	 * @param array $fields 数据
-	 * @return \Qii\Driver\Response
-	 */
-	final public function _update($fields, $privateKey = array())
-	{
-		return $this->getInstance()->setPrivateKey($privateKey)->setFieldsVal($fields)->_update();
-	}
-
-	/**
-	 * 删除数据
-	 * @param array $fields 数据
-	 * @return \Qii_Response
-	 */
-	final public function _remove($fields, $privateKey = array())
-	{
-		return $this->getInstance()->setPrivateKey($privateKey)->setFieldsVal($fields)->_remove();
-	}
-
-	/**
-	 * 方法不存在的时候调用$this->db下的方法
-	 * @param string $method 方法名
-	 * @param mix $args 参数
-	 */
-	public function __call($method, $args)
-	{
-		if ($this->db) return call_user_func_array(array($this->db, $method), $args);
-	}
+        $this->db->_debugSQL = isset($this->_dbInfo['debug']) ? $this->_dbInfo['debug'] : false;
+        return $this;
+    }
+
+    /**
+     * 设置属性
+     *
+     * @param string $name 属性名
+     * @param mix $val 值
+     */
+    public function __set($name, $val)
+    {
+        $this->db->$name = $val;
+    }
+
+    /**
+     * 将属性转到DB类中去
+     */
+    public function __get($attr)
+    {
+        if ($this->db) {
+            return $this->db->$attr;
+        }
+        return null;
+    }
+
+    /**
+     * 获取当前使用的数据库
+     */
+    public function getUseDB()
+    {
+        return $this->db->useDB;
+    }
+
+    /**
+     * 设置规则
+     * @param array $rules
+     */
+    public function setRules(\Qii\Driver\Rules $rules)
+    {
+        if (empty($rules)) throw new \Exception(\Qii::i('Please set rules first'), __LINE__);
+        $this->rules = $rules;
+        return $this;
+    }
+
+    /**
+     * 生成数据库结构
+     */
+    public function tableStruct()
+    {
+        $this->checkRulesInstance();
+        $struct = array_flip($this->rules->getFields());
+        foreach ($struct AS $key => $val) {
+            $struct[$key] = '';
+        }
+        return $struct;
+    }
+
+    /**
+     * 检查是否已经设置规则
+     */
+    final public function checkRulesInstance()
+    {
+        if ($this->rules == null) throw new \Exception(\Qii::i('Please set rules first'), __LINE__);
+    }
+
+    /**
+     * 获取当前初始化的model
+     * @return \Qii_Driver_Easy
+     */
+    final public function getInstance()
+    {
+        $this->checkRulesInstance();
+        $tableName = $this->rules->getTableName();
+        if (!isset($this->model[$tableName])) $this->model[$tableName] = _DBDriver($this->rules);
+        return $this->model[$tableName];
+    }
+
+    /**
+     * 设置主键
+     * @param array $privateKey 设置主键
+     * @return Object
+     */
+    final public function setPrivateKey($privateKey = array())
+    {
+        $this->getInstance()->setPrivateKey($privateKey);
+        return $this;
+    }
+
+    /**
+     * 检查数据是否存在
+     * @param array $fields 数据
+     * @return \Qii\Driver\Response
+     */
+    final public function _exist($fields, $privateKey = array())
+    {
+        return $this->getInstance()->setPrivateKey($privateKey)->setFieldsVal($fields)->_exist();
+    }
+
+    /**
+     * 保存数据
+     * @param array $fields 数据
+     * @return \Qii\Driver\Response
+     */
+    final public function _save($fields, $privateKey = array())
+    {
+        return $this->getInstance()->setPrivateKey($privateKey)->setFieldsVal($fields)->_save();
+    }
+
+    /**
+     * 更新数据
+     * @param array $fields 数据
+     * @return \Qii\Driver\Response
+     */
+    final public function _update($fields, $privateKey = array())
+    {
+        return $this->getInstance()->setPrivateKey($privateKey)->setFieldsVal($fields)->_update();
+    }
+
+    /**
+     * 删除数据
+     * @param array $fields 数据
+     * @return \Qii_Response
+     */
+    final public function _remove($fields, $privateKey = array())
+    {
+        return $this->getInstance()->setPrivateKey($privateKey)->setFieldsVal($fields)->_remove();
+    }
+
+    /**
+     * 方法不存在的时候调用$this->db下的方法
+     * @param string $method 方法名
+     * @param mix $args 参数
+     */
+    public function __call($method, $args)
+    {
+        if ($this->db) return call_user_func_array(array($this->db, $method), $args);
+    }
 }

+ 13 - 13
_cli.php

@@ -22,7 +22,7 @@ error_reporting(E_ALL ^ E_NOTICE ^ E_WARNING);
 class cmd
 {
     const VERSION = '1.2';
-    public $dir = array('Configure', 'Controller', 'Model', 'View', 'Plugins', 'tmp');
+    public $dir = array('configure', 'controller', 'model', 'view', 'plugins', 'tmp');
 
     public function __construct($args)
     {
@@ -103,13 +103,13 @@ class cmd
                     $appIni = file_get_contents('_cli/app.ini');
                     $appIni = str_replace('tmp/compile', $cache . '/compile', $appIni);
                     $appIni = str_replace('tmp/cache', $cache . '/cache', $appIni);
-                    file_put_contents($param['workspace'] . '/private/Configure/app.ini', $appIni);
-                }else if (!copy("_cli/app.ini", $param['workspace'] . '/private/Configure/app.ini')) {
-                     $this->stdout('拷贝 app.ini 到 ' . $param['workspace'] . '/private/Configure/app.ini失败, 拒绝访问.');
+                    file_put_contents($param['workspace'] . '/private/configure/app.ini', $appIni);
+                }else if (!copy("_cli/app.ini", $param['workspace'] . '/private/configure/app.ini')) {
+                     $this->stdout('拷贝 app.ini 到 ' . $param['workspace'] . '/private/configure/app.ini失败, 拒绝访问.');
                     
                 }
-                if (!copy("_cli/router.config.php", $param['workspace'] . '/private/Configure/router.config.php')) {
-                    $this->stdout('拷贝 router.config.php 到' . $param['workspace'] . '/private/Configure/router.config.php 失败, 拒绝访问.');
+                if (!copy("_cli/router.config.php", $param['workspace'] . '/private/configure/router.config.php')) {
+                    $this->stdout('拷贝 router.config.php 到' . $param['workspace'] . '/private/configure/router.config.php 失败, 拒绝访问.');
                 }
                 if ($param['useDB'] != 'no') {
                     $dbIni = file_get_contents('_cli/db.ini');
@@ -118,7 +118,7 @@ class cmd
                     $dbIni = str_replace('DB_USER', $param['dbUser'], $dbIni);
                     $dbIni = str_replace('DB_PASSWORD', $param['dbPassword'], $dbIni);
                     
-                    file_put_contents($param['workspace'] . '/private/Configure/db.ini', $dbIni);
+                    file_put_contents($param['workspace'] . '/private/configure/db.ini', $dbIni);
                 }
 
                 //生成数据库文件
@@ -144,19 +144,19 @@ class cmd
                 $indexPage[] = '$env = getenv(\'WEB_ENVIRONMENT\') ? getenv(\'WEB_ENVIRONMENT\') : \'product\';';
                 $indexPage[] = '$app->setEnv($env);';
                 $indexPage[] = '$app->setCachePath(\''.$cache.'\');';
-                $indexPage[] = '$app->setAppConfigure(\'private/Configure/app.ini\');';
-                if ($param['useDB']) $indexPage[] = '$app->setDB(\'../private/Configure/db.ini\');';
-                $indexPage[] = '$app->setRouter(\'../private/Configure/router.config.php\')';
+                $indexPage[] = '$app->setAppConfigure(\'private/configure/app.ini\');';
+                if ($param['useDB']) $indexPage[] = '$app->setDB(\'../private/configure/db.ini\');';
+                $indexPage[] = '$app->setRouter(\'../private/configure/router.config.php\')';
                 $indexPage[] = '->run();';
                 if (!file_exists($realPath . "/public/index.php")) {
                     //如果文件不存在就写入
                     file_put_contents($realPath . "/public/index.php", join("\n", $indexPage));
                 }
                 //写入首页controller
-                if (!file_exists($realPath . "/private/Controller/index.php")) {
+                if (!file_exists($realPath . "/private/controller/index.php")) {
                     $indexContents = array();
                     $indexContents[] = "<?php";
-                    $indexContents[] = 'namespace Controller;' . PHP_EOL;
+                    $indexContents[] = 'namespace controller;' . PHP_EOL;
                     $indexContents[] = 'use \Qii\Base\Controller;' . PHP_EOL;
                     $indexContents[] = "class index extends Controller";
                     $indexContents[] = "{";
@@ -168,7 +168,7 @@ class cmd
                     $indexContents[] = "\t\t return new \Qii\Base\Response(array('format' => 'html', 'body' => '请重写 '. __FILE__ . ' 中的 indexAction 方法, 第 ' . __LINE__ . ' 行'));";
                     $indexContents[] = "\t}";
                     $indexContents[] = "}";
-                    file_put_contents($realPath . "/private/Controller/index.php", join("\n", $indexContents));
+                    file_put_contents($realPath . "/private/controller/index.php", join("\n", $indexContents));
                 }
                 //apache rewrite file
                 $htaccessFile = $param['workspace'] . "/public/.htaccess";

+ 5 - 9
_cli/app.ini

@@ -7,10 +7,10 @@ qq = 119328118
 [common]
 ;程序是否使用命名空间
 namespace['use'] = true
-namespace[list.Controller] = true
-namespace[list.Model] = true
-namespace[list.Library] = true
-namespace[list.Action] = true
+namespace[list.controller] = true
+namespace[list.model] = true
+namespace[list.library] = true
+namespace[list.action] = true
 ;rewrite 方法, 此定义不能省略
 rewriteMethod = Short
 ;rewrite匹配规则,可选
@@ -18,11 +18,9 @@ rewriteRules = Normal
 ;hosts中的属性将会覆盖掉默认的属性,当在不同域名上使用不同配置上很有用处
 ;hosts[0.domain] = test.com
 ;hosts[0.path] = test
-;hosts[0.password] = test
 
 ;hosts[1.domain] = admin.test.com
 ;hosts[1.path] = admin
-;hosts[1.password] = admin
 
 ;是否开启调试模式,调试模式下,所有的错误都将抛出来,并终止运行
 debug = 1
@@ -68,7 +66,7 @@ query[] = param
 
 ;controller、action配置  name:参数名 ext:后缀;default:默认方法 
 controller[name] = controller
-controller[prefix] = Controller
+controller[prefix] = controller
 controller[default] = index
 
 action[name] = action
@@ -99,7 +97,5 @@ short[symbol] = "/"
 short[extenstion] = .html
 ;以下这种写法将会继承:后边的section,如果是"."开头的话就放在当前key下边
 [dev:common:.uri]
-password = 12345
 [product:common:.uri]
-password = 119328118