朱金辉 před 1 rokem
rodič
revize
4d1979baaa
3 změnil soubory, kde provedl 22 přidání a 14 odebrání
  1. 1 1
      composer.json
  2. 19 11
      src/Driver/Entity/Base.php
  3. 2 2
      src/Driver/Model.php

+ 1 - 1
composer.json

@@ -19,7 +19,7 @@
     },
     "minimum-stability": "dev",
     "require": {
-        "php": ">=5.4.0",
+        "php": ">=5.5",
         "ext-gd" : ">=2.1.0"
     }
 }

+ 19 - 11
src/Driver/Entity/Base.php

@@ -31,7 +31,9 @@ class Base {
      *
      * @return array
      */
-    public function defaultFieldsValue(){}
+    public function defaultFieldsValue(){
+        return array();
+    }
 
     /**
      * 返回 table 的名字,以便分库分表的时候指定使用
@@ -42,12 +44,14 @@ class Base {
     public function getTable() {
         throw new \Exception('请先设置需要保存的数据表');
     }
+
     /**
      * set hooker for method
      * 目前 where 和 order 及 fields 支持
      * @param $key
      * @param $hooker
-     * @return void
+     * @param $args
+     * @return $this
      */
     protected function setHooker($key, $hooker, $args) {
         $this->hooker[$key]['func'] = $hooker;
@@ -58,7 +62,7 @@ class Base {
     /**
      * 设置where hooker
      * @param object $hooker
-     * @return void
+     * @return $this
      * @throws \Exception
      */
     final public function setWhereHooker($hooker, $args = null) {
@@ -82,7 +86,7 @@ class Base {
     /**
      * 设置order by hooker
      * @param object $hooker
-     * @return void
+     * @return $this
      * @throws \Exception
      */
     final public function setOrderHooker($hooker, $args = null) {
@@ -95,7 +99,7 @@ class Base {
      * 设置 limit hooker
      *
      * @param object $hooker
-     * @return void
+     * @return $this
      * @throws \Exception
      */
     final public function setLimitHooker($hooker, $args = null) {
@@ -119,7 +123,7 @@ class Base {
      *
      * @param callable $hooker
      * @param array| mixed $args
-     * @return void
+     * @return $this
      * @throws \Exception
      */
     final public function setCacheHooker($hooker, $args = null) {
@@ -178,7 +182,7 @@ class Base {
     /**
      * 设置order by hooker
      * @param object $hooker
-     * @return void
+     * @return $this
      * @throws \Exception
      */
     final public function setQueryFieldsHooker($hooker, $args = null) {
@@ -216,7 +220,7 @@ class Base {
     /**
      * 返回使用的db信息
      *
-     * @return mixed
+     * @return \Qii\Driver\Base
      */
     final public function db() {
         return _loadClass('\Qii\Driver\Model');
@@ -386,7 +390,7 @@ class Base {
     /**
      * bind value
      * @param $values
-     * @return $this|false
+     * @return $this
      */
     final public function bindValues($values) {
         if(!is_array($values)) {
@@ -431,7 +435,8 @@ class Base {
     final public function info() {
         try{
             $info = $this->db()->fields($this->getFieldsHooker())->where($this->getWhereHooker())->selectRow($this->getTable());
-            return Response::Success(static::class .'::'. __FUNCTION__,
+            return Response::Success(
+                static::class .'::'. __FUNCTION__,
                 ['_result' => ['code' => Response::DO_SUCCESS, 'msg' => '获取成功', 'body' => $info]]
             );
         }catch (\Exception $e) {
@@ -822,9 +827,12 @@ class Base {
                 if(!in_array($key, $fields)) {
                     continue;
                 }
+
                 $field = $this->entity()->convertToField($key);
+                $value = isset($values[$field]) ? $values[$field] : null;
+                $limit = isset($val[2]) ? $val[2]: '';
 
-                $verify = new Verify($val[0], $values[$field] ?? null, strtolower($valid), $val[1], $val[2] ?? '');
+                $verify = new Verify($val[0], $value, strtolower($valid), $val[1], $limit);
                 $res = $verify->valid();
                 if($res->isError()) {
                     $result[] = $res->getResult() .',获取的是 '. $values[$field];

+ 2 - 2
src/Driver/Model.php

@@ -65,11 +65,11 @@ class Model
      */
     private $model = array();
     /**
-     * @var \Qii\Request\Abstract $_request 请求类
+     * @var \Qii\Request\Http $_request 请求类
      */
     protected $_request;
     /**
-     * @var $_helper helper类
+     * @var \Qii\Autoloader\Helper $_helper helper类
      */
     protected $_helper;