• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Question [DB Query Builder]

#1
Hello guys,

I am a bit confused of some functions from the library DB Query Builder.

I tried to use db->from, db->join in this way:

PHP Code:
$this->db->from('table t');
$this->db->join('table2 t2''condition''left'); 

but when i run the query i saw, that this functions add to the table '`' before and after, and the result is something like:

PHP Code:
FROM `table` `t`
LEFT JOIN `table2` `t2ON condition 

Is totally wrong... How i can use this function to get normal results like: `table` t and `table2` t2, and btw this happens and on the select function when i use: t.`column`, it makes `t`.`column`?

Thanks.
Reply

#2
Code:
$this->db->from('table AS t');
$this->db->join('table2 AS t2', 'condition', 'left');
Reply

#3
(09-07-2015, 11:47 AM)ivantcholakov Wrote:
Code:
$this->db->from('table AS t');
$this->db->join('table2 AS t2', 'condition', 'left');


I tried... Result is the same.
Reply

#4
Maybe the fake 'condition' breaks the query builder. On current 3.0.2-dev code I tested this:

Code:
$this->db->from('table AS t');
$this->db->join('table2 AS t2', 't.id = t2.t_id', 'left');
echo $this->db->get_compiled_select();

And here is the produced SQL:

Code:
SELECT *
FROM `table` AS `t`
LEFT JOIN `table2` AS `t2` ON `t`.`id` = `t2`.`t_id`
Reply

#5
(09-07-2015, 08:49 AM)-V1cu- Wrote:
PHP Code:
FROM `table` `t`
LEFT JOIN `table2` `t2ON condition 

Is totally wrong...

How's escaping the aliases totally wrong?
Reply

#6
(09-08-2015, 01:04 AM)Narf Wrote:
(09-07-2015, 08:49 AM)-V1cu- Wrote:
PHP Code:
FROM `table` `t`
LEFT JOIN `table2` `t2ON condition 

Is totally wrong...

How's escaping the aliases totally wrong?


My bad, i read the documentation and looked on the source library. Solved, thanks!
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.