- 浏览: 1742497 次
- 性别:
- 来自: 北京
文章分类
- 全部博客 (641)
- vb2005xu自己动手系列 (174)
- vb2005xu开发文章转摘 (47)
- vb2005xu发发牢骚 (99)
- vb2005xu新技术灌水 (12)
- vb2005xu网络资源集锦 (21)
- vb2005xu软件学习 (60)
- 英语学习 (3)
- JavaScript 学习 (54)
- JAVA OOP 巩固 之 CustomDatabase 的开发 (5)
- 2013年9月之前所在公司 记事 (7)
- FleaPHP/QEEPHP 资料 (87)
- JAVA MAIL 学习篇 (4)
- Python turbogears (5)
- Rails 个人开发四部曲 (3)
- 名人传 (8)
- iwp framework (5)
- 高考零分作文 (5)
- startos (8)
- lua (0)
- 职场 (1)
最新评论
-
hellotieye:
自己 评论 自己 挺嗨呀
Mysql sql查询时 if 的用法 -
igevin:
转载请标明出处,转自Gevin的博客http://blog.i ...
RESTful API 编写指南 -
Theobob:
...
实现简单的ACL -
vb2005xu:
比如 对于 curl 调用就不再需要 加各种if 判断了,
$ ...
搞一个简单的数据打印工具AsDebug の Laravel -
vb2005xu:
http://geekplux.com/wiki/
YII2 模块内自定义错误页
crud 以及sql如下: 感觉 自己写的coreapp-mini 其实还是蛮好用的...
-- 分类 -- 表的结构 `tiny_forum_category` DROP TABLE IF EXISTS `tiny_forum_category`; CREATE TABLE IF NOT EXISTS `tiny_forum_category` ( `id` int(10) unsigned NOT NULL auto_increment, `name` varchar(64) NOT NULL , `logo` varchar(64) NOT NULL , `uid` int(10) unsigned NOT NULL, `created_at` int(10) unsigned NOT NULL default 1, `updated_at` int(10) unsigned NOT NULL default 0, PRIMARY KEY (`id`) )DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -- 表的结构 `tiny_forum_category_info` DROP TABLE IF EXISTS `tiny_forum_category_info`; CREATE TABLE IF NOT EXISTS `tiny_forum_category_info` ( `id` int(10) unsigned NOT NULL auto_increment, `cat_id` int(10) unsigned NOT NULL, `num_post` int(8) unsigned NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `cat_id` (`cat_id`) )DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -- 主题 -- 表的结构 `tiny_forum_post` DROP TABLE IF EXISTS `tiny_forum_post`; CREATE TABLE IF NOT EXISTS `tiny_forum_post` ( `id` int(10) unsigned NOT NULL auto_increment, `title` varchar(64) NOT NULL , `cat_id` int(10) unsigned NOT NULL, `uid` int(10) unsigned NOT NULL, `created_at` int(10) unsigned NOT NULL default 1, `updated_at` int(10) unsigned NOT NULL default 0, PRIMARY KEY (`id`) )DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -- 表的结构 `tiny_forum_post_content` DROP TABLE IF EXISTS `tiny_forum_post_content`; CREATE TABLE IF NOT EXISTS `tiny_forum_post_content` ( `id` int(10) unsigned NOT NULL auto_increment, `post_id` int(10) unsigned NOT NULL, `content` text collate utf8_unicode_ci, PRIMARY KEY (`id`), UNIQUE KEY `post_id` (`post_id`) )DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -- 表的结构 `tiny_forum_post_info` DROP TABLE IF EXISTS `tiny_forum_post_info`; CREATE TABLE IF NOT EXISTS `tiny_forum_post_info` ( `id` int(10) unsigned NOT NULL auto_increment, `post_id` int(10) unsigned NOT NULL, `num_comment` int(6) unsigned NOT NULL, PRIMARY KEY (`id`), UNIQUE KEY `post_id` (`post_id`) )DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; -- 评论 -- 表的结构 `tiny_forum_post_comment` DROP TABLE IF EXISTS `tiny_forum_post_comment`; CREATE TABLE IF NOT EXISTS `tiny_forum_post_comment` ( `id` int(10) unsigned NOT NULL auto_increment, `post_id` int(10) unsigned NOT NULL, `content` text collate utf8_unicode_ci, `uid` int(10) unsigned NOT NULL, `created_at` int(10) unsigned NOT NULL default 1, PRIMARY KEY (`id`) )DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; ---- 添加索引 ALTER TABLE `tiny_forum_category` ADD INDEX `inx_tiny_fc_uid` (`uid`); ALTER TABLE `tiny_forum_post` ADD INDEX `inx_tiny_fp_cat_id` (`cat_id`); ALTER TABLE `tiny_forum_post` ADD INDEX `inx_tiny_fp_uid` (`uid`); ALTER TABLE `tiny_forum_post_comment` ADD INDEX `inx_tiny_fpc_uid` (`uid`); ALTER TABLE `tiny_forum_post_comment` ADD INDEX `inx_tiny_fpc_post_id` (`post_id`);
<?php // a tiny forum for more users final class tiny_forum { /** * 所有用户标识 */ const ALL_USER = -301; } // ---- 表关系模型 ----- 开始 -------------- /** * * tiny_forum_category[ * :id,:name,:logo,:uid,:create_at,:update_at * ] * * tiny_forum_category_info[ * :id,:cat_id,:num_post * ] */ class tiny_forum_category { public $tbCategory = 'tiny_forum_category'; public $tbCategoryInfo = 'tiny_forum_category_info'; private function __construct(){} /** * @return tiny_forum_category */ static function getInstance(){ static $inst = false; if (!$inst) $inst = new self(); return $inst; } function find($cat_id){ $catfields = CoreDbSqlHelper::qfields('id,name,logo,uid','c'); $cifields = CoreDbSqlHelper::qfields('num_post','ci'); $cond = array('c.id'=>(int) $cat_id); $sqlCond = CoreDbSqlHelper::parseConditions(CoreApp::$defaultDBO,$cond); if ($sqlCond) $sqlCond = "WHERE {$sqlCond}"; $sql = "SELECT {$catfields},{$cifields} FROM {$this->tbCategory} AS c LEFT JOIN {$this->tbCategoryInfo} AS ci ON ci.cat_id=c.id {$sqlCond} " . CoreDbSqlHelper::getLimitSql(1); return CoreApp::$defaultDBO->getRow($sql); } function find_all($limit=null,& $counter=null){ return $this->find_all_by_user(tiny_forum::ALL_USER,$limit,$counter); } function destroy_all(){ return $this->destroy_all_by_user(tiny_forum::ALL_USER); } function create(array $row){ $rt = assertAssocArray($row,array( 'name' => array( array('not_empty', false), ), 'uid' => array( array('not_null', false), array('is_int', false), ), )); if ($rt){ $row['create_at'] = CURRENT_TIMESTAMP; return SingleTableCRUD::insert($this->tbCategory,$row); } return false; } function update(array $row){ $rt = assertAssocArray($row,array( 'id' => array( array('not_null', false), array('is_int', false), ), 'name' => array( array('not_empty', false), ) )); if ($rt){ $row['update_at'] = CURRENT_TIMESTAMP; return SingleTableCRUD::update($this->tbCategory,$row,'id'); } return false; } function destroy($cat_id){ $cat_id = (int) $cat_id; $rt = SingleTableCRUD::delete($this->tbCategory,array('id'=>$cat_id)); if ($rt){ SingleTableCRUD::delete($this->tbCategoryInfo,array('cat_id'=>$cat_id)); } return $rt; } function destroy_all_by_user($user_id){ $user_id = (int) $user_id; $cond = ($user_id === tiny_forum::ALL_USER) ? null : array('uid'=>$user_id); $rt = SingleTableCRUD::delete($this->tbCategory,$cond); if ($rt){ SingleTableCRUD::delete($this->tbCategoryInfo,$cond); } return $rt; } function find_all_by_user($user_id, $limit=null,& $counter=null){ $catfields = CoreDbSqlHelper::qfields('id,name,logo,uid','c'); $cifields = CoreDbSqlHelper::qfields('num_post','ci'); if ($user_id === tiny_forum::ALL_USER){ $sqlCond = ''; }else { $cond = array('c.uid'=>(int) $user_id); $sqlCond = CoreDbSqlHelper::parseConditions(CoreApp::$defaultDBO,$cond); if ($sqlCond) $sqlCond = "WHERE {$sqlCond}"; } $counter = $counter ? 'SQL_CALC_FOUND_ROWS' : '' ; $sql = "SELECT {$counter} {$catfields},{$cifields} FROM {$this->tbCategory} AS c LEFT JOIN {$this->tbCategoryInfo} AS ci ON ci.cat_id=c.id {$sqlCond} " . CoreDbSqlHelper::getLimitSql($limit); $rows = CoreApp::$defaultDBO->getAll($sql); if ($counter) $counter = CoreApp::$defaultDBO->getOne('SELECT FOUND_ROWS()') ; return $rows; } function incr_postnum($cat_id,$incr = 1){ return SingleTableCRUD::incrField($this->tbCategoryInfo,array('cat_id'=>$cat_id),'num_post',$incr); } } /** * * tiny_forum_post[ * :id,:title,:cat_id,:uid,:create_at,:update_at * ] * * tiny_forum_post_content[ * :id,:post_id,:content * ] * * tiny_forum_post_info[ * :id,:post_id,:num_comment * ] */ class tiny_forum_post { public $tbPost = 'tiny_forum_post'; public $tbPostContent = 'tiny_forum_post_content'; public $tbPostInfo = 'tiny_forum_post_info'; private function __construct(){} /** * @return tiny_forum_post */ static function getInstance(){ static $inst = false; if (!$inst) $inst = new self(); return $inst; } function find($post_id){ $pfields = CoreDbSqlHelper::qfields('*','p'); $pcfields = CoreDbSqlHelper::qfields('content','pc'); $pifields = CoreDbSqlHelper::qfields('num_comment','pi'); $cond = array('p.id'=>(int) $post_id); $sqlCond = CoreDbSqlHelper::parseConditions(CoreApp::$defaultDBO,$cond); if ($sqlCond) $sqlCond = "WHERE {$sqlCond}"; $counter = $counter ? 'SQL_CALC_FOUND_ROWS' : '' ; $sql = "SELECT {$counter} {$catfields},{$cifields} FROM {$this->tbPost} AS p LEFT JOIN {$this->tbPostContent} AS pc ON pc.post_id=p.id LEFT JOIN {$this->tbPostInfo} AS pi ON pi.post_id=p.id {$sqlCond} " . CoreDbSqlHelper::getLimitSql(1); return CoreApp::$defaultDBO->getRow($sql); } function find_all_by_user($user_id, $limit=null,& $counter=null){ $pfields = CoreDbSqlHelper::qfields('*','p'); $pifields = CoreDbSqlHelper::qfields('num_comment','pi'); if ($user_id === tiny_forum::ALL_USER){ $sqlCond = ''; }else { $cond = array('p.uid'=>(int) $user_id); $sqlCond = CoreDbSqlHelper::parseConditions(CoreApp::$defaultDBO,$cond); if ($sqlCond) $sqlCond = "WHERE {$sqlCond}"; } $sqlCond = CoreDbSqlHelper::parseConditions(CoreApp::$defaultDBO,$cond); if ($sqlCond) $sqlCond = "WHERE {$sqlCond}"; $sql = "SELECT {$catfields},{$cifields} FROM {$this->tbPost} AS p LEFT JOIN {$this->tbPostInfo} AS pi ON pi.post_id=p.id {$sqlCond} " . CoreDbSqlHelper::getLimitSql($limit); $rows = CoreApp::$defaultDBO->getAll($sql); if ($counter) $counter = CoreApp::$defaultDBO->getOne('SELECT FOUND_ROWS()') ; return $rows; } function find_all_by_category($cat_id, $limit=null,& $counter=null){ $pfields = CoreDbSqlHelper::qfields('*','p'); $pifields = CoreDbSqlHelper::qfields('num_comment','pi'); $cond = array('p.cat_id'=>(int) $cat_id); $sqlCond = CoreDbSqlHelper::parseConditions(CoreApp::$defaultDBO,$cond); if ($sqlCond) $sqlCond = "WHERE {$sqlCond}"; $sql = "SELECT {$catfields},{$cifields} FROM {$this->tbPost} AS p LEFT JOIN {$this->tbPostInfo} AS pi ON pi.post_id=p.id {$sqlCond} " . CoreDbSqlHelper::getLimitSql($limit); $rows = CoreApp::$defaultDBO->getAll($sql); if ($counter) $counter = CoreApp::$defaultDBO->getOne('SELECT FOUND_ROWS()') ; return $rows; } function destroy($post_id){ $post_id = (int) $post_id; $cat_id = SingleTableCRUD::find($this->tbPost,array('id'=>$post_id),'cat_id'); if (!$cat_id) return false; $rt = SingleTableCRUD::delete($this->tbPost,array('id'=>$post_id)); if ($rt){ tiny_forum_category::getInstance()->incr_postnum($cat_id,-1); tiny_forum_post_comment::getInstance()->destroy_all_by_post($post_id); SingleTableCRUD::delete($this->tbPostInfo,array('post_id'=>$post_id)); SingleTableCRUD::delete($this->tbPostContent,array('post_id'=>$post_id)); } return $rt; } function destroy_all($post_ids){ $post_ids = normalize($post_ids); if (empty($post_ids)) return false; $affectRows = 0; foreach ($post_ids as $post_id){ if ($this->destroy($post_id)){ $affectRows ++; } } return $affectRows; } function destroy_all_by_user($user_id){ $counter = false; $cond = ($user_id === tiny_forum::ALL_USER) ? null : array('uid'=>$user_id); $post_ids = SingleTableCRUD::findAll($this->tbPost,$cond,null,null,$counter,'id'); if (empty($post_ids)) return false; return $this->destroy_all($post_ids); } function create(array $row){ $rt = assertAssocArray($row,array( 'title' => array( array('not_empty', false), ), 'uid' => array( array('not_null', false), array('is_int', false), ), 'cat_id' => array( array('not_null', false), array('is_int', false), ), )); if ($rt){ $row['create_at'] = CURRENT_TIMESTAMP; $post_id = SingleTableCRUD::insert($this->tbPost,$row); if ($post_id){ tiny_forum_category::getInstance()->incr_postnum($row['cat_id'],1); } } return false; } function update(array $row){ $rt = assertAssocArray($row,array( 'id' => array( array('not_null', false), array('is_int', false), ), 'title' => array( array('not_empty', false), ) )); if ($rt){ $row['update_at'] = CURRENT_TIMESTAMP; if (SingleTableCRUD::update($this->tbPost,$row,'id')){ if (isset($row['content'])){ return SingleTableCRUD::update($this->tbPostContent,array('content' => $row['content']),'post_id'); } return true; } } return false; } function incr_commentnum($post_id,$incr = 1){ return SingleTableCRUD::incrField($this->tbPostInfo,array('post_id'=>$post_id),'num_comment',$incr); } } /** * * tiny_forum_post_comment[ * :id,:post_id,:content,:uid,:create_at * ] */ class tiny_forum_post_comment { public $tbPostComment = 'tiny_forum_post_comment'; private function __construct(){} /** * @return tiny_forum_post_comment */ static function getInstance(){ static $inst = false; if (!$inst) $inst = new self(); return $inst; } function find_all_by_post($post_id, $limit=null,& $counter=null){ return SingleTableCRUD::findAll($this->tbPostComment, array('post_id'=>(int)$post_id),'create_at',$limit,$counter ); } function find_all_by_user($user_id, $limit=null,& $counter=null){ return SingleTableCRUD::findAll($this->tbPostComment, array('uid'=>(int)$user_id),'create_at',$limit,$counter ); } function destroy($comment_id){ $cond = array('id'=>$comment_id); $post_id = SingleTableCRUD::find($this->tbPostComment,$cond,'post_id'); if (!$post_id) return false; $rt = SingleTableCRUD::delete($this->tbPostComment,$cond); if ($rt){ tiny_forum_post::getInstance()->incr_commentnum($post_id,-1); } return $rt; } function destroy_all($comment_ids){ $comment_ids = normalize($comment_ids); if (empty($comment_ids)) return false; $affectRows = 0; foreach ($comment_ids as $comment_id){ if ($this->destroy($comment_id)){ $affectRows ++; } } return $affectRows; } function destroy_all_by_post($post_id){ $cond = array('post_id'=>$post_id); $rt = SingleTableCRUD::delete($this->tbPostComment,$cond); if ($rt){ SingleTableCRUD::update( tiny_forum_post::getInstance()->tbPostInfo, array('post_id'=>$post_id,'num_comment'=>0) ,'post_id'); } return $rt; } function destroy_all_by_user($user_id){ $counter = false; $cond = ($user_id === tiny_forum::ALL_USER) ? null : array('uid'=>$user_id); $post_ids = SingleTableCRUD::findAll($this->tbPostComment,$cond,null,null,$counter,'post_id'); if (empty($post_ids)) return false; $affectRows = 0; foreach ($post_ids as $post_id){ if ($this->destroy_all_by_post($post_id)){ $affectRows ++; } } return $affectRows; } function create(array $row){ $rt = assertAssocArray($row,array( 'content' => array( array('not_empty', false), ), 'uid' => array( array('not_null', false), array('is_int', false), ), 'post_id' => array( array('not_null', false), array('is_int', false), ), )); if ($rt){ $row['create_at'] = CURRENT_TIMESTAMP; $comment_id = SingleTableCRUD::insert($this->tbPostComment,$row); if ($comment_id){ tiny_forum_post::getInstance()->incr_commentnum($row['post_id'],1); } } return false; } } // ---- 表关系模型 ----- 结束 -------------- // ---- 控制器/Action ----- 开始 -------------- // ---- 控制器/Action ----- 结束 --------------
发表评论
-
前端截取url成图片
2017-11-09 18:16 1484有些小需求需要将 url 转成图片, 直接使用 ... -
excel-to-csv-inbrowser
2016-08-15 19:20 2829# excel-to-csv-inbrowser exce ... -
ws-http 最简单轻量的PHP CURL工具库
2016-07-29 20:44 2549欢迎大家拍砖 https://github.com/to ... -
常用的 js 代码梳理
2016-06-16 12:00 1851/** * 格式化时间函数 * @param {form ... -
Facade 包装类 -- 解决视图里面长长的命名空间调用问题
2016-04-20 10:48 1650有时候模版里面定义 ... -
搞一个简单的数据打印工具AsDebug の Laravel
2016-01-20 19:47 2914很多时候我们都要纠结于代码开发过程中的数据 dump 工作 ... -
ken\trade
2015-12-18 20:45 1499<?php namespace ken\tra ... -
我承认我手贱: 升级 xcode
2015-11-14 21:11 1817升级 xcode 之后, 在终端运行 git clone 出现 ... -
YII2 模块内自定义错误页
2015-11-07 12:17 5424当前YII框架中把错误异常配置都放置在 web.php 中, ... -
PHP单例模式面试注意事项
2015-10-20 09:57 1898最近面了不少PHP从业者,有实习生也有5/6年以上的开发者 ... -
NGINX 配置 SSL 证书 搭建 HTTPS 网站
2015-10-19 19:19 2858下面是详细的配置过程: 1、在服务器上使用 Open ... -
关于php cron任务管理的实现假想
2015-10-17 21:25 1823之前每开发一个计划任务功能均需要在线上操作crontab来新 ... -
fineuploader 跨子域上传文件 cookie丢失问题的解决
2015-10-14 13:30 4740目前的项目中,使用到了fineuploader 这个纯htm ... -
CentOS 6安全加固及性能优化
2015-07-27 14:54 4219CentOS 6安全加固及性能优化 我们可以通过调整 ... -
常见票据辨别真伪的方法
2015-04-28 09:07 16811、真伪鉴别图示和步 ... -
梳理面试中遇到的HTTP协议相关的问题和知识
2015-04-16 13:45 3878本文会是一个比较长的,持续更新的过程 当你在浏览器地 ... -
面试中遇到的期权问题
2015-04-13 14:33 2680最近在面试一直遇到 ... -
遭遇windows上PHP 不能打开GBK编码文件名的问题
2015-03-09 11:21 3081我在 目录下建了一个文件名为 謀定三國-i8ujlw.js ... -
遭遇jsonp同域下变作post请求的坑
2015-01-28 21:39 4699今天迁移一个站点时遇到一个坑爹问题,同一个jsonp接口在 ... -
nginx 400 错误请求分析
2015-01-27 15:01 3244在服务器上传文件过程中 nginx经常会出现 400 的错误 ...
相关推荐
tiny_mce_wiris原因分析: 1. tiny_mec是富文本编辑器,但原生不支持公式插件 2. wiris是公式插件能支持各种富文本编辑器,但他是半开源的,要使用他的插件 ,必须依赖于wiris云端服务器,意思是如果项目没有网络则...
swin unet预训练权重swin_tiny_patch4_window7_224.pth
LDD3 tiny_tty模块源码(基于linux 2.6.32内核)
tiny_cnn C++( Github上是已经更新的tiny_dnn,这个是以前版本tiny_cnn)
编译原理 Tiny C语法的实现 本人的课程设计
## 运行步骤 1. 运行voc_annotation.py,生成根目录...而之前测试的yolov4模型调用GPU每帧0.17s,tiny_yolov4速度上比起yolov4足足快了5倍,但的确在VOC2007数据集上的检测精度不及,轮廓精度和分类类别精度均有欠缺。
所以DPI会很高,但同时业务员需要在一些聊天软件发一些正常DPI的小图广告,但是手头上又没有PS这样的图片编辑软件,这时你就需要一款快速更改DPI的小工具就是这款tiny_ppi_editor,非常的实用。
包含官方提供的yolov3-tiny.weights和yolov3-tiny.cfg文件,通过datknet2caffe转换得到的yolov3-tiny.caffemodel和yolov3-tiny.prototxt文件,通过RuyiStudio转换得到的inst_yolov3-tiny_inst_YVU420sp.wk文件,亲测...
tiny_usb_officetiny_usb_officetiny_usb_office
论文最新,想学习的小伙伴可以看看哦,一起学习一起分享
在推荐系统中进行CTR预估代码测试所需要的数据集,里面包含了很多用户信息,而且规模适中,可以用来测试你所写的CTR模型的大致性能如何。
Django的富文本框中tiny_mce需要的js文件
tiny_li_code
Rtx51_tiny_RTOS中文版.pdfRtx51_tiny_RTOS中文版.pdfRtx51_tiny_RTOS中文版.pdf
tiny_yolov3权重keras_h5,经过试验证实可用,修改model相关路径即可
1.全简体中文界面,使用更友好. 2.修改了部分页面大小,使其空白面积减少,更加美观. 3.修改图片功能,增加自定义图片上传功能(php)...4.浏览器支持测试通过:windows下chrome,firefox,Opera,safari,ie6,ie8.linux下firefox.
tiny_li_code_dbbrowser
rtx-tiny源码
自然环境下极小众多的人脸人头检测,用于多目标远近人脸检测和车站、公共场所数人头。以包含训练好的模型文件。
由 yolov3_tiny.weights生成的tiny_yolo_weights.h5 ,适用与keras-yolov3 版本