Doctrine\DBAL\Platforms\OraclePlatform::assertValidIdentifier PHP Method

assertValidIdentifier() public static method

Assertion for Oracle identifiers.
public static assertValidIdentifier ( string $identifier )
$identifier string
    public static function assertValidIdentifier($identifier)
    {
        if (!preg_match('(^(([a-zA-Z]{1}[a-zA-Z0-9_$#]{0,})|("[^"]+"))$)', $identifier)) {
            throw new DBALException("Invalid Oracle identifier");
        }
    }

Usage Example

 /**
  * {@inheritdoc}
  */
 public function lastInsertId($name = null)
 {
     if ($name === null) {
         return false;
     }
     OraclePlatform::assertValidIdentifier($name);
     $sql = 'SELECT ' . $name . '.CURRVAL FROM DUAL';
     $stmt = $this->query($sql);
     $result = $stmt->fetch(\PDO::FETCH_ASSOC);
     if ($result === false || !isset($result['CURRVAL'])) {
         throw new OCI8Exception("lastInsertId failed: Query was executed but no result was returned.");
     }
     return (int) $result['CURRVAL'];
 }
OraclePlatform