]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-16930 dml: converting print_error to exceptions
authorskodak <skodak>
Sat, 25 Oct 2008 17:43:45 +0000 (17:43 +0000)
committerskodak <skodak>
Sat, 25 Oct 2008 17:43:45 +0000 (17:43 +0000)
lib/dml/moodle_database.php
lib/dml/mssql_adodb_moodle_database.php
lib/dml/oci8po_adodb_moodle_database.php
lib/dml/postgres7_adodb_moodle_database.php

index 4a53a50f3880da0ba39988d106d9622b0dc5d679..9f8727a179be9684a297963cd73573aaebbc37cd 100644 (file)
@@ -318,7 +318,7 @@ abstract class moodle_database {
             }
 
         } else {
-            print_error('typenotimplement');
+            throw new dml_exception('typenotimplement');
         }
         return array($sql, $params);
     }
@@ -358,7 +358,7 @@ abstract class moodle_database {
         }
         if ($dollar_count) {
             if ($count) {
-                print_error('mixedtypesqlparam');
+                throw new dml_exception('mixedtypesqlparam');
             }
             $type = SQL_PARAMS_DOLLAR;
             $count = $dollar_count;
@@ -366,7 +366,7 @@ abstract class moodle_database {
         }
         if ($q_count) {
             if ($count) {
-                print_error('mixedtypesqlparam');
+                throw new dml_exception('mixedtypesqlparam');
             }
             $type = SQL_PARAMS_QM;
             $count = $q_count;
@@ -385,7 +385,7 @@ abstract class moodle_database {
         }
 
         if ($count > count($params)) {
-            print_error('invalidqueryparam');
+            throw new dml_exception('invalidqueryparam');
         }
 
         if ($type & $allowed_types) { // bitwise AND
@@ -408,12 +408,12 @@ abstract class moodle_database {
             foreach ($named_matches[0] as $key) {
                 $key = trim($key, ':');
                 if (!array_key_exists($key, $params)) {
-                    print_error('missingkeyinsql', '', '', $key);
+                    throw new dml_exception('missingkeyinsql', '', '', $key);
                 }
                 $finalparams[$key] = $params[$key];
             }
             if ($count != count($finalparams)) {
-                print_error('duplicateparaminsql');
+                throw new dml_exception('duplicateparaminsql');
             }
 
             if ($target_type & SQL_PARAMS_QM) {
@@ -422,11 +422,11 @@ abstract class moodle_database {
             } else if ($target_type & SQL_PARAMS_NAMED) {
                 return array($sql, $finalparams, SQL_PARAMS_NAMED);
             } else {  // $type & SQL_PARAMS_DOLLAR
-                print_error('boundsyntaxnotsupport');
+                throw new dml_exception('boundsyntaxnotsupport');
             }
 
         } else if ($type == SQL_PARAMS_DOLLAR) {
-            print_error('boundsyntaxnotsupport');
+            throw new dml_exception('boundsyntaxnotsupport');
 
         } else { // $type == SQL_PARAMS_QM
             if (count($params) != $count) {
@@ -448,7 +448,7 @@ abstract class moodle_database {
                 }
                 return array($sql, $finalparams, SQL_PARAMS_NAMED);
             } else {  // $type & SQL_PARAMS_DOLLAR
-                print_error('boundsyntaxnotsupport');
+                throw new dml_exception('boundsyntaxnotsupport');
             }
         }
     }
@@ -1417,7 +1417,7 @@ abstract class moodle_database {
         $params = array();
         foreach ($conditions as $key=>$value) {
             if (is_int($key)) {
-                print_error('invalidnumkey');
+                throw new dml_exception('invalidnumkey');
             }
             if (is_null($value)) {
                 $where[] = "$key IS NULL";
index c9350e1450d80198f0127356b61ceb248bdf2af2..e3157164d65ea12b82f752e60dc284dfba4c66e7 100644 (file)
@@ -16,7 +16,7 @@ class mssql_adodb_moodle_database extends adodb_moodle_database {
     public function connect($dbhost, $dbuser, $dbpass, $dbname, $dbpersist, $prefix, array $dboptions=null) {
         if ($prefix == '' and !$this->external) {
             //Enforce prefixes for everybody but mysql
-            print_error('prefixcannotbeempty', 'error', '', $this->get_dbfamily());
+            throw new dml_exception('prefixcannotbeempty', $this->get_dbfamily());
         }
         return parent::connect($dbhost, $dbuser, $dbpass, $dbname, $dbpersist, $prefix, $dboptions);
     }
index 3d02f662d8cdcbecf079a38c407eb009061c73ea..77dcbbb18439310b1c2f826343b08bbb2340096a 100644 (file)
@@ -13,12 +13,12 @@ class oci8po_adodb_moodle_database extends adodb_moodle_database {
     public function connect($dbhost, $dbuser, $dbpass, $dbname, $dbpersist, $prefix, array $dboptions=null) {
         if ($prefix == '' and !$this->external) {
             //Enforce prefixes for everybody but mysql
-            print_error('prefixcannotbeempty', 'error', '', $this->get_dbfamily());
+            throw new dml_exception('prefixcannotbeempty', $this->get_dbfamily());
         }
         if (!$this->external and strlen($prefix) > 2) {
             //Max prefix length for Oracle is 2cc
             $a = (object)array('dbfamily'=>'oracle', 'maxlength'=>2);
-            print_error('prefixtoolong', 'error', '', $a);
+            throw new dml_exception('prefixtoolong', $a);
         }
         return parent::connect($dbhost, $dbuser, $dbpass, $dbname, $dbpersist, $prefix, $dboptions);
     }
index 0710cec63fabb23d1628410cbf6bed5dad0ad1ec..d11f9f4a86f0bebb2b7e53c6c2d362ffe0bd2521 100644 (file)
@@ -12,7 +12,7 @@ class postgres7_adodb_moodle_database extends adodb_moodle_database {
     public function connect($dbhost, $dbuser, $dbpass, $dbname, $dbpersist, $prefix, array $dboptions=null) {
         if ($prefix == '' and !$this->external) {
             //Enforce prefixes for everybody but mysql
-            print_error('prefixcannotbeempty', 'error', '', $this->get_dbfamily());
+            throw new dml_exception('prefixcannotbeempty', $this->get_dbfamily());
         }
         return parent::connect($dbhost, $dbuser, $dbpass, $dbname, $dbpersist, $prefix, $dboptions);
     }