开源 企业版 高校版 私有云 模力方舟 AI 队友
代码拉取完成,页面将自动刷新
捐赠
捐赠前请先登录
扫描微信二维码支付
取消
支付完成
支付提示
将跳转至支付宝完成支付
确定
取消
1 Star 3 Fork 1

南漂一卒/WeChat_Web_Demo

加入 Gitee
与超过 1400万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
已有帐号? 立即登录
文件
master
分支 (1)
master
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
项目仓库所选许可证以仓库主分支所使用许可证为准
master
分支 (1)
master
克隆/下载
克隆/下载
提示
下载代码请复制以下命令到终端执行
为确保你提交的代码身份被 Gitee 正确识别,请执行以下命令完成配置
初次使用 SSH 协议进行代码克隆、推送等操作时,需按下述提示完成 SSH 配置
1 生成 RSA 密钥
2 获取 RSA 公钥内容,并配置到 SSH公钥
在 Gitee 上使用 SVN,请访问 使用指南
使用 HTTPS 协议时,命令行会出现如下账号密码验证步骤。基于安全考虑,Gitee 建议 配置并使用私人令牌 替代登录密码进行克隆、推送等操作
Username for 'https://gitee.com': userName
Password for 'https://userName@gitee.com': # 私人令牌
master
分支 (1)
master
WeChat_Web_Demo
/
php
/
EasyLibs.php
WeChat_Web_Demo
/
php
/
EasyLibs.php
EasyLibs.php 5.13 KB
一键复制 编辑 原始数据 按行查看 历史
南漂一卒 提交于 2016年11月14日 01:42 +08:00 . 【同步】更新 Web 前后端开源基础库
<?php
//
// >>> EasyLibs.php <<<
//
//
// [Version] v2.8 (2016年11月13日) Stable
//
// [Require] PHP v5.3.6+
//
// [Usage] A Light-weight PHP Class Library
// without PHP Extensions.
//
//
// (C)2015-2016 shiy2008@gmail.com
//
// ---------------------------------------------
//
// Object Attribute Access Controller v0.1
//
// ---------------------------------------------
abstract class EasyAccess {
protected $data = array();
private static function getName($_Key, $_Mode = 0) {
return ($_Mode ? 'set' : 'get') .
strtoupper( $_Key[0] ) . substr($_Key, 1);
}
public function __get($_Key) {
return isset( $this->data[$_Key] ) ? $this->data[$_Key] : (
$this->data[$_Key] = $this->{ self::getName($_Key) }()
);
}
public function __set($_Key, $_Value) {
$_Name = self::getName($_Key, 1);
if (method_exists($this, $_Name))
$this->$_Name( $this->data[$_Key] = $_Value );
}
}
// ------------------------------
//
// Class Auto Loader v0.1
//
// ------------------------------
spl_autoload_register(function ($_ClassName) {
$_Path = array_reduce(
array(
'/^(FS)_/', '/(SQL)/', '/^(HTTP)/', '/^(HTML)/'
),
function ($_Prev, $_Item) use ($_ClassName) {
return ((! $_Prev) && preg_match($_Item, $_ClassName, $_Path)) ?
$_Path[1] : $_Prev;
}
);
if ($_Path)
require_once(join(DIRECTORY_SEPARATOR, array(
__DIR__, 'EasyLibs', $_Path, "$_ClassName.php"
)));
}, true, true);
// ----------------------------------------
//
// Data Model Abstract Class v0.3
//
// ----------------------------------------
abstract class DataModel extends EasyAccess {
protected $dataBase;
protected $dataTable;
protected $requestData;
public function __construct(SQLDB $_SQLDB, array $_Request_Data = array()) {
$this->dataBase = $_SQLDB;
$this->dataTable = $_SQLDB->{$this->name};
$this->requestData = $_Request_Data;
}
protected function checkError() {
$_Error = $this->dataBase->errorInfo();
if ($_Error[0] != '00000') throw new Exception($_Error[2], $_Error[0]);
}
abstract protected function getFields();
abstract protected function getOrderBy();
abstract protected function getLimit();
public function search(array $_Condition = array()) {
$_Args = array_filter( $this->fields );
$_Condition = join(' and ', array_merge($_Condition, array_map(
function ($_Value, $_Key) {
return "$_Key like '%$_Value%'";
},
array_values( $_Args ),
array_keys( $_Args )
)));
$_Statement = array(
'select' => 'count(*)',
'from' => $this->name
);
if ( $_Condition ) $_Statement['where'] = $_Condition;
$_Result = $this->dataBase->query( $_Statement );
$this->checkError();
$_Result = array('total' => intval( $_Result[0]['count(*)'] ));
$_Statement['select'] = '*';
$_Statement['order by'] = $this->orderBy;
$_Statement['limit'] = $this->limit;
$_Result['rows'] = $this->dataBase->query( $_Statement );
$this->checkError();
return $_Result;
}
public function getItemBy($_Name) {
$_Item = $this->dataBase->query(array(
'select' => '*',
'from' => $this->name,
'where' => "$_Name = '{$this->fields[$_Name]}'"
));
$this->checkError();
return $_Item[0];
}
public function write($_ID_Name = '') {
if ($_ID_Name && $this->getItemBy( $_ID_Name ))
$this->dataTable->update(
"$_ID_Name = '{$this->fields[$_ID_Name]}'", $this->fields
);
else
$this->dataTable->insert( $this->fields );
$this->checkError();
return $this->dataBase->lastInsertId();
}
public function remove($_ID_Name = '', array $_Condition = array()) {
if (! $_ID_Name) return;
$_Result = $this->dataTable->delete(
join(' and ', array_merge($_Condition, array(
"$_ID_Name = '{$this->fields[$_ID_Name]}'"
)))
);
$this->checkError();
return $_Result;
}
public function countBy($_ID_Name) {
$_Result = $this->dataBase->query(array(
'select' => "$_ID_Name, count(*)",
'from' => $this->name,
'group by' => $_ID_Name
));
return array_combine(
array_map(function ($_Item) use ($_ID_Name) {
return $_Item[$_ID_Name];
}, $_Result),
array_map(function ($_Item) {
return $_Item['count(*)'];
}, $_Result)
);
}
}
spl_autoload_register(function ($_ClassName) {
$_Path = join(DIRECTORY_SEPARATOR, array(
__DIR__, 'DataModel', "$_ClassName.php"
));
if (file_exists( $_Path )) require_once( $_Path );
}, true, true);
Loading...
举报
举报成功
我们将于2个工作日内通过站内信反馈结果给你!
请认真填写举报原因,尽可能描述详细。
请选择举报类型
取消
发送
误判申诉

此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。

如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。

取消
提交

简介

微信公众平台 Web 项目框架(微信 JS-SDK、WeUI、PHP 5.3)
取消

发行版

暂无发行版

贡献者

全部

近期动态

不能加载更多了
编辑仓库简介
简介内容
主页
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
JavaScript
1
https://gitee.com/Tech_Query/WeChat_Web_Demo.git
git@gitee.com:Tech_Query/WeChat_Web_Demo.git
Tech_Query
WeChat_Web_Demo
WeChat_Web_Demo
master
点此查找更多帮助

搜索帮助

评论
仓库举报
回到顶部
登录提示
该操作需登录 Gitee 帐号,请先登录后再操作。
立即登录
没有帐号,去注册

AltStyle によって変換されたページ (->オリジナル) /