Example #1
0
 /**
  * @return ezcQueryExpression
  */
 protected function createExpression()
 {
     if ($this->db instanceof ezcDbInterface) {
         $expr = $this->db->createExpression($this->db);
     } else {
         $driver = $this->db->getAttribute(PDO::ATTR_DRIVER_NAME);
         $className = 'ezcQueryExpression';
         if ($driver !== 'mysql') {
             $className .= strtoupper(substr($impName, 0, 1)) . substr($impName, 1);
         }
         $expr = new $className($this->db);
     }
     return $expr;
 }
Example #2
0
 /**
  * Constructs a new ezcQuery that works on the database $db and with the aliases $aliases.
  *
  * The aliases can be used to substitute the column and table names with more
  * friendly names. E.g PersistentObject uses it to allow using property and class
  * names instead of column and table names.
  *
  * @param PDO $db
  * @param array(string=>string) $aliases
  */
 public function __construct(PDO $db, array $aliases = array())
 {
     $this->db = $db;
     if ($this->expr == null) {
         $this->expr = $db->createExpression();
     }
     if (!empty($aliases)) {
         $this->aliases = $aliases;
         $this->expr->setAliases($this->aliases);
     }
 }