|
|
@ -21,7 +21,8 @@ class Database |
|
|
|
private static $connection; |
|
|
|
private static $connection; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Set the DB manager instance |
|
|
|
* Set the DB manager instance. |
|
|
|
|
|
|
|
* |
|
|
|
* @param EntityManager $em |
|
|
|
* @param EntityManager $em |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public function setManager($em) |
|
|
|
public function setManager($em) |
|
|
@ -30,8 +31,7 @@ class Database |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Set the DB connection instance |
|
|
|
* Set the DB connection instance. |
|
|
|
* @param Connection $connection |
|
|
|
|
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public function setConnection(Connection $connection) |
|
|
|
public function setConnection(Connection $connection) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -39,7 +39,8 @@ class Database |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Get the DB connection instance |
|
|
|
* Get the DB connection instance. |
|
|
|
|
|
|
|
* |
|
|
|
* @return Connection |
|
|
|
* @return Connection |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public function getConnection() |
|
|
|
public function getConnection() |
|
|
@ -48,7 +49,8 @@ class Database |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Get the DB manager instance |
|
|
|
* Get the DB manager instance. |
|
|
|
|
|
|
|
* |
|
|
|
* @return EntityManager |
|
|
|
* @return EntityManager |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public static function getManager() |
|
|
|
public static function getManager() |
|
|
@ -339,7 +341,8 @@ class Database |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Wrapper for rowCount() |
|
|
|
* Wrapper for rowCount(). |
|
|
|
|
|
|
|
* |
|
|
|
* @return int |
|
|
|
* @return int |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public static function num_rows(Statement $result) |
|
|
|
public static function num_rows(Statement $result) |
|
|
@ -372,7 +375,8 @@ class Database |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Wrapper for executeQuery() |
|
|
|
* Wrapper for executeQuery(). |
|
|
|
|
|
|
|
* |
|
|
|
* @param string $query |
|
|
|
* @param string $query |
|
|
|
* |
|
|
|
* |
|
|
|
* @return Statement |
|
|
|
* @return Statement |
|
|
@ -391,7 +395,8 @@ class Database |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Deal with exceptions from the database extension |
|
|
|
* Deal with exceptions from the database extension. |
|
|
|
|
|
|
|
* |
|
|
|
* @param Exception $e |
|
|
|
* @param Exception $e |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public static function handleError($e) |
|
|
|
public static function handleError($e) |
|
|
@ -416,7 +421,8 @@ class Database |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Transform an SQL option from Chamilo to PDO syntax |
|
|
|
* Transform an SQL option from Chamilo to PDO syntax. |
|
|
|
|
|
|
|
* |
|
|
|
* @param string $option |
|
|
|
* @param string $option |
|
|
|
* |
|
|
|
* |
|
|
|
* @return int |
|
|
|
* @return int |
|
|
@ -453,7 +459,7 @@ class Database |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Build an insert query |
|
|
|
* Build an insert query. |
|
|
|
* |
|
|
|
* |
|
|
|
* @param string $table_name |
|
|
|
* @param string $table_name |
|
|
|
* @param array $attributes |
|
|
|
* @param array $attributes |
|
|
@ -490,7 +496,8 @@ class Database |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Build an update query |
|
|
|
* Build an update query. |
|
|
|
|
|
|
|
* |
|
|
|
* @param string $tableName use Database::get_main_table |
|
|
|
* @param string $tableName use Database::get_main_table |
|
|
|
* @param array $attributes Values to updates |
|
|
|
* @param array $attributes Values to updates |
|
|
|
* Example: $params['name'] = 'Julio'; $params['lastname'] = 'Montoya'; |
|
|
|
* Example: $params['name'] = 'Julio'; $params['lastname'] = 'Montoya'; |
|
|
@ -738,7 +745,8 @@ class Database |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Build a delete query |
|
|
|
* Build a delete query. |
|
|
|
|
|
|
|
* |
|
|
|
* @param string $table_name |
|
|
|
* @param string $table_name |
|
|
|
* @param array $where_conditions |
|
|
|
* @param array $where_conditions |
|
|
|
* @param bool $show_query |
|
|
|
* @param bool $show_query |
|
|
@ -802,7 +810,8 @@ class Database |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Check if a given table exists |
|
|
|
* Check if a given table exists. |
|
|
|
|
|
|
|
* |
|
|
|
* @param string $table |
|
|
|
* @param string $table |
|
|
|
* |
|
|
|
* |
|
|
|
* @return bool |
|
|
|
* @return bool |
|
|
@ -813,7 +822,8 @@ class Database |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* List the columns of a given table |
|
|
|
* List the columns of a given table. |
|
|
|
|
|
|
|
* |
|
|
|
* @param string $table |
|
|
|
* @param string $table |
|
|
|
* |
|
|
|
* |
|
|
|
* @return \Doctrine\DBAL\Schema\Column[] |
|
|
|
* @return \Doctrine\DBAL\Schema\Column[] |
|
|
|