You've already forked postfixadmin
mirror of
https://github.com/postfixadmin/postfixadmin.git
synced 2025-08-07 17:42:53 +03:00
phpdoc; touch sqlite file before trying to use it in tests
This commit is contained in:
@@ -1430,17 +1430,10 @@ EOF;
|
|||||||
* db_connect
|
* db_connect
|
||||||
* Action: Makes a connection to the database if it doesn't exist
|
* Action: Makes a connection to the database if it doesn't exist
|
||||||
* Call: db_connect ()
|
* Call: db_connect ()
|
||||||
* Optional parameter: $ignore_errors = TRUE, used by setup.php
|
|
||||||
*
|
*
|
||||||
* Return value:
|
* Return value:
|
||||||
* a) without $ignore_errors or $ignore_errors == 0
|
|
||||||
* - $link - the database connection -OR-
|
|
||||||
* - call die() in case of connection problems
|
|
||||||
* b) with $ignore_errors == TRUE
|
|
||||||
* array($link, $error_text);
|
|
||||||
*
|
*
|
||||||
* @param bool $ignore_errors
|
* @return \PDO|false
|
||||||
* @return PDO
|
|
||||||
*/
|
*/
|
||||||
function db_connect() {
|
function db_connect() {
|
||||||
list($link, $_) = db_connect_with_errors();
|
list($link, $_) = db_connect_with_errors();
|
||||||
@@ -1450,7 +1443,7 @@ function db_connect() {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param bool $ignore_errors
|
* @param bool $ignore_errors
|
||||||
* @return array
|
* @return array [PDO link | false, string $error_text];
|
||||||
*/
|
*/
|
||||||
function db_connect_with_errors() {
|
function db_connect_with_errors() {
|
||||||
global $CONF;
|
global $CONF;
|
||||||
@@ -1462,7 +1455,7 @@ function db_connect_with_errors() {
|
|||||||
if (isset($link) && $link) {
|
if (isset($link) && $link) {
|
||||||
return array($link, $error_text);
|
return array($link, $error_text);
|
||||||
}
|
}
|
||||||
$link = 0;
|
$link = false;
|
||||||
|
|
||||||
$options = array(
|
$options = array(
|
||||||
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
|
PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
|
||||||
@@ -1649,6 +1642,12 @@ function db_query_one($sql, array $values = array()) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $sql e.g. UPDATE foo SET bar = :baz
|
||||||
|
* @param array $values - parameters for the prepared statement e.g. ['baz' => 1234]
|
||||||
|
* @param bool $throw_errors
|
||||||
|
* @return int number of rows affected by the query
|
||||||
|
*/
|
||||||
function db_execute($sql, array $values = array(), $throw_errors = false) {
|
function db_execute($sql, array $values = array(), $throw_errors = false) {
|
||||||
$link = db_connect();
|
$link = db_connect();
|
||||||
|
|
||||||
|
@@ -11,6 +11,9 @@ $CONF['default_language'] = 'en';
|
|||||||
$CONF['language_hook'] = '';
|
$CONF['language_hook'] = '';
|
||||||
|
|
||||||
$db_file = dirname(__FILE__) . '/postfixadmin.sqlite.test';
|
$db_file = dirname(__FILE__) . '/postfixadmin.sqlite.test';
|
||||||
|
|
||||||
|
touch($db_file);
|
||||||
|
|
||||||
$CONF['database_type'] = 'sqlite';
|
$CONF['database_type'] = 'sqlite';
|
||||||
$CONF['database_name'] = $db_file;
|
$CONF['database_name'] = $db_file;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user