Esempio n. 1
0
 /**
  * @link       http://propel.phpdb.org/trac/ticket/425
  */
 public function testMultipleFunctionInCriteria()
 {
     $db = Propel::getServiceContainer()->getAdapter(BookPeer::DATABASE_NAME);
     try {
         $c = new Criteria();
         $c->setDistinct();
         if ($db instanceof PgsqlAdapter) {
             $c->addSelectColumn("substring(" . BookPeer::TITLE . " from position('Potter' in " . BookPeer::TITLE . ")) AS col");
         } else {
             $this->markTestSkipped('Configured database vendor is not PostgreSQL');
         }
         $stmt = BookPeer::doSelectStmt($c);
     } catch (PropelException $x) {
         $this->fail("Paring of nested functions failed: " . $x->getMessage());
     }
 }
Esempio n. 2
0
 /**
  * @link       http://propel.phpdb.org/trac/ticket/425
  */
 public function testMultipleFunctionInCriteria()
 {
     $db = Propel::getDB(BookPeer::DATABASE_NAME);
     try {
         $c = new Criteria();
         $c->setDistinct();
         if ($db instanceof DBPostgres) {
             $c->addSelectColumn("substring(" . BookPeer::TITLE . " from position('Potter' in " . BookPeer::TITLE . ")) AS col");
         } else {
             $this->markTestSkipped();
         }
         $stmt = BookPeer::doSelectStmt($c);
     } catch (PropelException $x) {
         $this->fail("Paring of nested functions failed: " . $x->getMessage());
     }
 }
Esempio n. 3
0
 public function testAddSelectModifier()
 {
     $c = new Criteria();
     $c->setDistinct();
     $c->addSelectModifier('SQL_CALC_FOUND_ROWS');
     $this->assertEquals(array(Criteria::DISTINCT, 'SQL_CALC_FOUND_ROWS'), $c->getSelectModifiers(), 'addSelectModifier() adds a select modifier to the Criteria');
     $c->addSelectModifier('SQL_CALC_FOUND_ROWS');
     $this->assertEquals(array(Criteria::DISTINCT, 'SQL_CALC_FOUND_ROWS'), $c->getSelectModifiers(), 'addSelectModifier() adds a select modifier only once');
     $params = array();
     $result = BasePeer::createSelectSql($c, $params);
     $this->assertEquals('SELECT DISTINCT SQL_CALC_FOUND_ROWS  FROM ', $result, 'addSelectModifier() adds a modifier to the final query');
 }
Esempio n. 4
0
 public function testMergeWithSelectModifiers()
 {
     $c1 = new Criteria();
     $c1->setDistinct();
     $c2 = new Criteria();
     $c1->mergeWith($c2);
     $this->assertEquals(array(Criteria::DISTINCT), $c1->getSelectModifiers(), 'mergeWith() does not remove an existing select modifier');
     $c1 = new Criteria();
     $c2 = new Criteria();
     $c2->setDistinct();
     $c1->mergeWith($c2);
     $this->assertEquals(array(Criteria::DISTINCT), $c1->getSelectModifiers(), 'mergeWith() merges the select modifiers');
     $c1 = new Criteria();
     $c1->setDistinct();
     $c2 = new Criteria();
     $c2->setDistinct();
     $c1->mergeWith($c2);
     $this->assertEquals(array(Criteria::DISTINCT), $c1->getSelectModifiers(), 'mergeWith() does not duplicate select modifiers');
     $c1 = new Criteria();
     $c1->setAll();
     $c2 = new Criteria();
     $c2->setDistinct();
     $c1->mergeWith($c2);
     $this->assertEquals(array(Criteria::ALL), $c1->getSelectModifiers(), 'mergeWith() does not merge the select modifiers in case of conflict');
 }
Esempio n. 5
0
 public function testCreateSelectSqlPartSelectModifier()
 {
     $db = Propel::getDB(BookPeer::DATABASE_NAME);
     $c = new Criteria();
     $c->addSelectColumn(BookPeer::ID);
     $c->addAsColumn('book_ID', BookPeer::ID);
     $c->setDistinct();
     $fromClause = array();
     $selectSql = $db->createSelectSqlPart($c, $fromClause);
     $this->assertEquals('SELECT DISTINCT book.ID, book.ID AS book_ID', $selectSql, 'createSelectSqlPart() includes the select modifiers in the SELECT clause');
     $this->assertEquals(array('book'), $fromClause, 'createSelectSqlPart() adds the tables from the select columns to the from clause');
 }