From: Eloy Lafuente Date: Wed, 4 Nov 2009 13:19:11 +0000 (+0000) Subject: MDL-20734 normalise_value() - moving from private to protected everywhere and abstracting X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=e3acc8af7acc0b97c6b1bf25f5dc56a345161e73;p=moodle.git MDL-20734 normalise_value() - moving from private to protected everywhere and abstracting --- diff --git a/lib/dml/moodle_database.php b/lib/dml/moodle_database.php index cf303a5181..4dff70cb42 100644 --- a/lib/dml/moodle_database.php +++ b/lib/dml/moodle_database.php @@ -744,6 +744,15 @@ abstract class moodle_database { */ public abstract function get_columns($table, $usecache=true); + /** + * Normalise values based in RDBMS dependencies (booleans, LOBs...) + * + * @param database_column_info $column column metadata corresponding with the value we are going to normalise + * @param mixed $value value we are going to normalise + * @return mixed the normalised value + */ + protected abstract function normalise_value($column, $value); + /** * Reset internal column details cache * @param string $table - empty means all, or one if name of table given diff --git a/lib/dml/mssql_native_moodle_database.php b/lib/dml/mssql_native_moodle_database.php index db2f0ba1b3..07398f53c7 100644 --- a/lib/dml/mssql_native_moodle_database.php +++ b/lib/dml/mssql_native_moodle_database.php @@ -517,7 +517,7 @@ class mssql_native_moodle_database extends moodle_database { * @param mixed $value value we are going to normalise * @return mixed the normalised value */ - private function normalise_value($column, $value) { + protected function normalise_value($column, $value) { if (is_bool($value)) { /// Always, convert boolean to int $value = (int)$value; } // And continue processing because text columns with numeric info need special handling below diff --git a/lib/dml/mysqli_native_moodle_database.php b/lib/dml/mysqli_native_moodle_database.php index 05ff054829..2ba86cd90e 100644 --- a/lib/dml/mysqli_native_moodle_database.php +++ b/lib/dml/mysqli_native_moodle_database.php @@ -462,7 +462,7 @@ class mysqli_native_moodle_database extends moodle_database { * @param mixed $value value we are going to normalise * @return mixed the normalised value */ - private function normalise_value($column, $value) { + protected function normalise_value($column, $value) { if (is_bool($value)) { // Always, convert boolean to int $value = (int)$value; diff --git a/lib/dml/oci_native_moodle_database.php b/lib/dml/oci_native_moodle_database.php index b89b1cacb4..16b3a42037 100644 --- a/lib/dml/oci_native_moodle_database.php +++ b/lib/dml/oci_native_moodle_database.php @@ -638,7 +638,7 @@ class oci_native_moodle_database extends moodle_database { * @param mixed $value value we are going to normalise * @return mixed the normalised value */ - private function normalise_value($column, $value) { + protected function normalise_value($column, $value) { if (is_bool($value)) { // Always, convert boolean to int $value = (int)$value; diff --git a/lib/dml/pgsql_native_moodle_database.php b/lib/dml/pgsql_native_moodle_database.php index d2be127c98..6e9836f41c 100644 --- a/lib/dml/pgsql_native_moodle_database.php +++ b/lib/dml/pgsql_native_moodle_database.php @@ -508,7 +508,7 @@ class pgsql_native_moodle_database extends moodle_database { * @param mixed $value value we are going to normalise * @return mixed the normalised value */ - private function normalise_value($column, $value) { + protected function normalise_value($column, $value) { if (is_bool($value)) { // Always, convert boolean to int $value = (int)$value; diff --git a/lib/dml/simpletest/testdml.php b/lib/dml/simpletest/testdml.php index 6c5b37b4d1..56a90c9b98 100755 --- a/lib/dml/simpletest/testdml.php +++ b/lib/dml/simpletest/testdml.php @@ -2435,6 +2435,7 @@ class moodle_database_for_testing extends moodle_database { public function get_tables($usecache=true){} public function get_indexes($table){} public function get_columns($table, $usecache=true){} + protected function normalise_value($column, $value){} public function set_debug($state){} public function get_debug(){} public function set_logging($state){} diff --git a/lib/dml/sqlite3_pdo_moodle_database.php b/lib/dml/sqlite3_pdo_moodle_database.php index e3821cc723..30b44f8ddd 100644 --- a/lib/dml/sqlite3_pdo_moodle_database.php +++ b/lib/dml/sqlite3_pdo_moodle_database.php @@ -293,6 +293,17 @@ class sqlite3_pdo_moodle_database extends pdo_moodle_database { return $columns; } + /** + * Normalise values based in RDBMS dependencies (booleans, LOBs...) + * + * @param database_column_info $column column metadata corresponding with the value we are going to normalise + * @param mixed $value value we are going to normalise + * @return mixed the normalised value + */ + protected function normalise_value($column, $value) { + return $value; + } + /** * Returns the sql statement with clauses to append used to limit a recordset range. * @param string $sql the SQL statement to limit.