$keyword = I('get.keyword','','htmlspecialchars');
$Cid = I('get.Cid','','htmlspecialchars');
$contact = D('Contact');
import('ORG.Util.Page'); // 导入分页类
$where['Recycle'] = 0;
$where['Inbox'] = 0;
$where['Uid'] = $_SESSION['ThinkUser']['ID'];
if (is_numeric($keyword)) {
$where['Phone'] = array('LIKE',"%$keyword%");
}else {
$where['ContactName'] = $keyword;
}
if ($Cid!='' && is_numeric($Cid)) {
$where['Cid'] = intval($Cid);
}
$count = $contact->where($where)->count(); //总记录数
$Page = new Page($count,15); //实例化分页类 传入总记录数和每页显示的记录数
$Page->setConfig('header','条记录');
$Page->setConfig('prev','<img src="'.C('TMPL_PARSE_STRING.__IMAGE__').'/prev.gif" border="0" title="上一页" />');
$Page->setConfig('next','<img src="'.C('TMPL_PARSE_STRING.__IMAGE__').'/next.gif" border="0" title="下一页" />');
$Page->setConfig('first','<img src="'.C('TMPL_PARSE_STRING.__IMAGE__').'/first.gif" border="0" title="第一页" />');
$Page->setConfig('last','<img src="'.C('TMPL_PARSE_STRING.__IMAGE__').'/last.gif" border="0" title="最后一页" />');
$show = $Page->show(); //分页显示输出
$dmenu = M('dmenu');
$dlist = $dmenu->order('Sortid asc')->select();
$volist = $contact->relation(true)->where($where)->order('FinalTime desc')->limit($Page->firstRow.','.$Page->listRows)->select();
$html = '';
dump($where);
echo $contact->execute($sql);
dump($volist);执行这个控制器array(4) {
["Recycle"] => int(0)
["Inbox"] => int(0)
["Uid"] => string(1) "1"
["ContactName"] => string(0) ""
}
array(1) {
[0] => array(20) {
["ID"] => string(2) "28"
["Uid"] => string(1) "1"
["Cid"] => string(3) "122"
["ContactName"] => string(21) "阿斯顿阿斯顿是"
["Sex"] => string(3) "男"
["Post"] => string(2) "22"
["Qq"] => string(0) ""
["Skype"] => string(0) ""
["Alww"] => string(0) ""
["Phone"] => string(11) "13019635349"
["Tel"] => string(0) ""
["Fax"] => string(0) ""
["Email"] => string(0) ""
["Birthday"] => string(19) "0000-00-00 00:00:00"
["Content"] => NULL
["Recycle"] => string(1) "0"
["Dtime"] => string(19) "2014-07-23 10:12:24"
["FinalTime"] => string(19) "2014-07-23 10:12:24"
["CompanyName"] => string(15) "阿斯顿撒的"
["Inbox"] => string(1) "1"
}
}他会这样 明明我定义了WHERE Inbox=0这是我模型的设计
protected $_link = array(
'Client' => array(
'mapping_type'=>BELONGS_TO,
'class_name'=>'Client',
'foreign_key'=>'Cid',
'mapping_name'=>'CompanyName',
'mapping_fields'=>'CompanyName,Recycle,Inbox',
'as_fields'=>'CompanyName,Recycle,Inbox'
),
);我已经研究一上午了 谢谢大家了 帮忙解决下! 最佳答案