Biny
Biny copied to clipboard
sql多表连接
大大,想问一下在多表连接时,如果使用sql模板,涉及两个‘:table’时怎么用这两个表的DAO调用select呢?
sql模版在多表中也是一样可以使用的,join后的DAO调用select commond方法时 :table会自动替换为连表后的表名 例如
$this->userDAO->join($this->projectDAO, array('projectId'=>'id'))->select('select * from :table')
最后执行的sql为
select * from user join project on user.projectId = project.id
你可以用 TXEvent::on(onSql); 调试看看