public function testOrderByIgnoreCase() { $originalDB = Propel::getServiceContainer()->getAdapter(); Propel::getServiceContainer()->setAdapter(Propel::getServiceContainer()->getDefaultDatasource(), new MysqlAdapter()); $criteria = new Criteria(); $criteria->setIgnoreCase(true); $criteria->addAscendingOrderByColumn(BookPeer::TITLE); BookPeer::addSelectColumns($criteria); $params = array(); $sql = BasePeer::createSelectSql($criteria, $params); $expectedSQL = 'SELECT book.ID, book.TITLE, book.ISBN, book.PRICE, book.PUBLISHER_ID, book.AUTHOR_ID, UPPER(book.TITLE) FROM `book` ORDER BY UPPER(book.TITLE) ASC'; $this->assertEquals($expectedSQL, $sql); Propel::getServiceContainer()->setAdapter(Propel::getServiceContainer()->getDefaultDatasource(), $originalDB); }
public function testBigIntIgnoreCaseOrderBy() { BookstorePeer::doDeleteAll(); // Some sample data $b = new Bookstore(); $b->setStoreName("SortTest1")->setPopulationServed(2000)->save(); $b = new Bookstore(); $b->setStoreName("SortTest2")->setPopulationServed(201)->save(); $b = new Bookstore(); $b->setStoreName("SortTest3")->setPopulationServed(302)->save(); $b = new Bookstore(); $b->setStoreName("SortTest4")->setPopulationServed(10000000)->save(); $c = new Criteria(); $c->setIgnoreCase(true); $c->add(BookstorePeer::STORE_NAME, 'SortTest%', Criteria::LIKE); $c->addAscendingOrderByColumn(BookstorePeer::POPULATION_SERVED); $rows = BookstorePeer::doSelect($c); $this->assertEquals('SortTest2', $rows[0]->getStoreName()); $this->assertEquals('SortTest3', $rows[1]->getStoreName()); $this->assertEquals('SortTest1', $rows[2]->getStoreName()); $this->assertEquals('SortTest4', $rows[3]->getStoreName()); }