sqlserver 视图模型 排序报错 无法绑定由多个部分组成的标识符
2017-08-11 10:59
501 查看
如题:连接sql 2005数据库,使用视图模型
<?php
namespace Index\Model;
use Think\Model\ViewModel;
class CommentaViewModel extends ViewModel{
public $viewFields=array(
'comment'=>array('gid','comment','pic','time'=>'cctime','status'=>'cstatus','_as'=>'aa'),
'guest'=>array('avatar','username','_as'=>'bb','_on'=>'aa.gid=bb.id'),
);
}
?>
复制代码
代码中使用order排序就会报错,不使用排序则正常,
$comment=$Model->where($where)->limit($limit)->order('cctime')->select();
复制代码
------报错:ERR: SQLSTATE[42000]: [Microsoft][SQL Server Native Client 10.0][SQL Server]无法绑定由多个部分组成的标识符 "aa.time"。
$comment=$Model->where($where)->limit($limit)->select();
复制代码
----正常
研究这个问题研究很久了。最终找到解决办法。把->order('cctime')
这个改成:->order('thinkphp.cctime') 问题解决。
我的语句是这样的:$order=D('OrderView');
$orderinfo=$order->field('cusid')->order('thinkphp.cusid desc')->where($map)->limit($firstrow,$listRows)->select();
只是不知道什么原理,有懂的大神请解释下
<?php
namespace Index\Model;
use Think\Model\ViewModel;
class CommentaViewModel extends ViewModel{
public $viewFields=array(
'comment'=>array('gid','comment','pic','time'=>'cctime','status'=>'cstatus','_as'=>'aa'),
'guest'=>array('avatar','username','_as'=>'bb','_on'=>'aa.gid=bb.id'),
);
}
?>
复制代码
代码中使用order排序就会报错,不使用排序则正常,
$comment=$Model->where($where)->limit($limit)->order('cctime')->select();
复制代码
------报错:ERR: SQLSTATE[42000]: [Microsoft][SQL Server Native Client 10.0][SQL Server]无法绑定由多个部分组成的标识符 "aa.time"。
$comment=$Model->where($where)->limit($limit)->select();
复制代码
----正常
研究这个问题研究很久了。最终找到解决办法。把->order('cctime')
这个改成:->order('thinkphp.cctime') 问题解决。
我的语句是这样的:$order=D('OrderView');
$orderinfo=$order->field('cusid')->order('thinkphp.cusid desc')->where($map)->limit($firstrow,$listRows)->select();
只是不知道什么原理,有懂的大神请解释下
相关文章推荐
- 无法绑定由多个部分组成的标识符--解决办法
- 跨数据库查询导致的 无法绑定由多个部分组成的标识符 问题的解决办法
- SQL_无法绑定由多个部分组成的标识符
- [SQL]无法绑定由多个部分组成的标识符
- 无法绑定由多个部分组成的标识符
- 消息 4104,级别 16,状态 1,第 1 行 无法绑定由多个部分组成的标识符 "f.新增日期"。
- “无法绑定由多个部分组成的标识符 “解决方案
- slq 无法绑定由多个部分组成的标识符...
- 无法绑定由多个部分组成的标识符 "yvi312082007@163.com"。
- 无法绑定由多个部分组成的标识符
- 无法绑定由多个部分组成的标识符“System.Data.DataRowView”
- 无法绑定由多个部分组成的标识符“System.Data.DataRowView” 遇到问题转帖
- MS SQL 错误:无法绑定由多个部分组成的标识符 "xxxxx"
- 关于在MS sqlserver中无法绑定由多个部分组成的标识符问题
- SQL错误:无法绑定由多个部分组成的标识符“******”
- 无法绑定由多个部分组成的标识符的解决方法
- sql服务器无法绑定由多个部分组成的标识符 "inserted.MotorNum"
- 无法对视图创建索引,因为该视图未绑定到架构 SQLServer
- 小结:无法绑定由多个部分组成的标…
- 无法绑定由多个部分组成的标示符