From 173728484e87ce8d695ecdcb1a15f8fd5ece9fbb Mon Sep 17 00:00:00 2001 From: Robert Sesek Date: Sat, 24 Dec 2005 20:55:20 +0000 Subject: [PATCH] We can no longer assume to use ISSO->modules['db_mysql']; ISSO_DB_LAYER is now used to determine the module. This constant *MUST* be defined. --- api.php | 10 +++++----- db_postgresql.php | 19 +++++++++++++++++++ kernel.php | 4 ++-- printer.php | 4 ++-- template.php | 10 +++++----- 5 files changed, 33 insertions(+), 14 deletions(-) diff --git a/api.php b/api.php index 924ebaf..60d30c2 100644 --- a/api.php +++ b/api.php @@ -290,7 +290,7 @@ class API $this->run_action_method('pre_fetch'); - $result = $this->registry->modules['db_mysql']->query_first("SELECT * FROM {$this->prefix}{$this->table} WHERE {$this->condition}"); + $result = $this->registry->modules[ISSO_DB_LAYER]->query_first("SELECT * FROM {$this->prefix}{$this->table} WHERE {$this->condition}"); if (!$result) { $this->error($this->registry->modules['localize']->string('No records were returned')); @@ -320,8 +320,8 @@ class API $values[] = $this->prepare_field_for_sql($field); } - $this->registry->modules['db_mysql']->query("INSERT INTO {$this->prefix}{$this->table} (" . implode(',', $fields) . ") VALUES (" . implode(',', $values) . ")"); - $this->insertid = $this->registry->modules['db_mysql']->insert_id(); + $this->registry->modules[ISSO_DB_LAYER]->query("INSERT INTO {$this->prefix}{$this->table} (" . implode(',', $fields) . ") VALUES (" . implode(',', $values) . ")"); + $this->insertid = $this->registry->modules[ISSO_DB_LAYER]->insert_id(); $this->run_action_method('post_insert'); } @@ -347,7 +347,7 @@ class API } $updates = implode(', ', $updates); - $this->registry->modules['db_mysql']->query("UPDATE {$this->prefix}{$this->table} SET $updates WHERE {$this->condition}"); + $this->registry->modules[ISSO_DB_LAYER]->query("UPDATE {$this->prefix}{$this->table} SET $updates WHERE {$this->condition}"); $this->run_action_method('post_update'); } @@ -369,7 +369,7 @@ class API $this->run_action_method('pre_delete'); - $this->registry->modules['db_mysql']->query("DELETE FROM {$this->prefix}{$this->table} WHERE {$this->condition}"); + $this->registry->modules[ISSO_DB_LAYER]->query("DELETE FROM {$this->prefix}{$this->table} WHERE {$this->condition}"); $this->run_action_method('post_delete'); } diff --git a/db_postgresql.php b/db_postgresql.php index 8677c5f..ae66a1a 100644 --- a/db_postgresql.php +++ b/db_postgresql.php @@ -171,6 +171,25 @@ class DB_PostgreSQL extends DB_Abstract { return -1; } + + // ################################################################### + /** + * Overload: insert_id + * + * @access public + * + * @param integer Result + * @param string PostgreSQL sequence + * + * @return integer Insert ID + */ + function insert_id($result, $sequence) + { + $temp = $this->query("SELECT currval($sequence) AS auto_inc"); + //$temp = call_user_func($this->commands['query'], "SELECT currval($table_col)"); + var_dump( $temp); + print_r($this->fetch_array($temp)); + } } /*=====================================================================*\ diff --git a/kernel.php b/kernel.php index 7493ae2..ba7d4a5 100644 --- a/kernel.php +++ b/kernel.php @@ -876,9 +876,9 @@ class Shared_Object_Framework $debug .= "\n\t
  • Source Control: $scinfo
  • "; // query information - if (is_object($this->modules['db_mysql'])) + if (is_object($this->modules[ISSO_DB_LAYER])) { - $debug .= "\n\t
  • Total Queries: " . sizeof($this->modules['db_mysql']->history) . " (sanitize($_SERVER['REQUEST_URI']) . ((strpos($_SERVER['REQUEST_URI'], '?') !== false) ? '&query=1' : '?query=1') . "\">?)
  • "; + $debug .= "\n\t
  • Total Queries: " . sizeof($this->modules[ISSO_DB_LAYER]->history) . " (sanitize($_SERVER['REQUEST_URI']) . ((strpos($_SERVER['REQUEST_URI'], '?') !== false) ? '&query=1' : '?query=1') . "\">?)
  • "; } // total execution time diff --git a/printer.php b/printer.php index b18d9d5..54d3df5 100644 --- a/printer.php +++ b/printer.php @@ -342,10 +342,10 @@ JS; ob_clean(); ob_end_clean(); - if (is_array($this->registry->modules['db_mysql']->history)) + if (is_array($this->registry->modules[ISSO_DB_LAYER]->history)) { echo '
    ';
    -				foreach ($this->registry->modules['db_mysql']->history AS $query)
    +				foreach ($this->registry->modules[ISSO_DB_LAYER]->history AS $query)
     				{
     					echo $query . "\n\n
    \n\n"; } diff --git a/template.php b/template.php index 1acffeb..c1052e3 100644 --- a/template.php +++ b/template.php @@ -147,8 +147,8 @@ class Template } else { - $templates = $this->registry->modules['db_mysql']->query("SELECT * FROM " . $this->tablename . " WHERE " . $this->namecolumn . " IN ('" . implode("', '", $namearray) . "')" . ($this->extrawhere ? $this->extrawhere : '')); - while ($template = $this->registry->modules['db_mysql']->fetch_array($templates)) + $templates = $this->registry->modules[ISSO_DB_LAYER]->query("SELECT * FROM " . $this->tablename . " WHERE " . $this->namecolumn . " IN ('" . implode("', '", $namearray) . "')" . ($this->extrawhere ? $this->extrawhere : '')); + while ($template = $this->registry->modules[ISSO_DB_LAYER]->fetch_array($templates)) { $this->cache[ $template[ $this->namecolumn ] ] = $this->_parse($template[ $this->datacolumn ]); $this->usage["$name"] = 0; @@ -211,10 +211,10 @@ class Template if ($this->registry->debug AND isset($_GET['query'])) { - if (is_array($this->registry->modules['db_mysql']->history)) + if (is_array($this->registry->modules[ISSO_DB_LAYER]->history)) { echo '
    ';
    -				foreach ($this->registry->modules['db_mysql']->history AS $query)
    +				foreach ($this->registry->modules[ISSO_DB_LAYER]->history AS $query)
     				{
     					echo $query . "\n\n
    \n\n"; } @@ -246,7 +246,7 @@ class Template */ function _load($name) { - if ($template = $this->registry->modules['db_mysql']->query("SELECT * FROM " . $this->tablename . " WHERE " . $this->namecolumn . " = '$name'" . ($this->extrawhere ? $this->extrawhere : ''))) + if ($template = $this->registry->modules[ISSO_DB_LAYER]->query("SELECT * FROM " . $this->tablename . " WHERE " . $this->namecolumn . " = '$name'" . ($this->extrawhere ? $this->extrawhere : ''))) { return $template[ $this->datacolumn ]; } -- 2.22.5