SELECT a.bulletinId,a.title,a.content,b.userName,a.createTime FROM sp_Bulletin a left outer join sp_user b on a.userid=b.userId
ThinkPHP里面怎么写?
(普通查询然后分页)$list=$Bulletin->limit($p->firstRow.','.$p->listRows)->order('bulletinId asc')->findAll();
得到的是
protected 'queryStr' => string 'SELECT * FROM `sp_bulletin` ORDER BY bulletinId asc LIMIT 30,5 ' (length=63)
有人推荐用realtion做,在自己尝试的写了一个
但是不成功
我发一下我的Model类
BulletinModel.class.php
<?php
class BulletinModel extends Model
{
protected $_validate =array(
array('title','require','标题必须!',1),
array('content','require','内容必须'),
array('title','','标题已经存在',0,'unique',self::MODEL_INSERT),
);
protected $_auto=array(
array('userId','1',self::MODEL_INSERT),
array('createTime','time',1,'function'),
);
}
?>
UserModel.class.php
<?php
class UserModel extends Model{
}
?>求帮助,
ThinkPHP里面怎么写?
(普通查询然后分页)$list=$Bulletin->limit($p->firstRow.','.$p->listRows)->order('bulletinId asc')->findAll();
得到的是
protected 'queryStr' => string 'SELECT * FROM `sp_bulletin` ORDER BY bulletinId asc LIMIT 30,5 ' (length=63)
有人推荐用realtion做,在自己尝试的写了一个
但是不成功
我发一下我的Model类
BulletinModel.class.php
<?php
class BulletinModel extends Model
{
protected $_validate =array(
array('title','require','标题必须!',1),
array('content','require','内容必须'),
array('title','','标题已经存在',0,'unique',self::MODEL_INSERT),
);
protected $_auto=array(
array('userId','1',self::MODEL_INSERT),
array('createTime','time',1,'function'),
);
}
?>
UserModel.class.php
<?php
class UserModel extends Model{
}
?>求帮助,
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货