From 6f3493bb3ca3718d4b69278c96df384c8a4d5811 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sun, 12 Mar 2017 15:50:47 -0700 Subject: db issues --- include/dba/dba_pdo.php | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'include/dba') diff --git a/include/dba/dba_pdo.php b/include/dba/dba_pdo.php index f76e6cdd7..f119d8926 100755 --- a/include/dba/dba_pdo.php +++ b/include/dba/dba_pdo.php @@ -74,19 +74,19 @@ class dba_pdo extends dba_driver { return $result; } - if($this->debug) { - db_logger('dba_pdo: DEBUG: ' . printable($sql) . ' returned ' . count($result) . ' results.', LOGGER_NORMAL, LOG_INFO); - } - $r = array(); if($result) { foreach($result as $x) { $r[] = $x; } - if($this->debug) { - db_logger('dba_pdo: ' . printable(print_r($r,true)), LOGGER_NORMAL, LOG_INFO); - } } + + if($this->debug) { + db_logger('dba_pdo: DEBUG: ' . printable($sql) . ' returned ' . count($r) . ' results.', LOGGER_NORMAL, LOG_INFO); + db_logger('dba_pdo: ' . printable(print_r($r,true)), LOGGER_NORMAL, LOG_INFO); + } + + return (($this->error) ? false : $r); } -- cgit v1.2.3 From 5c63f7dd58c5b3b88efcc47120c791f92527f720 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Sat, 25 Mar 2017 14:19:32 -0700 Subject: provide platform specific install script --- include/dba/dba_driver.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'include/dba') diff --git a/include/dba/dba_driver.php b/include/dba/dba_driver.php index e47f97387..ad1d9d194 100755 --- a/include/dba/dba_driver.php +++ b/include/dba/dba_driver.php @@ -15,7 +15,7 @@ class DBA { static public $scheme = 'mysql'; static public $logging = false; - static public $install_script = 'install/schema_mysql.sql'; + static public $install_script = 'schema_mysql.sql'; static public $null_date = '0001-01-01 00:00:00'; static public $utc_now = 'UTC_TIMESTAMP()'; static public $tquot = "`"; @@ -46,7 +46,7 @@ class DBA { if(!($port)) $port = 5432; - self::$install_script = 'install/schema_postgres.sql'; + self::$install_script = 'schema_postgres.sql'; self::$utc_now = "now() at time zone 'UTC'"; self::$tquot = '"'; self::$scheme = 'pgsql'; @@ -163,7 +163,9 @@ abstract class dba_driver { } function get_install_script() { - return \DBA::$install_script; + if(file_exists('install/' . PLATFORM_NAME . '/' . \DBA::$install_script)) + return 'install/' . PLATFORM_NAME . '/' . \DBA::$install_script; + return 'install/' . \DBA::$install_script; } function get_table_quote() { -- cgit v1.2.3 From 3a00140797fa0d557db2434402ce20258b4ce570 Mon Sep 17 00:00:00 2001 From: zotlabs Date: Tue, 23 May 2017 21:20:40 -0700 Subject: remove php version checks for older ( < 5.4) code incompatibilities --- include/dba/dba_driver.php | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'include/dba') diff --git a/include/dba/dba_driver.php b/include/dba/dba_driver.php index d362f58b2..b0ad7936c 100755 --- a/include/dba/dba_driver.php +++ b/include/dba/dba_driver.php @@ -344,11 +344,8 @@ function q($sql) { if(\DBA::$dba && \DBA::$dba->connected) { $stmt = vsprintf($sql, $args); if($stmt === false) { - if(version_compare(PHP_VERSION, '5.4.0') >= 0) - db_logger('dba: vsprintf error: ' . - print_r(debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT, 1), true),LOGGER_NORMAL,LOG_CRIT); - else - db_logger('dba: vsprintf error: ' . print_r(debug_backtrace(), true),LOGGER_NORMAL,LOG_CRIT); + db_logger('dba: vsprintf error: ' . + print_r(debug_backtrace(DEBUG_BACKTRACE_PROVIDE_OBJECT, 1), true),LOGGER_NORMAL,LOG_CRIT); } if(\DBA::$dba->debug) db_logger('Sql: ' . $stmt, LOGGER_DEBUG, LOG_INFO); -- cgit v1.2.3 From 6c771f84cedc71e7ffeecebe3e2fd7f912de3e7b Mon Sep 17 00:00:00 2001 From: zotlabs Date: Thu, 22 Jun 2017 22:43:08 -0700 Subject: remove unused page_widgets.php include and provide a general function for loading sql from file to use in the cdav migration --- include/dba/dba_driver.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'include/dba') diff --git a/include/dba/dba_driver.php b/include/dba/dba_driver.php index b0ad7936c..4079bcaba 100755 --- a/include/dba/dba_driver.php +++ b/include/dba/dba_driver.php @@ -442,6 +442,20 @@ function db_getfunc($f) { return $f; } +function db_load_file($f) { + // db errors should get logged to the logfile + $str = @file_get_contents($f); + $arr = explode(';', $str); + if($arr) { + foreach($arr as $a) { + if(strlen(trim($a))) { + $r = dbq(trim($a)); + } + } + } +} + + // The logger function may make DB calls internally to query the system logging parameters. // This can cause a recursion if database debugging is enabled. // So this function preserves the current database debugging state and then turns it off -- cgit v1.2.3