summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.idea/codeStyleSettings.xml8
-rw-r--r--inc/database.inc.php37
2 files changed, 22 insertions, 23 deletions
diff --git a/.idea/codeStyleSettings.xml b/.idea/codeStyleSettings.xml
index 29def55c..9237b675 100644
--- a/.idea/codeStyleSettings.xml
+++ b/.idea/codeStyleSettings.xml
@@ -29,6 +29,14 @@
<option name="USE_TAB_CHARACTER" value="true" />
</indentOptions>
</codeStyleSettings>
+ <codeStyleSettings language="JavaScript">
+ <indentOptions>
+ <option name="INDENT_SIZE" value="3" />
+ <option name="CONTINUATION_INDENT_SIZE" value="3" />
+ <option name="TAB_SIZE" value="3" />
+ <option name="USE_TAB_CHARACTER" value="true" />
+ </indentOptions>
+ </codeStyleSettings>
<codeStyleSettings language="PHP">
<option name="LINE_COMMENT_AT_FIRST_COLUMN" value="false" />
<option name="LINE_COMMENT_ADD_SPACE" value="true" />
diff --git a/inc/database.inc.php b/inc/database.inc.php
index c3901453..ee45f6c0 100644
--- a/inc/database.inc.php
+++ b/inc/database.inc.php
@@ -13,36 +13,26 @@ class Database
*/
private static $dbh = false;
private static $statements = array();
-
- /**
- * Get database schema version - used for checking for updates
- * @return int Version of db schema
- */
- public static function getExpectedSchemaVersion()
- {
- return 12;
- }
-
- public static function needSchemaUpdate()
- {
- return Property::getCurrentSchemaVersion() < self::getExpectedSchemaVersion();
- }
/**
* Connect to the DB if not already connected.
*/
- private static function init()
+ public static function init($returnSuccess = false)
{
if (self::$dbh !== false)
- return;
+ return true;
try {
- if (CONFIG_SQL_FORCE_UTF8)
+ if (CONFIG_SQL_FORCE_UTF8) {
self::$dbh = new PDO(CONFIG_SQL_DSN, CONFIG_SQL_USER, CONFIG_SQL_PASS, array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"));
- else
+ } else {
self::$dbh = new PDO(CONFIG_SQL_DSN, CONFIG_SQL_USER, CONFIG_SQL_PASS);
+ }
} catch (PDOException $e) {
+ if ($returnSuccess)
+ return false;
Util::traceError('Connecting to the local database failed: ' . $e->getMessage());
}
+ return true;
}
/**
@@ -62,7 +52,7 @@ class Database
/**
* Execute the given query and return the number of rows affected.
* Mostly useful for UPDATEs or INSERTs
- *
+ *
* @param string $query Query to run
* @param array $args Arguments to query
* @param boolean $ignoreError Ignore query errors and just return false
@@ -78,7 +68,7 @@ class Database
/**
* Get id (promary key) of last row inserted.
- *
+ *
* @return int the id
*/
public static function lastInsertId()
@@ -91,6 +81,7 @@ class Database
* Note that this will re-use PDOStatements, so if you run the same
* query again with different params, do not rely on the first PDOStatement
* still being valid. If you need to do something fancy, use Database::prepare
+ *
* @return \PDOStatement The query result object
*/
public static function simpleQuery($query, $args = array(), $ignoreError = false)
@@ -109,9 +100,9 @@ class Database
}
return self::$statements[$query];
} catch (Exception $e) {
- if ($ignoreError)
- return false;
- Util::traceError("Database Error: \n" . $e->getMessage());
+ if ($ignoreError)
+ return false;
+ Util::traceError("Database Error: \n" . $e->getMessage());
}
return false;
}