]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-17020 dml: native pgsql driver - $ bound syntax fully implemented, we do not...
authorskodak <skodak>
Mon, 27 Oct 2008 12:00:04 +0000 (12:00 +0000)
committerskodak <skodak>
Mon, 27 Oct 2008 12:00:04 +0000 (12:00 +0000)
lang/en_utf8/error.php
lib/dml/moodle_database.php

index 3fd0cced9d0a9e848c98f9727c719e7852dfcfef..bae343195997d5304d08dc2e8e3e0d0c080840d7 100644 (file)
@@ -11,7 +11,6 @@ $string['blockcannotconfig'] = 'This block does not support global configuration
 $string['blocknameconflict'] = 'Naming conflict: block $a->name has the same title with an existing block: $a->conflict!';
 $string['backupcontainexternal'] = 'This backup file contains external Moodle Network Hosts that are not configured locally';
 $string['backuptablefail'] = 'Backup tables could NOT be set up successfully!';
-$string['boundsyntaxnotsupport'] = 'Pg \$1, \$2 bound syntax not supported yet :-(';
 $string['cannotassignanthing'] = 'Cannot assign moodle/site:doanything';
 $string['cannotassignrole'] = 'Cannot assign role in course';
 $string['cannotassignselfasparent'] = 'Cannot assign self as parent!';
index d3c612589680e7eb97b02167ce359802fc82f513..e027465e9e2eb1cec3c76218bdcf21461453bd35 100644 (file)
@@ -431,8 +431,17 @@ abstract class moodle_database {
         } else if ($type == SQL_PARAMS_DOLLAR) {
             if ($target_type & SQL_PARAMS_DOLLAR) {
                 return array($sql, array_values($params), SQL_PARAMS_DOLLAR); // 0-based required
-            } else {
-                throw new dml_exception('boundsyntaxnotsupport');
+            } else if ($target_type & SQL_PARAMS_QM) {
+                $sql = preg_replace('/\$[0-9]+/', '?', $sql);
+                return array($sql, array_values($params), SQL_PARAMS_QM); // 0-based required
+            } else { //$target_type & SQL_PARAMS_NAMED
+                $sql = preg_replace('/\$([0-9]+)/', ':param\\1', $sql);
+                $finalparams = array();
+                foreach ($params as $key=>$param) {
+                    $key++;
+                    $finalparams['param'.$key] = $param;
+                }
+                return array($sql, $finalparams, SQL_PARAMS_NAMED);
             }
 
         } else { // $type == SQL_PARAMS_QM