• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Builder query question From table AS table01, table AS table02

#1
I would like to make a Builder Query base on

PHP Code:
$tQRY "SELECT node.*
         FROM "
.$this->dbTable." AS node,
              "
.$this->dbTable." AS parent
         WHERE node.LFT BETWEEN parent.LFT AND parent.RGT
              AND parent.NAME = '"
.$node."'
         ORDER BY node.LFT"
;
$query $this->db->query($tQRY);
$this->dbLastQuery =  $this->db->getLastQuery(); 

Result of this query :

Code:
SELECT node.*
FROM da_mainmenu AS node, da_mainmenu AS parent
WHERE node.LFT BETWEEN parent.LFT AND parent.RGT AND parent.NAME = 'Elektriciteit'
ORDER BY node.LFT

When is transform it to a full builder
PHP Code:
$builder $this->db->table($this->dbTable);
$builder->resetQuery();
$builder->select('node.*');
$builder->from($this->dbTable .' AS node');
$builder->from($this->dbTable .' AS parent');
$builder->where('node.LFT BETWEEN ''parent.LFT AND parent.RGT');
$builder->where('parent.NAME '$node);
$builder->orderBy('node.LFT');
$query =  $builder->get(); 

with following result
Code:
SELECT node.*
FROM da_mainmenu, da_mainmenu AS node, da_mainmenu AS parent
WHERE node.LFT BETWEEN 'parent.LFT AND parent.RGT' AND parent.NAME = 'Elektriciteit'
ORDER BY node.LFT

I get the first da_mainmenu to much.
So there is problem with

PHP Code:
$builder->from($this->dbTable .' AS node');
$builder->from($this->dbTable .' AS parent'); 

How can i transform the query to builder?
Also I'm not sure how to do the 'WHERE X BETWEEN y  AND Z'
** solved **

Class is included


Attached Files
.php   Nested_sets.php (Size: 3.1 KB / Downloads: 2)
Reply


Messages In This Thread
Builder query question From table AS table01, table AS table02 - by Bart Goossens - 04-12-2020, 10:04 AM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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