Biny icon indicating copy to clipboard operation
Biny copied to clipboard

sql多表连接

Open wallance1130 opened this issue 6 years ago • 1 comments

大大,想问一下在多表连接时,如果使用sql模板,涉及两个‘:table’时怎么用这两个表的DAO调用select呢?

wallance1130 avatar Aug 31 '18 10:08 wallance1130

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); 调试看看

billge1205 avatar Aug 31 '18 11:08 billge1205