MyPic v2.0 完全注释~源码~
时间:2009-03-05
来源:互联网
安装目录 /install.php 安装
后台用户密码: admin/admin
本版本仅供测试,请勿泄露到源码站或者其它地方,谢谢!
功能列表什么的就不列了~
单入口MVC模式~
放在这里的是全注释测试版本,错误难免~
接受批评,建议,指点!
2.0演示: http://www.diqiye.com/mp/
1.32演示: http://www.diqiye.com/mypic
[ 本帖最后由 wbsifan 于 2009-3-5 15:15 编辑 ]

MyPic v2.0 Beta.rar (635.58 KB)
作者: 小鱼哥哥 发布时间: 2009-03-05
protected $db;
protected $_options = array();
protected $_table = array();
protected $_data = array();
protected $validate = array();
protected $mp;
public function __construct()
{
}
public function initModel()
{
$this -> db = getConn();
dump($this->db);
$this -> mp = &$GLOBALS['_MP'];
}
public function getvo()
{
return $this -> _data;
}
public function __set($name, $value)
{
$this -> _data[$name] = $value;
}
public function __get($name)
{
if (isset($this -> _data[$name])) {
return $this -> _data[$name];
} elseif (property_exists($this, $name)) {
return $this -> $name;
} else {
return null;
}
}
public function find()
{
$sql = $this -> parse_select();
$arr = $this -> db -> getone($sql);
return $arr;
}
public function findAll()
{
$sql = $this -> parse_select();
$arr = $this -> db -> getall($sql);
return $arr;
}
public function result($num = 0)
{
$sql = $this -> parse_select();
$arr = $this -> db -> result($sql, $num);
return $arr;
}
public function save($data = null)
{
$table = $this -> parse_table();
$where = $this -> parse_where();
if (!empty($where)) {
return $this -> db -> update($table, $data, $where);
} else {
return $this -> db -> insert($table, $data);
}
}
public function del()
{
$table = $this -> parse_table();
$where = $this -> parse_where();
if (!$where) {
throwError(L('error.nowhere'));
}
return $this -> db -> delete($table, $where);
}
public function parse_select()
{
if (!empty($this -> _options['sql'])) {
$sql = $this -> _options['sql'];
unset($this -> _options['sql']);
} else {
$field = '*';
if (!empty($this -> _options['field'])) {
if (is_array($this -> _options['field'])) {
$field = implode(',', $this -> db -> deal_field($this -> _options['field']));
} else {
$field = $this -> _options['field'];
}
unset($this -> _options['field']);
}
$table = $this -> parse_table();
$where = $this -> parse_where();
!empty($where) && $where = ' WHERE ' . $where;
$order = '';
if (!empty($this -> _options['order'])) {
$order = ' ORDER BY ' . $this -> _options['order'];
unset($this -> _options['order']);
}
$limit = '';
if (!empty($this -> _options['limit'])) {
$limit = ' LIMIT ' . $this -> _options['limit'];
unset($this -> _options['limit']);
}
$sql = "SELECT {$field} FROM {$table}{$where}{$order}{$limit}";
}
return $this -> deal_table($sql);
}
protected function parse_where()
{
$where = '';
if (!empty($this -> _options['where'])) {
if (is_array($this -> _options['where'])) {
$where = $this -> db -> deal_where($this -> _options['where']);
} else {
$where = $this -> _options['where'];
}
unset($this -> _options['where']);
}
return $where;
}
protected function parse_table()
{
$table = $this -> _table[1];
if (!empty($this -> _options['table'])) {
if (is_numeric($this -> _options['table'])) {
$table = $this -> _table[$this -> _options['table']];
} else {
$table = $this -> _options['table'];
}
unset($this -> _options['table']);
}
return $table;
}
protected function deal_table($sql)
{
return preg_replace_callback('/#(\d+)/', array(__CLASS__, 'deal_table_callback'), $sql);
}
protected function deal_table_callback($tab)
{
return $this -> _table[$tab[1]];
}
public function sql($sql)
{
$this -> _options['sql'] = $sql;
return $this;
}
public function where($where)
{
$this -> _options['where'] = $where;
return $this;
}
public function order($order)
{
$this -> _options['order'] = $order;
return $this;
}
public function table($table)
{
$this -> _options['table'] = $table;
return $this;
}
public function field($field)
{
$this -> _options['field'] = $field;
return $this;
}
public function limit($limit)
{
$this -> _options['limit'] = $limit;
return $this;
}
} [/php]
[ 本帖最后由 kakashilw 于 2009-3-5 13:08 编辑 ]
作者: kakashilw 发布时间: 2009-03-05
作者: blankyao 发布时间: 2009-03-05
作者: E蜗牛 发布时间: 2009-03-05
作者: abcnic1 发布时间: 2009-03-05
作者: TankMe 发布时间: 2009-03-05
作者: wanchun0222 发布时间: 2009-03-05
作者: liexusong 发布时间: 2009-03-05
作者: zwws 发布时间: 2009-03-05
作者: dontlie 发布时间: 2009-03-05
作者: jinxikun001 发布时间: 2009-03-06
作者: szrq 发布时间: 2009-03-06
作者: yoofeng 发布时间: 2009-03-06
我收藏了:lol:
作者: 啊丢 发布时间: 2009-03-09
作者: 哈出出 发布时间: 2009-03-12
作者: aszx0413 发布时间: 2010-08-02
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28