From 7d025ba2cbe3672a934d3be1f90c218ca2e7567d Mon Sep 17 00:00:00 2001 From: thinkphp Date: Mon, 28 Dec 2015 12:22:38 +0800 Subject: [PATCH] =?UTF-8?q?hook=E7=B1=BB=E7=9A=84add=E6=96=B9=E6=B3=95?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0first=E5=8F=82=E6=95=B0=20=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E6=8A=8A=E6=9F=90=E4=B8=AA=E8=A1=8C=E4=B8=BA=E6=94=BE=E5=88=B0?= =?UTF-8?q?=E9=92=A9=E5=AD=90=E7=9A=84=E5=BC=80=E5=A4=B4=E9=A6=96=E5=85=88?= =?UTF-8?q?=E6=89=A7=E8=A1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- library/think/db/driver.php | 2 +- library/think/hook.php | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/library/think/db/driver.php b/library/think/db/driver.php index 66d71ff1..0d12cb95 100644 --- a/library/think/db/driver.php +++ b/library/think/db/driver.php @@ -41,7 +41,6 @@ abstract class Driver protected $_linkID = null; // 数据库连接参数配置 protected $config = [ - 'db_like_fields' => '', //like字段自动替换为%%包裹 'type' => '', // 数据库类型 'hostname' => '127.0.0.1', // 服务器地址 'database' => '', // 数据库名 @@ -57,6 +56,7 @@ abstract class Driver 'rw_separate' => false, // 数据库读写是否分离 主从式有效 'master_num' => 1, // 读写分离后 主服务器数量 'slave_no' => '', // 指定从服务器序号 + 'db_like_fields' => '', //like字段自动替换为%%包裹 ]; // 数据库表达式 protected $exp = ['eq' => '=', 'neq' => '<>', 'gt' => '>', 'egt' => '>=', 'lt' => '<', 'elt' => '<=', 'notlike' => 'NOT LIKE', 'like' => 'LIKE', 'in' => 'IN', 'notin' => 'NOT IN', 'not in' => 'NOT IN', 'between' => 'BETWEEN', 'not between' => 'NOT BETWEEN', 'notbetween' => 'NOT BETWEEN']; diff --git a/library/think/hook.php b/library/think/hook.php index dc7bc54a..b7e691aa 100644 --- a/library/think/hook.php +++ b/library/think/hook.php @@ -20,15 +20,18 @@ class Hook * 动态添加行为扩展到某个标签 * @param string $tag 标签名称 * @param mixed $behavior 行为名称 + * @param bool $first 是否放到开头执行 * @return void */ - public static function add($tag, $behavior) + public static function add($tag, $behavior,$first=false) { if (!isset(self::$tags[$tag])) { self::$tags[$tag] = []; } if (is_array($behavior)) { self::$tags[$tag] = array_merge(self::$tags[$tag], $behavior); + } elseif($first){ + array_unshift(self::$tags[$tag],$behavior); } else { self::$tags[$tag][] = $behavior; }