Tencent / Biny

Biny is a tiny, high-performance PHP framework for web applications
BSD 3-Clause "New" or "Revised" License
1.69k stars 259 forks source link

sql多表连接 #76

Open wallance1130 opened 6 years ago

wallance1130 commented 6 years ago

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

billge1205 commented 6 years ago

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