%PDF- <> %âãÏÓ endobj 2 0 obj <> endobj 3 0 obj <>/ExtGState<>/ProcSet[/PDF/Text/ImageB/ImageC/ImageI] >>/Annots[ 28 0 R 29 0 R] /MediaBox[ 0 0 595.5 842.25] /Contents 4 0 R/Group<>/Tabs/S>> endobj ºaâÚÎΞ-ÌE1ÍØÄ÷{òò2ÿ ÛÖ^ÔÀá TÎ{¦?§®¥kuµùÕ5sLOšuY>endobj 2 0 obj<>endobj 2 0 obj<>endobj 2 0 obj<>endobj 2 0 obj<> endobj 2 0 obj<>endobj 2 0 obj<>es 3 0 R>> endobj 2 0 obj<> ox[ 0.000000 0.000000 609.600000 935.600000]/Fi endobj 3 0 obj<> endobj 7 1 obj<>/ProcSet[/PDF/Text/ImageB/ImageC/ImageI]>>/Subtype/Form>> stream
<?php
namespace Codeception\Lib\Driver;
class Oci extends Db
{
public function setWaitLock($seconds)
{
$this->dbh->exec('ALTER SESSION SET ddl_lock_timeout = ' . (int) $seconds);
}
public function cleanup()
{
$this->dbh->exec(
"BEGIN
FOR i IN (SELECT trigger_name FROM user_triggers)
LOOP
EXECUTE IMMEDIATE('DROP TRIGGER ' || user || '.\"' || i.trigger_name || '\"');
END LOOP;
END;"
);
$this->dbh->exec(
"BEGIN
FOR i IN (SELECT table_name FROM user_tables)
LOOP
EXECUTE IMMEDIATE('DROP TABLE ' || user || '.\"' || i.table_name || '\" CASCADE CONSTRAINTS');
END LOOP;
END;"
);
$this->dbh->exec(
"BEGIN
FOR i IN (SELECT sequence_name FROM user_sequences)
LOOP
EXECUTE IMMEDIATE('DROP SEQUENCE ' || user || '.\"' || i.sequence_name || '\"');
END LOOP;
END;"
);
$this->dbh->exec(
"BEGIN
FOR i IN (SELECT view_name FROM user_views)
LOOP
EXECUTE IMMEDIATE('DROP VIEW ' || user || '.\"' || i.view_name || '\"');
END LOOP;
END;"
);
}
/**
* SQL commands should ends with `//` in the dump file
* IF you want to load triggers too.
* IF you do not want to load triggers you can use the `;` characters
* but in this case you need to change the $delimiter from `//` to `;`
*
* @param $sql
*/
public function load($sql)
{
$query = '';
$delimiter = '//';
$delimiterLength = 2;
foreach ($sql as $sqlLine) {
if (preg_match('/DELIMITER ([\;\$\|\\\\]+)/i', $sqlLine, $match)) {
$delimiter = $match[1];
$delimiterLength = strlen($delimiter);
continue;
}
$parsed = $this->sqlLine($sqlLine);
if ($parsed) {
continue;
}
$query .= "\n" . rtrim($sqlLine);
if (substr($query, -1 * $delimiterLength, $delimiterLength) == $delimiter) {
$this->sqlQuery(substr($query, 0, -1 * $delimiterLength));
$query = "";
}
}
if ($query !== '') {
$this->sqlQuery($query);
}
}
/**
* @param string $tableName
*
* @return array[string]
*/
public function getPrimaryKey($tableName)
{
if (!isset($this->primaryKeys[$tableName])) {
$primaryKey = [];
$query = "SELECT cols.column_name
FROM all_constraints cons, all_cons_columns cols
WHERE cols.table_name = ?
AND cons.constraint_type = 'P'
AND cons.constraint_name = cols.constraint_name
AND cons.owner = cols.owner
ORDER BY cols.table_name, cols.position";
$stmt = $this->executeQuery($query, [$tableName]);
$columns = $stmt->fetchAll(\PDO::FETCH_ASSOC);
foreach ($columns as $column) {
$primaryKey []= $column['COLUMN_NAME'];
}
$this->primaryKeys[$tableName] = $primaryKey;
}
return $this->primaryKeys[$tableName];
}
}