<?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 -1second'],
'yesterday' => ['yesterday', 'today -1second'],
'week' => ['this week 00:00:00', 'next week 00:00:00 -1second'],
'last week' => ['last week 00:00:00', 'this week 00:00:00 -1second'],
'month' => ['first Day of this month 00:00:00', 'first Day of next month 00:00:00 -1second'],
'last month' => ['first Day of last month 00:00:00', 'first Day of this month 00:00:00 -1second'],
'year' => ['this year 1/1', 'next year 1/1 -1second'],
'last year' => ['last year 1/1', 'this year 1/1 -1second'],
];
/**
* 日期查询快捷定义
* @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()
{
$query = new static($this->connection);
if ($this->model) {
$query->model($this->model);
}
if (isset($this->options['table'])) {
$query->table($this->options['table']);
} else {
$query->name($this->name);
}
if (isset($this->options['json'])) {
$query->json($this->options['json'], $this->options['json_assoc']);
}
if (isset($this->options['field_type'])) {
$query->setJsonFieldType($this->options['field_type']);
}
return $query;
}
/**
* 利用__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;
}
/**
没有合适的资源?快使用搜索试试~ 我知道了~
PHP话费充值通道网站完整运营源码全解密无授权源码下载.zip
共1859个文件
dat:720个
php:564个
png:156个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
0 下载量 183 浏览量
2024-05-21
09:16:34
上传
评论
收藏 20.95MB ZIP 举报
温馨提示
话费充值的PHP网站源码,非常完整,我到手之后修复了充值时金额显示错误的问题,充值对接了Z支付的免签接口。可以设置九折优惠券吸引流量,支持限制每月充值次数,本来是默认限制每月一次的,我把限制取消了,限制的方法备注在里面。文本教程里也非常详细的指出了,短信API对接的是短信宝,就没有改动。这个就不上图了,有用处的自己下载搭建就行,都整理过了。 一.测试环境: 1.linux宝塔面板 2.Nginx 1.18.0 3.MySQL 5.6.50 4.PHP-5.6 //PHP5.6安装拓展 fileinfo 删除所有禁用函数 1.创建站点 1)上传源码并解压 2)设置网站伪静态 /thinkphp 2.创建数据库 1)上传并导入数据库 2)修改数据库信息 /config/database.php 3.访问网站后台 1)后台地址 域名/admin 2)默认后台账号密码 admin www.jocat.cn 4.登陆Z支付商户后台 1)在网站目录/application/index/controller/User.php中 154行和156行配置中填入Z支付商户信息
资源推荐
资源详情
资源评论
收起资源包目录
PHP话费充值通道网站完整运营源码全解密无授权源码下载.zip (1859个子文件)
bootstrap.min.css 118KB
frozenui.css 88KB
new_file.css 71KB
layui.css 71KB
styles.css 34KB
admin.css 21KB
layim.css 15KB
layer.css 14KB
layer.css 14KB
style.css 14KB
layui.mobile.css 10KB
template.css 9KB
layim.css 9KB
laydate.css 7KB
layer.css 5KB
login.css 4KB
login.css 2KB
base.css 2KB
style1.css 1KB
code.css 1KB
treetable.css 294B
treetable.css 294B
mask_177_6.dat 441B
mask_177_6.dat 441B
mask_173_6.dat 429B
mask_173_6.dat 429B
mask_177_7.dat 407B
mask_177_7.dat 407B
frame_40.dat 406B
frame_40.dat 406B
mask_173_7.dat 405B
mask_173_7.dat 405B
frame_39.dat 404B
frame_39.dat 404B
mask_165_6.dat 400B
mask_165_6.dat 400B
mask_161_6.dat 399B
mask_161_6.dat 399B
mask_169_6.dat 391B
mask_169_6.dat 391B
mask_169_7.dat 383B
mask_169_7.dat 383B
frame_37.dat 376B
mask_161_7.dat 376B
frame_37.dat 376B
mask_161_7.dat 376B
mask_165_7.dat 375B
mask_165_7.dat 375B
frame_36.dat 370B
mask_149_6.dat 370B
frame_36.dat 370B
mask_149_6.dat 370B
mask_177_5.dat 369B
mask_177_5.dat 369B
mask_153_6.dat 367B
mask_153_6.dat 367B
mask_173_5.dat 362B
mask_173_5.dat 362B
frame_38.dat 358B
frame_38.dat 358B
mask_141_6.dat 357B
mask_145_6.dat 357B
mask_141_6.dat 357B
mask_145_6.dat 357B
mask_137_6.dat 355B
mask_137_6.dat 355B
mask_149_7.dat 351B
mask_153_7.dat 351B
mask_149_7.dat 351B
mask_153_7.dat 351B
mask_145_7.dat 349B
mask_145_7.dat 349B
frame_33.dat 343B
frame_33.dat 343B
frame_35.dat 342B
frame_35.dat 342B
mask_169_5.dat 336B
mask_169_5.dat 336B
mask_165_5.dat 332B
mask_165_5.dat 332B
frame_34.dat 331B
mask_157_6.dat 331B
mask_137_7.dat 331B
frame_34.dat 331B
mask_157_6.dat 331B
mask_137_7.dat 331B
mask_141_7.dat 330B
mask_141_7.dat 330B
frame_32.dat 329B
frame_32.dat 329B
frame_31.dat 328B
mask_161_5.dat 328B
frame_31.dat 328B
mask_161_5.dat 328B
frame_30.dat 324B
frame_30.dat 324B
frame_28.dat 318B
frame_28.dat 318B
mask_157_7.dat 316B
mask_157_7.dat 316B
共 1859 条
- 1
- 2
- 3
- 4
- 5
- 6
- 19
资源评论
智慧浩海
- 粉丝: 1w+
- 资源: 5197
下载权益
C知道特权
VIP文章
课程特权
开通VIP
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- Delphi 12 控件之unidac-10.2.1-d29pro.exe
- keyword.other.package.java
- Apple//DTD PLIST 1.0//EN
- comment.block.documentation.rust
- there is no way to distinguish perfectly
- 数据库管理工具:dbeaver-ce-24.0.2-x86-64-setup.exe
- Objective-C.tmLanguage
- 数据库管理工具:dbeaver-ce-24.0.2-macos-x86-64.dmg
- Delphi 12 控件之StyleControls 5.77.7z
- 苹果CMSV10红色自适应网站模板
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功