HOR-829
HOR-829 HOR-829 HOR-829
This commit is contained in:
@@ -425,7 +425,7 @@ class DataBaseMaintenance
|
|||||||
if (empty( $aTables ))
|
if (empty( $aTables ))
|
||||||
return false;
|
return false;
|
||||||
printf( "%-70s", "LOCK TABLES" );
|
printf( "%-70s", "LOCK TABLES" );
|
||||||
if (@mysql_query( "LOCK TABLES " . implode( " READ, ", $aTables ) . " READ; " )) {
|
if (@mysql_query( 'LOCK TABLES ' . implode( ' READ, ', $aTables ) . ' READ; ' )) {
|
||||||
echo " [OK]\n";
|
echo " [OK]\n";
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
@@ -455,7 +455,7 @@ class DataBaseMaintenance
|
|||||||
{
|
{
|
||||||
|
|
||||||
$bytesSaved = 0;
|
$bytesSaved = 0;
|
||||||
$result = @mysql_query( "SELECT * FROM `$table`" );
|
$result = @mysql_query( 'SELECT * FROM `'.$table.'`' );
|
||||||
|
|
||||||
$num_rows = mysql_num_rows( $result );
|
$num_rows = mysql_num_rows( $result );
|
||||||
$num_fields = mysql_num_fields( $result );
|
$num_fields = mysql_num_fields( $result );
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ class PgSQLTableInfo extends TableInfo {
|
|||||||
WHERE att.attrelid = %d AND att.attnum > 0
|
WHERE att.attrelid = %d AND att.attnum > 0
|
||||||
AND att.attisdropped IS FALSE
|
AND att.attisdropped IS FALSE
|
||||||
ORDER BY att.attnum";
|
ORDER BY att.attnum";
|
||||||
$result = pg_query ($this->conn->getResource(), sprintf ($filter->preventSqlInjection($query), $this->oid));
|
$result = $this->executePgQuery($this->conn->getResource(), sprintf ($filter->preventSqlInjection($query), $this->oid));
|
||||||
|
|
||||||
if (!$result) {
|
if (!$result) {
|
||||||
throw new SQLException("Could not list fields for table: " . $this->name, pg_last_error($this->conn->getResource()));
|
throw new SQLException("Could not list fields for table: " . $this->name, pg_last_error($this->conn->getResource()));
|
||||||
@@ -224,7 +224,7 @@ class PgSQLTableInfo extends TableInfo {
|
|||||||
require_once($pathTrunk.'gulliver/system/class.inputfilter.php');
|
require_once($pathTrunk.'gulliver/system/class.inputfilter.php');
|
||||||
$filter = new InputFilter();
|
$filter = new InputFilter();
|
||||||
$strDomain = $filter->validateInput($strDomain);
|
$strDomain = $filter->validateInput($strDomain);
|
||||||
$query = "SELECT
|
$query = "SELECT
|
||||||
d.typname as domname,
|
d.typname as domname,
|
||||||
b.typname as basetype,
|
b.typname as basetype,
|
||||||
d.typlen,
|
d.typlen,
|
||||||
@@ -237,7 +237,7 @@ class PgSQLTableInfo extends TableInfo {
|
|||||||
d.typtype = 'd'
|
d.typtype = 'd'
|
||||||
AND d.typname = '%s'
|
AND d.typname = '%s'
|
||||||
ORDER BY d.typname";
|
ORDER BY d.typname";
|
||||||
$result = pg_query ($this->conn->getResource(), sprintf ($filter->preventSqlInjection($query), $strDomain));
|
$result = $this->executePgQuery($this->conn->getResource(), sprintf ($filter->preventSqlInjection($query), $strDomain));
|
||||||
|
|
||||||
if (!$result) {
|
if (!$result) {
|
||||||
throw new SQLException("Query for domain [" . $strDomain . "] failed.", pg_last_error($this->conn->getResource()));
|
throw new SQLException("Query for domain [" . $strDomain . "] failed.", pg_last_error($this->conn->getResource()));
|
||||||
@@ -295,7 +295,7 @@ class PgSQLTableInfo extends TableInfo {
|
|||||||
AND a2.attnum = ct.conkey[1]
|
AND a2.attnum = ct.conkey[1]
|
||||||
AND a1.attnum = ct.confkey[1]
|
AND a1.attnum = ct.confkey[1]
|
||||||
ORDER BY conname";
|
ORDER BY conname";
|
||||||
$result = pg_query ($this->conn->getResource(), sprintf ($filter->preventSqlInjection($query), $this->oid));
|
$result = $this->executePgQuery($this->conn->getResource(), sprintf ($filter->preventSqlInjection($query), $this->oid));
|
||||||
if (!$result) {
|
if (!$result) {
|
||||||
throw new SQLException("Could not list foreign keys for table: " . $this->name, pg_last_error($this->conn->getResource()));
|
throw new SQLException("Could not list foreign keys for table: " . $this->name, pg_last_error($this->conn->getResource()));
|
||||||
}
|
}
|
||||||
@@ -381,7 +381,7 @@ class PgSQLTableInfo extends TableInfo {
|
|||||||
JOIN pg_class cls ON cls.oid=indexrelid
|
JOIN pg_class cls ON cls.oid=indexrelid
|
||||||
WHERE indrelid = %d AND NOT indisprimary
|
WHERE indrelid = %d AND NOT indisprimary
|
||||||
ORDER BY cls.relname";
|
ORDER BY cls.relname";
|
||||||
$result = pg_query ($this->conn->getResource(), sprintf ($filter->preventSqlInjection($query), $this->oid));
|
$result = $this->executePgQuery($this->conn->getResource(), sprintf ($filter->preventSqlInjection($query), $this->oid));
|
||||||
|
|
||||||
|
|
||||||
if (!$result) {
|
if (!$result) {
|
||||||
@@ -413,7 +413,7 @@ class PgSQLTableInfo extends TableInfo {
|
|||||||
FROM pg_catalog.pg_class c JOIN pg_catalog.pg_attribute a ON a.attrelid = c.oid
|
FROM pg_catalog.pg_class c JOIN pg_catalog.pg_attribute a ON a.attrelid = c.oid
|
||||||
WHERE c.oid = '%s' AND a.attnum = %d AND NOT a.attisdropped
|
WHERE c.oid = '%s' AND a.attnum = %d AND NOT a.attisdropped
|
||||||
ORDER BY a.attnum";
|
ORDER BY a.attnum";
|
||||||
$result2 = pg_query ($this->conn->getResource(), sprintf ($filter->preventSqlInjection($query), $this->oid, $intColNum));
|
$result2 = $this->executePgQuery($this->conn->getResource(), sprintf ($filter->preventSqlInjection($query), $this->oid, $intColNum));
|
||||||
if (!$result2)
|
if (!$result2)
|
||||||
{
|
{
|
||||||
throw new SQLException("Could not list indexes keys for table: " . $this->name, pg_last_error($this->conn->getResource()));
|
throw new SQLException("Could not list indexes keys for table: " . $this->name, pg_last_error($this->conn->getResource()));
|
||||||
@@ -456,7 +456,7 @@ class PgSQLTableInfo extends TableInfo {
|
|||||||
JOIN pg_class cls ON cls.oid=indexrelid
|
JOIN pg_class cls ON cls.oid=indexrelid
|
||||||
WHERE indrelid = %s AND indisprimary
|
WHERE indrelid = %s AND indisprimary
|
||||||
ORDER BY cls.relname";
|
ORDER BY cls.relname";
|
||||||
$result = pg_query($this->conn->getResource(), sprintf ($filter->preventSqlInjection($query), $this->oid));
|
$result = $this->executePgQuery($this->conn->getResource(), sprintf ($filter->preventSqlInjection($query), $this->oid));
|
||||||
if (!$result) {
|
if (!$result) {
|
||||||
throw new SQLException("Could not list primary keys for table: " . $this->name, pg_last_error($this->conn->getResource()));
|
throw new SQLException("Could not list primary keys for table: " . $this->name, pg_last_error($this->conn->getResource()));
|
||||||
}
|
}
|
||||||
@@ -485,7 +485,7 @@ class PgSQLTableInfo extends TableInfo {
|
|||||||
FROM pg_catalog.pg_class c JOIN pg_catalog.pg_attribute a ON a.attrelid = c.oid
|
FROM pg_catalog.pg_class c JOIN pg_catalog.pg_attribute a ON a.attrelid = c.oid
|
||||||
WHERE c.oid = '%s' AND a.attnum = %d AND NOT a.attisdropped
|
WHERE c.oid = '%s' AND a.attnum = %d AND NOT a.attisdropped
|
||||||
ORDER BY a.attnum";
|
ORDER BY a.attnum";
|
||||||
$result2 = pg_query ($this->conn->getResource(), sprintf ($filter->preventSqlInjection($query), $this->oid, $intColNum));
|
$result2 = $this->executePgQuery($this->conn->getResource(), sprintf ($filter->preventSqlInjection($query), $this->oid, $intColNum));
|
||||||
if (!$result2)
|
if (!$result2)
|
||||||
{
|
{
|
||||||
throw new SQLException("Could not list indexes keys for table: " . $this->name, pg_last_error($this->conn->getResource()));
|
throw new SQLException("Could not list indexes keys for table: " . $this->name, pg_last_error($this->conn->getResource()));
|
||||||
@@ -500,6 +500,9 @@ class PgSQLTableInfo extends TableInfo {
|
|||||||
$this->pkLoaded = true;
|
$this->pkLoaded = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function executePgQuery($conn, $query){
|
||||||
|
$result = pg_query($conn, $query);
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -123,7 +123,7 @@ class SQLiteTableInfo extends TableInfo {
|
|||||||
$this->indexes[$name] = new IndexInfo($name);
|
$this->indexes[$name] = new IndexInfo($name);
|
||||||
|
|
||||||
// get columns for that index
|
// get columns for that index
|
||||||
$query = "PRAGMA index_info('$name')";
|
$query = "PRAGMA index_info('".$name."')";
|
||||||
$res2 = sqlite_query($this->conn->getResource(), $filter->preventSqlInjection($query));
|
$res2 = sqlite_query($this->conn->getResource(), $filter->preventSqlInjection($query));
|
||||||
while($row2 = sqlite_fetch_array($res2, SQLITE_ASSOC)) {
|
while($row2 = sqlite_fetch_array($res2, SQLITE_ASSOC)) {
|
||||||
$colname = $row2['name'];
|
$colname = $row2['name'];
|
||||||
|
|||||||
Reference in New Issue
Block a user