예제 #1
0
 /**
  * Return a quoted schema name
  *
  * @param string   $schema  The schema name OPTIONAL
  * @return string|null
  */
 protected function getQuotedSchema($schema = null)
 {
     if ($schema === null) {
         return null;
     }
     return $this->quote->quoteIdentifier($schema) . '.';
 }
예제 #2
0
 /**
  * Render GROUP BY section
  *
  * @param Select $select
  * @param string $sql
  * @return string
  */
 public function render(Select $select, $sql = '')
 {
     if ($select->getPart(Select::FROM) && $select->getPart(Select::GROUP)) {
         $group = [];
         foreach ($select->getPart(Select::GROUP) as $term) {
             $group[] = $this->quote->quoteIdentifier($term);
         }
         $sql .= ' ' . Select::SQL_GROUP_BY . ' ' . implode(",\n\t", $group);
     }
     return $sql;
 }
예제 #3
0
 /**
  * Render ORDER BY section
  *
  * @param Select $select
  * @param string $sql
  * @return string
  */
 public function render(Select $select, $sql = '')
 {
     if ($select->getPart(Select::ORDER)) {
         $order = [];
         foreach ($select->getPart(Select::ORDER) as $term) {
             if (is_array($term)) {
                 if (is_numeric($term[0]) && strval(intval($term[0])) == $term[0]) {
                     $order[] = (int) trim($term[0]) . ' ' . $term[1];
                 } else {
                     $order[] = $this->quote->quoteIdentifier($term[0]) . ' ' . $term[1];
                 }
             } elseif (is_numeric($term) && strval(intval($term)) == $term) {
                 $order[] = (int) trim($term);
             } else {
                 $order[] = $this->quote->quoteIdentifier($term);
             }
         }
         $sql .= ' ' . Select::SQL_ORDER_BY . ' ' . implode(', ', $order) . PHP_EOL;
     }
     return $sql;
 }
예제 #4
0
 /**
  * @param string|array $identifier
  * @param string $expectedResult
  * @dataProvider getStringArrayToQuoteDataProvider
  * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  */
 public function testQuoteIdentifier($identifier, $alias, $expectedResult)
 {
     $this->assertEquals($expectedResult, $this->model->quoteIdentifier($identifier));
 }