• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
CI 3.0 query builder: Is it possible not to escape string passed to from method?

#1
[eluser]navihtot[/eluser]
Hi,
If I call
Code:
$this->db->from('SELECT CONCAT_WS(" ", lastname, firstname) FROM usr_user')..
. query produced is
Code:
SELECT CONCAT_WS(" ", `lastname`, `firstname)` FROM `usr_user`  ...
so I'm wondering is there any way I could force query builder not to escape when calling from method (just like where method i.e.) ?

This is a simplified example my query is actually much more complex Smile

#2
[eluser]navihtot[/eluser]
I'm now doing it with override of mysqli driver:

Code:
public function from($from, $escape = TRUE)
{
  foreach ((array) $from as $val)
  {
   if (strpos($val, ',') !== FALSE)
   {
    foreach (explode(',', $val) as $v)
    {
     $v = trim($v);
     $this->_track_aliases($v);

    
     if ($escape===TRUE) $this->qb_from[]=$this->protect_identifiers($v, TRUE, NULL, FALSE);
     else $this->qb_from[] = $v;

     if ($this->qb_caching === TRUE)
     {
      $this->qb_cache_from[] = $v;
      $this->qb_cache_exists[] = 'from';
     }
    }
   }
   else
   {
    $val = trim($val);

    // Extract any aliases that might exist. We use this information
    // in the protect_identifiers to know whether to add a table prefix
    $this->_track_aliases($val);
    
    if ($escape===TRUE) $this->qb_from[]=$this->protect_identifiers($val, TRUE, NULL, FALSE);
    else $this->qb_from[] = $val;

    if ($this->qb_caching === TRUE)
    {
     $this->qb_cache_from[] = $val;
     $this->qb_cache_exists[] = 'from';
    }
   }
  }

  return $this;
}

but I would rather do this in some better way, if there is one...

#3
[eluser]navihtot[/eluser]
anybody? Sad


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


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