From 5b110d7b7328b1b72fd608b9f9370534dff5f30a Mon Sep 17 00:00:00 2001 From: stronk7 Date: Sun, 25 May 2008 22:23:27 +0000 Subject: [PATCH] More changes to Oracle driver + fixing some bugs. More coming soon. MDL-14888, MDL-14986 --- lib/dml/oci8po_adodb_moodle_database.php | 51 +++--------------------- 1 file changed, 6 insertions(+), 45 deletions(-) diff --git a/lib/dml/oci8po_adodb_moodle_database.php b/lib/dml/oci8po_adodb_moodle_database.php index e2a9c0aa51..88c730ced5 100644 --- a/lib/dml/oci8po_adodb_moodle_database.php +++ b/lib/dml/oci8po_adodb_moodle_database.php @@ -219,7 +219,7 @@ class oci8po_adodb_moodle_database extends adodb_moodle_database { return false; } - oracle_dirty_hack($table, $dataobject); /// Convert object to the correct "empty" values for Oracle DB + $this->oracle_dirty_hack($table, $dataobject); /// Convert object to the correct "empty" values for Oracle DB $columns = $this->get_columns($table); $cleaned = array(); @@ -302,7 +302,7 @@ class oci8po_adodb_moodle_database extends adodb_moodle_database { unset($dataobject->id); - oracle_dirty_hack($table, $dataobject); /// Convert object to the correct "empty" values for Oracle DB + $this->oracle_dirty_hack($table, $dataobject); /// Convert object to the correct "empty" values for Oracle DB $columns = $this->get_columns($table); $cleaned = array(); @@ -384,7 +384,7 @@ class oci8po_adodb_moodle_database extends adodb_moodle_database { $dataobject = new StdClass; $dataobject->{$newfield} = $newvalue; - oracle_dirty_hack($table, $dataobject); // Convert object to the correct "empty" values for Oracle DB + $this->oracle_dirty_hack($table, $dataobject); // Convert object to the correct "empty" values for Oracle DB $newvalue = $dataobject->{$newfield}; $columns = $this->get_columns($table); @@ -449,7 +449,7 @@ class oci8po_adodb_moodle_database extends adodb_moodle_database { /// Fallback, seqname not found, something is wrong. Inform and use the alternative getNameForObject() method $generator = $this->get_dbman()->generator; $generator->setPrefix($this->getPrefix()); - $seqname = $generator->getNameForObject($table, $primarykey, 'seq'); + $seqname = $generator->getNameForObject($table, 'id', 'seq'); } if ($nextval = $this->db->GenID($seqname)) { $params['id'] = (int)$nextval; @@ -466,10 +466,10 @@ class oci8po_adodb_moodle_database extends adodb_moodle_database { /// Oracle requires those function calls on insert to prepare blob/clob storage, so we /// specify them as SQL, deleting them from parameters foreach ($params as $key=>$param) { - if ($param == 'empty_blob()') { + if ($param === 'empty_blob()') { $qms[] = 'empty_blob()'; unset($params[$key]); - } else if ($param == 'empty_clob()') { + } else if ($param === 'empty_clob()') { $qms[] = 'empty_clob()'; unset($params[$key]); } else { @@ -493,45 +493,6 @@ class oci8po_adodb_moodle_database extends adodb_moodle_database { return false; } - /** - * Update record in database, as fast as possible, no safety checks, lobs not supported. - * (overloaded from adodb_moodle_database because of empty_blob()/empty_clob()) - * @param string $table name - * @param mixed $params data record as object or array - * @param bool true means repeated updates expected - * @return bool success - */ - public function update_record_raw($table, $params, $bulk=false) { - if (!is_array($params)) { - $params = (array)$params; - } - if (!isset($params['id'])) { - return false; - } - $id = $params['id']; - unset($params['id']); - - if (empty($params)) { - return false; - } - - $sets = array(); - foreach ($params as $field=>$value) { - $sets[] = "$field = ?"; - } - - $params[] = $id; // last ? in WHERE condition - - $sets = implode(',', $sets); - $sql = "UPDATE {$this->prefix}$table SET $sets WHERE id=?"; - - if (!$rs = $this->db->Execute($sql, $params)) { - $this->report_error($sql, $params); - return false; - } - return true; - } - /** * This function is used to convert all the Oracle 1-space defaults to the empty string * like a really DIRTY HACK to allow it to work better until all those NOT NULL DEFAULT '' -- 2.39.5