public function dropTable($name)
{
+ global $_PEAR;
+
$res = $this->conn->query("DROP TABLE $name");
- if (PEAR::isError($res)) {
+ if ($_PEAR->isError($res)) {
throw new Exception($res->getMessage());
}
public function createIndex($table, $columnNames, $name=null)
{
+ global $_PEAR;
+
if (!is_array($columnNames)) {
$columnNames = array($columnNames);
}
"ADD INDEX $name (".
implode(",", $columnNames).")");
- if (PEAR::isError($res)) {
+ if ($_PEAR->isError($res)) {
throw new Exception($res->getMessage());
}
public function dropIndex($table, $name)
{
+ global $_PEAR;
+
$res = $this->conn->query("ALTER TABLE $table DROP INDEX $name");
- if (PEAR::isError($res)) {
+ if ($_PEAR->isError($res)) {
throw new Exception($res->getMessage());
}
public function addColumn($table, $columndef)
{
+ global $_PEAR;
+
$sql = "ALTER TABLE $table ADD COLUMN " . $this->_columnSql($columndef);
$res = $this->conn->query($sql);
- if (PEAR::isError($res)) {
+ if ($_PEAR->isError($res)) {
throw new Exception($res->getMessage());
}
public function modifyColumn($table, $columndef)
{
+ global $_PEAR;
+
$sql = "ALTER TABLE $table MODIFY COLUMN " .
$this->_columnSql($columndef);
$res = $this->conn->query($sql);
- if (PEAR::isError($res)) {
+ if ($_PEAR->isError($res)) {
throw new Exception($res->getMessage());
}
public function dropColumn($table, $columnName)
{
+ global $_PEAR;
+
$sql = "ALTER TABLE $table DROP COLUMN $columnName";
$res = $this->conn->query($sql);
- if (PEAR::isError($res)) {
+ if ($_PEAR->isError($res)) {
throw new Exception($res->getMessage());
}
*/
function runSqlSet(array $statements)
{
+ global $_PEAR;
+
$ok = true;
foreach ($statements as $sql) {
if (defined('DEBUG_INSTALLER')) {
}
$res = $this->conn->query($sql);
- if (PEAR::isError($res)) {
+ if ($_PEAR->isError($res)) {
throw new Exception($res->getMessage());
}
}
$uniques = $this->diffArrays($old, $def, 'unique keys');
$indexes = $this->diffArrays($old, $def, 'indexes');
$foreign = $this->diffArrays($old, $def, 'foreign keys');
+ $fulltext = $this->diffArrays($old, $def, 'fulltext indexes');
// Drop any obsolete or modified indexes ahead...
foreach ($indexes['del'] + $indexes['mod'] as $indexName) {
$this->appendDropIndex($statements, $tableName, $indexName);
}
+ // Drop any obsolete or modified fulltext indexes ahead...
+ foreach ($fulltext['del'] + $fulltext['mod'] as $indexName) {
+ $this->appendDropIndex($statements, $tableName, $indexName);
+ }
+
// For efficiency, we want this all in one
// query, instead of using our methods.
$this->appendCreateIndex($statements, $tableName, $indexName, $def['indexes'][$indexName]);
}
+ foreach ($fulltext['mod'] + $fulltext['add'] as $indexName) {
+ $colDef = $def['fulltext indexes'][$indexName];
+ $this->appendCreateFulltextIndex($statements, $tableName, $indexName, $colDef);
+ }
+
return $statements;
}
*/
protected function fetchQueryData($sql)
{
+ global $_PEAR;
+
$res = $this->conn->query($sql);
- if (PEAR::isError($res)) {
+ if ($_PEAR->isError($res)) {
throw new Exception($res->getMessage());
}