Esempio n. 1
0
 /**
  * Quotes a database value
  * @param string $value value to quote
  * @return string quoted value
  * @throws zibo\library\database\exception\DatabaseException when $value is not a scalar value
  */
 public function quoteValue($value)
 {
     parent::quoteValue($value);
     if (is_bool($value)) {
         return $value ? 1 : 0;
     }
     $valueLength = strlen($value);
     if (is_numeric($value)) {
         return $value;
     }
     if (is_null($value) || $value === self::VALUE_NULL) {
         return self::VALUE_NULL;
     }
     if (!$this->isConnected()) {
         $this->connect();
     }
     $quotedValue = $this->connection->escapeString($value);
     if ($quotedValue === false) {
         throw new DatabaseException('Could not quote ' . $value);
     }
     return self::QUOTE_VALUE . $quotedValue . self::QUOTE_VALUE;
 }
Esempio n. 2
0
 /**
  * Quotes a database identifier
  * @param string $identifier
  * @return string quoted identifier
  * @throws zibo\library\database\exception\DatabaseException when $identifier is not a scalar value or when $identifier is empty
  */
 public function quoteIdentifier($identifier)
 {
     parent::quoteIdentifier($identifier);
     $identifier = str_replace(self::QUOTE_IDENTIFIER, self::QUOTE_IDENTIFIER . self::QUOTE_IDENTIFIER, $identifier);
     return self::QUOTE_IDENTIFIER . $identifier . self::QUOTE_IDENTIFIER;
 }