DB_dsql::bt PHP Méthode

bt() public méthode

Adds backtics around argument. This will allow you to use reserved SQL words as table or field names such as "table".
public bt ( mixed $s ) : string
$s mixed Any string or array of strings
Résultat string Quoted string
    public function bt($s)
    {
        if (is_array($s)) {
            $out = array();
            foreach ($s as $ss) {
                $out[] = $this->bt($ss);
            }
            return $out;
        }
        if (!$this->bt || is_object($s) || $s === '*' || strpos($s, '.') !== false || strpos($s, '(') !== false || strpos($s, $this->bt) !== false) {
            return $s;
        }
        return $this->bt . $s . $this->bt;
    }

Usage Example

Exemple #1
0
 /** Initializes base query for this model.
  * @link http://agiletoolkit.org/doc/modeltable/dsql */
 public function initQuery()
 {
     if (!$this->table) {
         throw $this->exception('$table property must be defined');
     }
     $this->dsql = $this->db->dsql();
     $this->dsql->debug($this->debug);
     $this->dsql->table($this->table, $this->table_alias);
     $this->dsql->default_field = $this->dsql->expr('*,' . $this->dsql->bt($this->table_alias ?: $this->table) . '.' . $this->dsql->bt($this->id_field));
     $this->dsql->id_field = $this->id_field;
     return $this;
 }