php项目实战
来源:互联网 发布:金汇宝软件 编辑:程序博客网 时间:2024/05/20 01:10
1.在数据库字段中,查找某个值,find_in_set.
public function actionSurverylst($pageno)
{try {
//$model = new UserInfo();
$usr = Yii::app()->session["userlogin"] ; //
$pagesize = 15;
$start = ($pageno)*$pagesize;
//Yii::log($usr->compid."----------compid------------------",CLogger::LEVEL_INFO);and endtime>now()
//根据用户所属部门,获取符合规则的调查题号
/*
$ids = SurveryDept::model()->findAll("find_in_set(".$usr->deptid.", scope)");
//判断是否为空
if(!empty($ids))
{
$idString = '';
foreach($ids as $item)
{
$idsArr[] = $item->attributes['surveryid'];
}
$idString = implode(',', $idsArr);
*/
//根据用户所属企业,获取符合规则的调查列表
$data = CompanySurvery::model()->findAll("(find_in_set(".$usr->deptid.", scope) and eid=".$usr->compid.") or (usertype=0 and eid=".$usr->compid.") and endtime>'".date('Y:m:d H:i:s',time())."' order by id desc limit $start,$pagesize");
$result = array();
if(!empty($data)){
foreach($data as $item)
{
$result[] = $item->attributes;
}
echo json_encode($result);
}else{
print_r(0);
}
}
catch (Exception $e)
{
print_r($e);
}
}
2.问题2,json_decode为空,检查原因,双引号,转义成了"。使用 $answer=htmlspecialchars_decode($answer);
public function actionSaveanswer()
{
date_default_timezone_set("UTC");
$answer = $_POST["submitData"];
$resultCount = 0;
if(!empty($answer))
{
$answers = json_decode($answer);
if(is_array($answers))
{
$tran = SurveryHistory::model()->dbConnection->beginTransaction();
try {
foreach ($answers as $his)
{
$hisrec = new SurveryHistory();
$hisrec->answerid = $his->answerid;
$hisrec->asnswer_timer = date('Y-m-d h:i:s');
$hisrec->userid = $his->userid;
$hisrec->questionid = $his->questionid;
$hisrec->surveryid = $his->surveryid;
$hisrec->save();
$sql = "update syberos_electronicsurvery_option set answernum=answernum+1 where id=:id";
$command = Yii::app()->db->createCommand($sql);
$command->bindParam(":id",$his->answerid,PDO::PARAM_INT);
$command->execute();
$resultCount++;
}
$tran->commit();
}
catch (Exception $e)
{
$resultCount =0;
$tran->rollback();
}
}
}
print_r($resultCount);
}
阅读全文
0 0
- php项目实战
- PHP之MVC项目实战
- PHP之MVC项目实战(二)
- PHP之MVC项目实战(三)
- PHP项目实战-微信支付接口
- PHP项目导入Zend Framework的实战经验
- 实战突击:PHP项目开发案例整合(第2版)
- 传智播客PHP项目实战-微信支付接口
- 传智播客PHP项目实战-微信支付接口
- 项目实战
- 实战项目
- 项目实战
- 项目实战
- 项目实战篇-餐馆管理系统—MFC,PHP,MySql:1.项目工具准备篇
- 项目实战--项目介绍
- 【项目实战】Spring MyBatis 实战
- Java Web项目实战,Jsp项目实战
- 超多Java\ASP.NET\PHP\oracle\android\iphone\VC++项目实战视频教程分享
- jQuery设置下拉框select 默认选中option
- jq 今天学到的新技术
- 数学 砍树
- shader总结二
- 日志文件系统的设计与实现
- php项目实战
- qt获取combox内容的知识点
- 用有名管道实现文件复制,有两个终端 ,一个进行复制操作,另一个进行粘贴操作
- 17.9.15leetcode刷题(595)
- css中大div中的块级元素转为内联块产生的问题
- 数据结构——线性表——散列存储结构——哈希表知识点总结 原创 2017年05月14日 10:08:40 散列(hashing)是一种重要的存储方法,也是一种常见的查找方法。 基本思想:以结点的
- Keras的使用方法
- 跨域请求不被允许
- 安卓今日头条的框架的搭建