Group database connection and schema function
This commit is contained in:
parent
013333fe6a
commit
de83bf98c7
54
lib/db.php
54
lib/db.php
|
@ -285,6 +285,33 @@ class OC_DB {
|
||||||
return self::$connection->lastInsertId($table);
|
return self::$connection->lastInsertId($table);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Insert a row if a matching row doesn't exists.
|
||||||
|
* @param string $table. The table to insert into in the form '*PREFIX*tableName'
|
||||||
|
* @param array $input. An array of fieldname/value pairs
|
||||||
|
* @returns int number of updated rows
|
||||||
|
*/
|
||||||
|
public static function insertIfNotExist($table, $input) {
|
||||||
|
self::connect();
|
||||||
|
return self::$connection->insertIfNotExist($table, $input);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Start a transaction
|
||||||
|
*/
|
||||||
|
public static function beginTransaction() {
|
||||||
|
self::connect();
|
||||||
|
self::$connection->beginTransaction();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Commit the database changes done during a transaction that is in progress
|
||||||
|
*/
|
||||||
|
public static function commit() {
|
||||||
|
self::connect();
|
||||||
|
self::$connection->commit();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Disconnect
|
* @brief Disconnect
|
||||||
*
|
*
|
||||||
|
@ -340,17 +367,6 @@ class OC_DB {
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief Insert a row if a matching row doesn't exists.
|
|
||||||
* @param string $table. The table to insert into in the form '*PREFIX*tableName'
|
|
||||||
* @param array $input. An array of fieldname/value pairs
|
|
||||||
* @returns int number of updated rows
|
|
||||||
*/
|
|
||||||
public static function insertIfNotExist($table, $input) {
|
|
||||||
self::connect();
|
|
||||||
return self::$connection->insertIfNotExist($table, $input);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief drop a table
|
* @brief drop a table
|
||||||
* @param string $tableName the table to drop
|
* @param string $tableName the table to drop
|
||||||
|
@ -378,22 +394,6 @@ class OC_DB {
|
||||||
OC_DB_Schema::replaceDB(self::$connection, $file);
|
OC_DB_Schema::replaceDB(self::$connection, $file);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Start a transaction
|
|
||||||
*/
|
|
||||||
public static function beginTransaction() {
|
|
||||||
self::connect();
|
|
||||||
self::$connection->beginTransaction();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Commit the database changes done during a transaction that is in progress
|
|
||||||
*/
|
|
||||||
public static function commit() {
|
|
||||||
self::connect();
|
|
||||||
self::$connection->commit();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* check if a result is an error, works with Doctrine
|
* check if a result is an error, works with Doctrine
|
||||||
* @param mixed $result
|
* @param mixed $result
|
||||||
|
|
Loading…
Reference in New Issue