<?php
// +----------------------------------------------------------------------
// | ThinkPHP [ WE CAN DO IT JUST THINK ]
// +----------------------------------------------------------------------
// | Copyright (c) 2006~2018 http://thinkphp.cn All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: liu21st <liu21st@gmail.com>
// +----------------------------------------------------------------------
namespace think\db;
use PDO;
use think\Collection;
use think\Container;
use think\Db;
use think\db\exception\BindParamException;
use think\db\exception\DataNotFoundException;
use think\db\exception\ModelNotFoundException;
use think\Exception;
use think\exception\DbException;
use think\exception\PDOException;
use think\Loader;
use think\Model;
use think\model\Collection as ModelCollection;
use think\model\Relation;
use think\model\relation\OneToOne;
use think\Paginator;
class Query
{
/**
* 当前数据库连接对象
* @var Connection
*/
protected $connection;
/**
* 当前模型对象
* @var Model
*/
protected $model;
/**
* 当前数据表名称(不含前缀)
* @var string
*/
protected $name = '';
/**
* 当前数据表主键
* @var string|array
*/
protected $pk;
/**
* 当前数据表前缀
* @var string
*/
protected $prefix = '';
/**
* 当前查询参数
* @var array
*/
protected $options = [];
/**
* 当前参数绑定
* @var array
*/
protected $bind = [];
/**
* 事件回调
* @var array
*/
private static $event = [];
/**
* 扩展查询方法
* @var array
*/
private static $extend = [];
/**
* 读取主库的表
* @var array
*/
protected static $readMaster = [];
/**
* 日期查询表达式
* @var array
*/
protected $timeRule = [
'today' => ['today', 'tomorrow'],
'yesterday' => ['yesterday', 'today'],
'week' => ['this week 00:00:00', 'next week 00:00:00'],
'last week' => ['last week 00:00:00', 'this week 00:00:00'],
'month' => ['first Day of this month 00:00:00', 'first Day of next month 00:00:00'],
'last month' => ['first Day of last month 00:00:00', 'first Day of this month 00:00:00'],
'year' => ['this year 1/1', 'next year 1/1'],
'last year' => ['last year 1/1', 'this year 1/1'],
];
/**
* 日期查询快捷定义
* @var array
*/
protected $timeExp = ['d' => 'today', 'w' => 'week', 'm' => 'month', 'y' => 'year'];
/**
* 架构函数
* @access public
*/
public function __construct(Connection $connection = null)
{
if (is_null($connection)) {
$this->connection = Db::connect();
} else {
$this->connection = $connection;
}
$this->prefix = $this->connection->getConfig('prefix');
}
/**
* 创建一个新的查询对象
* @access public
* @return Query
*/
public function newQuery()
{
return new static($this->connection);
}
/**
* 利用__call方法实现一些特殊的Model方法
* @access public
* @param string $method 方法名称
* @param array $args 调用参数
* @return mixed
* @throws DbException
* @throws Exception
*/
public function __call($method, $args)
{
if (isset(self::$extend[strtolower($method)])) {
// 调用扩展查询方法
array_unshift($args, $this);
return Container::getInstance()
->invoke(self::$extend[strtolower($method)], $args);
} elseif (strtolower(substr($method, 0, 5)) == 'getby') {
// 根据某个字段获取记录
$field = Loader::parseName(substr($method, 5));
return $this->where($field, '=', $args[0])->find();
} elseif (strtolower(substr($method, 0, 10)) == 'getfieldby') {
// 根据某个字段获取记录的某个值
$name = Loader::parseName(substr($method, 10));
return $this->where($name, '=', $args[0])->value($args[1]);
} elseif (strtolower(substr($method, 0, 7)) == 'whereor') {
$name = Loader::parseName(substr($method, 7));
array_unshift($args, $name);
return call_user_func_array([$this, 'whereOr'], $args);
} elseif (strtolower(substr($method, 0, 5)) == 'where') {
$name = Loader::parseName(substr($method, 5));
array_unshift($args, $name);
return call_user_func_array([$this, 'where'], $args);
} elseif ($this->model && method_exists($this->model, 'scope' . $method)) {
// 动态调用命名范围
$method = 'scope' . $method;
array_unshift($args, $this);
call_user_func_array([$this->model, $method], $args);
return $this;
} else {
throw new Exception('method not exist:' . ($this->model ? get_class($this->model) : static::class) . '->' . $method);
}
}
/**
* 扩展查询方法
* @access public
* @param string|array $method 查询方法名
* @param callable $callback
* @return void
*/
public static function extend($method, $callback = null)
{
if (is_array($method)) {
foreach ($method as $key => $val) {
self::$extend[strtolower($key)] = $val;
}
} else {
self::$extend[strtolower($method)] = $callback;
}
}
/**
* 设置当前的数据库Connection对象
* @access public
* @param Connection $connection
* @return $this
*/
public function setConnection(Connection $connection)
{
$this->connection = $connection;
$this->prefix = $this->connection->getConfig('prefix');
return $this;
}
/**
* 获取当前的数据库Connection对象
* @access public
* @return Connection
*/
public function getConnection()
{
return $this->connection;
}
/**
* 指定模型
* @access public
* @param Model $model 模型对象实例
* @return $this
*/
public function model(Model $model)
{
$this->model = $model;
return $this;
}
/**
* 获取当前的模型对象
* @access public
* @return Model|null
*/
public function getModel()
{
return $this->model ? $this->model->setQuery($this) : null;
}
/**
* 设置从主库读取数据
* @access public
* @param bool $all 是否所有表有效
* @return $this
*/
public function readMaster($all = false)
{
$table = $all ? '*' : $this->getTable();
static::$readMaster[$table] = true;
return $this;
}
/**
* 指定当前数据表名(不含前缀)
* @access public
* @param string $name
* @return $this
*/
public function name($name)
{
$this->name = $name;
return $this;
}
/**
* 获取当前的数据表名称
* @access public
* @return string
*/
public function getName()
{
return $this->name ?: $this->model->getName();
}
/**
* 得到当前或者指定名称的数据表
* @access public
* @param string $name
* @return string
*/
public function getTable($name = '')
{
if (empty($name) && isset($this->options['table'])) {
return $this->options['table'];
}
$name = $name ?: $this->name;
return $this->prefix . Loader::parseName($name);
}
/**
* �
没有合适的资源?快使用搜索试试~ 我知道了~
个人免签码支付源码+监控APP+免签约支付源码
共1001个文件
php:529个
gif:78个
js:70个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
5星 · 超过95%的资源 3 下载量 173 浏览量
2022-07-12
15:22:17
上传
评论 2
收藏 39.66MB ZIP 举报
温馨提示
个人免签码支付源码+监控APP 免签约支付源码1、宝塔面板中新建网站安装环境需要设置:+ 运行环境为PHP7.0+MYsql5.6+ 网站目录->运行目录 设置为public并保存+ 伪静态 设置为thinkphp并保存+ 默认文档 设置将index.html放在第一行并保存2、打开网站目录 config/database.php ,设置好您的mysql账号密码。3、导入数据库文件。4、至此网站搭建完毕,请访问后自行修改配置信息!默认后台账号和密码均为admin/user //商户后台路劲/admin //后台管理路劲后台账户:admin后台密码:admin上传二维码之后下载APP监控 需要登录微信和支付宝才能监控
资源推荐
资源详情
资源评论
收起资源包目录
个人免签码支付源码+监控APP+免签约支付源码 (1001个子文件)
App.apk 2.69MB
blk-design-system.css 457KB
style.css 142KB
bootstrap.min.css 122KB
material-design-iconic-font.css 88KB
util.css 85KB
layui.css 73KB
material-design-iconic-font.min.css 69KB
loaders.css 56KB
font-awesome.css 37KB
layui.css 31KB
font-awesome.min.css 30KB
main.css 25KB
global.css 24KB
global.css 17KB
layer.css 14KB
layer.css 14KB
layui.mobile.css 10KB
main.css 9KB
laydate.css 8KB
layui.mobile.css 8KB
nucleo-icons.css 8KB
laydate.css 7KB
styles.css 6KB
wechat_pay.css 6KB
pay.css 5KB
pay.css 5KB
pay.css 5KB
wechat_pay.css 4KB
icons-extra.css 3KB
login.css 3KB
stylew.css 2KB
mikufont.css 2KB
normalize.css 2KB
demo.css 2KB
default.css 1KB
code.css 1KB
code.css 1KB
noscript.css 205B
phpunit.xml.dist 1KB
phpunit.xml.dist 893B
phpunit.xml.dist 892B
phpunit.xml.dist 335B
phpunit.xml.dist 335B
phpunit.xml.dist 304B
fontawesome-webfont.eot 162KB
Material-Design-Iconic-Font.eot 162KB
iconfont.eot 46KB
hiddeninput.exe 9KB
59.gif 10KB
22.gif 10KB
24.gif 8KB
13.gif 7KB
16.gif 7KB
39.gif 6KB
64.gif 6KB
63.gif 6KB
50.gif 6KB
loading-0.gif 6KB
loading-0.gif 6KB
4.gif 6KB
1.gif 5KB
42.gif 5KB
71.gif 5KB
21.gif 5KB
20.gif 5KB
29.gif 5KB
70.gif 4KB
5.gif 4KB
17.gif 4KB
27.gif 4KB
9.gif 4KB
44.gif 4KB
11.gif 4KB
8.gif 4KB
3.gif 4KB
23.gif 4KB
34.gif 4KB
41.gif 4KB
38.gif 4KB
65.gif 3KB
32.gif 3KB
45.gif 3KB
7.gif 3KB
12.gif 3KB
26.gif 3KB
60.gif 3KB
2.gif 3KB
40.gif 3KB
25.gif 3KB
19.gif 3KB
66.gif 3KB
18.gif 3KB
46.gif 3KB
10.gif 3KB
28.gif 3KB
51.gif 3KB
57.gif 3KB
67.gif 3KB
0.gif 3KB
共 1001 条
- 1
- 2
- 3
- 4
- 5
- 6
- 11
资源评论
- zhalai2023-05-12资源内容详尽,对我有使用价值,谢谢资源主的分享。
- m0_468256222023-12-26资源使用价值高,内容详实,给了我很多新想法,感谢大佬分享~
- jj_159561190532023-05-26资源使用价值高,内容详实,给了我很多新想法,感谢大佬分享~
智慧浩海
- 粉丝: 1w+
- 资源: 5107
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- yolov5,SSD 可能使用到的一些代码
- 基于c51单片机+DS1302+DHT11温湿度模块+LCD1602显示的万年历硬件原理图+BOM+软件程源码序+仿真图.zip
- NSGA2的MATLAB代码
- Messagepassingtest_GCN_DGL.py
- Sh,Docker 运维好帮手,一招通过 sh 脚本批量快速启动和重启多个Docker 容器
- PCF2123.pdf
- 打开注册表操作.doc
- Windows 常见运行运行库32+64
- WMJUL8iC.html
- 基于3KW光伏并网单相逆变器设计(TMS320F28035控制板+显示板+STM32F103功率板)硬件(原理图+PCB)工程
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功