Example #1
0
 /**
  * Sets the aliases $aliases for this object.
  *
  * The aliases should be in the form array( "aliasName" => "databaseName" )
  * Each alias defines a relation between a user-defined name and a name
  * in the database. This is supported for table names as column names.
  *
  * The aliases can be used to substitute the column and table names with more
  * friendly names. The substitution is done when the query is built, not using
  * AS statements in the database itself.
  *
  * Example of a select query with aliases:
  * <code>
  * <?php
  * $q->setAliases( array( 'Identifier' => 'id', 'Company' => 'company' ) );
  * $q->select( 'Company' )
  *   ->from( 'table' )
  *   ->where( $q->expr->eq( 'Identifier', 5 ) );
  * echo $q->getQuery();
  * ?>
  * </code>
  *
  * This example will output SQL similar to:
  * <code>
  * SELECT company FROM table WHERE id = 5
  * </code>
  *
  * Aliasses also take effect for composite names in the form
  * tablename.columnname as the following example shows:
  * <code>
  * <?php
  * $q->setAliases( array( 'Order' => 'orders', 'Recipient' => 'company' ) );
  * $q->select( 'Order.Recipient' )
  *   ->from( 'Order' );
  * echo $q->getQuery();
  * ?>
  * </code>
  *
  * This example will output SQL similar to:
  * <code>
  * SELECT orders.company FROM orders;
  * </code>
  *
  * It is even possible to have an alias point to a table name/column name
  * combination. This will only work for alias names without a . (dot):
  * <code>
  * <?php
  * $q->setAliases( array( 'Order' => 'orders', 'Recipient' => 'orders.company' ) );
  * $q->select( 'Recipient' )
  *   ->from( 'Order' );
  * echo $q->getQuery();
  * ?>
  * </code>
  *
  * This example will output SQL similar to:
  * <code>
  * SELECT orders.company FROM orders;
  * </code>
  *
  * In the following example, the Recipient alias will not be used, as it is
  * points to a fully qualified name - the Order alias however is used:
  * <code>
  * <?php
  * $q->setAliases( array( 'Order' => 'orders', 'Recipient' => 'orders.company' ) );
  * $q->select( 'Order.Recipient' )
  *   ->from( 'Order' );
  * echo $q->getQuery();
  * ?>
  * </code>
  *
  * This example will output SQL similar to:
  * <code>
  * SELECT orders.Recipient FROM orders;
  * </code>
  *
  * @param array(string=>string) $aliases
  * @return void
  */
 public function setAliases(array $aliases)
 {
     $this->aliases = $aliases;
     $this->expr->setAliases($aliases);
 }
 /**
  * Constructs an empty ezcQueryExpression
  *
  * @param PDO $db
  */
 public function __construct(PDO $db)
 {
     parent::__construct($db);
 }
 /**
  * Constructs an pgsql expression object using the db $db.
  *
  * @param PDO $db
  */
 public function __construct(PDO $db)
 {
     parent::__construct($db);
     $version = $db->getAttribute(PDO::ATTR_SERVER_VERSION);
     $this->version = substr($version, 0, 1);
 }