How to fix results key from a joined query - 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 fix results key from a joined query (/showthread.php?tid=18952) |
How to fix results key from a joined query - El Forum - 05-23-2009 [eluser]vps4[/eluser] Code: $query = $this->db->query('SELECT a.*, n.node_title FROM article AS a JOIN node AS n ON a.node_ID = n.ID WHERE a.ID = '.(int)$id.' LIMIT 1;'); WHY the result be Code: Array how can I fix it to Code: Array How to fix results key from a joined query - El Forum - 05-24-2009 [eluser]depthcharge[/eluser] use Aliases i.e Code: SELECT a.ID AS ID, n.node_title AS node_title ......... I tend to stay away from using table.* and state the field names where possible, but that's just my preference. How to fix results key from a joined query - El Forum - 05-24-2009 [eluser]vps4[/eluser] [quote author="depthcharge" date="1243167627"]use Aliases i.e Code: SELECT a.ID AS ID, n.node_title AS node_title ......... I tend to stay away from using table.* and state the field names where possible, but that's just my preference.[/quote] thanks for reply. but fanit, the SQL will be too long... any other ways? How to fix results key from a joined query - El Forum - 05-24-2009 [eluser]TheFuzzy0ne[/eluser] Too long for what, exactly? Last time I checked, MySQL supported, by default, it's 1MB, which should be sufficient for most queries. How to fix results key from a joined query - El Forum - 05-24-2009 [eluser]Dam1an[/eluser] And even if it gets to be that long (unlikely) and you're concerned about it not being readable, break it up accross multiple lines and add some structure to it |