CodeIgniter Forums
How to write query string? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: How to write query string? (/showthread.php?tid=52617)



How to write query string? - El Forum - 06-19-2012

[eluser]Unknown[/eluser]
I have some trouble to query data. The query string is as follow.

$sql = "SELECT ri.routeid, bi.maxseat FROM ytp_routeinfo AS ri
INNER JOIN (ytp_businfo AS bi LEFT JOIN ytp_busline AS bl ON bi.lineid=bl.lineid)
ON ri.busid=bi.busid
WHERE ri.from = ? AND ri.to = ? AND ri.date = ? AND bl.name= ?
ORDER BY ri.time ASC";
$this -> db -> query($sql, array($from, $to, $date, $busline));


I use table prefix. In above query string the table name are unknown because of table prefix miss.

In this query string ("$this -> db -> get('city')") no need to add table prefix. I want to write like this.

Tanks.