diff --git a/Sccp_manager.inc/dbinterface.class.php b/Sccp_manager.inc/dbinterface.class.php index 8bbd930..d362149 100644 --- a/Sccp_manager.inc/dbinterface.class.php +++ b/Sccp_manager.inc/dbinterface.class.php @@ -149,12 +149,30 @@ class dbinterface public function get_db_SccpSetting() { global $db; - $stmt = $db->prepare('SELECT keyword, data, type, seq FROM sccpsettings ORDER BY type, seq'); - $stmt->execute(); - foreach ($stmt->fetchAll() as $var) { - $mysccpvalues[$var['keyword']] = array('keyword' => $var['keyword'], 'data' => $var['data'], 'seq' => $var['seq'], 'type' => $var['type']); + try { + $stmt = $db->prepare('SELECT keyword, data, type, seq FROM sccpsettings ORDER BY type, seq'); + $stmt->execute(); + foreach ($stmt->fetchAll() as $var) { + $mysccpvalues[$var['keyword']] = array('keyword' => $var['keyword'], 'data' => $var['data'], 'seq' => $var['seq'], 'type' => $var['type']); + } + return $mysccpvalues; + } catch(\PDOException $e) { + // sccpsettings table does not yet exist. FreePBX is instantiating + // a SCCP_Manager object from the Installer before the installer can + // create the table so will create here. + $stmt = $db-> prepare('CREATE TABLE IF NOT EXISTS sccpsettings ( + keyword VARCHAR (50) NOT NULL, + data VARCHAR (255) NOT NULL, + seq TINYINT (1), + type TINYINT (1) NOT NULL default 0, + PRIMARY KEY (keyword, seq, type ) + );'); + $check = $stmt->execute(); + if (\DB::IsError($check)) { + die_freepbx("Can not create sccpsettings table, error: $check\n"); + } + return array(); } - return $mysccpvalues; } public function get_db_sysvalues() diff --git a/install.php b/install.php index 54d2dca..daa9063 100644 --- a/install.php +++ b/install.php @@ -27,7 +27,6 @@ if (!class_exists($class, false)) { if (class_exists($class, false)) { $srvinterface = new $class(); } - function Get_DB_config($sccp_compatible) { global $mobile_hw; @@ -487,16 +486,16 @@ function InstallDB_sccpsettings() { global $db; outn("