예제 #1
0
파일: Where.php 프로젝트: bradley-holt/zf2
 /**
  * Get SQL string for statement
  * 
  * @param  null|PlatformInterface $platform If null, defaults to Sql92
  * @return string
  */
 public function getSqlString(PlatformInterface $platform = null)
 {
     $platform = $platform ?: new Sql92();
     $parts = parent::getWhereParts();
     $wherePart = '';
     foreach ($parts as $part) {
         if (is_string($part)) {
             $wherePart .= $part;
         } elseif (is_array($part)) {
             $values = $part[1];
             $types = isset($part[2]) ? $part[2] : array();
             foreach ($values as $index => $value) {
                 if (isset($types[$index]) && $types[$index] == self::TYPE_IDENTIFIER) {
                     $values[$index] = $platform->quoteIdentifierInFragment($value);
                 } elseif (isset($types[$index]) && $types[$index] == self::TYPE_VALUE) {
                     $values[$index] = $platform->quoteValue($value);
                 }
             }
             $wherePart .= vsprintf($part[0], $values);
         }
     }
     return sprintf($this->specification, $wherePart);
 }