MDL-80821 dml: declare arguments for sql_concat()
This commit is contained in:
@@ -2321,10 +2321,10 @@ abstract class moodle_database {
|
||||
* This function accepts variable number of string parameters.
|
||||
* All strings/fieldnames will used in the SQL concatenate statement generated.
|
||||
*
|
||||
* @param string $arr,... expressions to be concatenated.
|
||||
* @return string The SQL to concatenate strings passed in.
|
||||
* @uses func_get_args() and thus parameters are unlimited OPTIONAL number of additional field names.
|
||||
*/
|
||||
public abstract function sql_concat();
|
||||
public abstract function sql_concat(...$arr);
|
||||
|
||||
/**
|
||||
* Returns the proper SQL to do CONCAT between the elements passed
|
||||
|
||||
@@ -1927,12 +1927,11 @@ class mysqli_native_moodle_database extends moodle_database {
|
||||
* Returns the proper SQL to do CONCAT between the elements passed
|
||||
* Can take many parameters
|
||||
*
|
||||
* @param string $str,... 1 or more fields/strings to concat
|
||||
* @param string $arr,... 1 or more fields/strings to concat
|
||||
*
|
||||
* @return string The concat sql
|
||||
*/
|
||||
public function sql_concat() {
|
||||
$arr = func_get_args();
|
||||
public function sql_concat(...$arr) {
|
||||
$s = implode(', ', $arr);
|
||||
if ($s === '') {
|
||||
return "''";
|
||||
|
||||
@@ -1577,8 +1577,7 @@ class oci_native_moodle_database extends moodle_database {
|
||||
}
|
||||
}
|
||||
|
||||
public function sql_concat() {
|
||||
$arr = func_get_args();
|
||||
public function sql_concat(...$arr) {
|
||||
if (empty($arr)) {
|
||||
return " ' ' ";
|
||||
}
|
||||
|
||||
@@ -534,7 +534,7 @@ abstract class pdo_moodle_database extends moodle_database {
|
||||
return $this->execute($sql, $params);
|
||||
}
|
||||
|
||||
public function sql_concat() {
|
||||
public function sql_concat(...$arr) {
|
||||
throw new \moodle_exception('TODO');
|
||||
}
|
||||
|
||||
|
||||
@@ -1508,8 +1508,7 @@ class pgsql_native_moodle_database extends moodle_database {
|
||||
return " $fieldname::real ";
|
||||
}
|
||||
|
||||
public function sql_concat() {
|
||||
$arr = func_get_args();
|
||||
public function sql_concat(...$arr) {
|
||||
$s = implode(' || ', $arr);
|
||||
if ($s === '') {
|
||||
return " '' ";
|
||||
|
||||
@@ -341,11 +341,10 @@ class sqlite3_pdo_moodle_database extends pdo_moodle_database {
|
||||
* Returns the proper SQL to do CONCAT between the elements passed
|
||||
* Can take many parameters
|
||||
*
|
||||
* @param string $element
|
||||
* @param string $elements,...
|
||||
* @return string
|
||||
*/
|
||||
public function sql_concat() {
|
||||
$elements = func_get_args();
|
||||
public function sql_concat(...$elements) {
|
||||
return implode('||', $elements);
|
||||
}
|
||||
|
||||
|
||||
@@ -1447,9 +1447,7 @@ class sqlsrv_native_moodle_database extends moodle_database {
|
||||
return $text;
|
||||
}
|
||||
|
||||
public function sql_concat() {
|
||||
$arr = func_get_args();
|
||||
|
||||
public function sql_concat(...$arr) {
|
||||
foreach ($arr as $key => $ele) {
|
||||
$arr[$key] = $this->sql_cast_to_char($ele);
|
||||
}
|
||||
|
||||
@@ -6443,7 +6443,7 @@ class moodle_database_for_testing extends moodle_database {
|
||||
public function update_record($table, $dataobject, $bulk=false) {}
|
||||
public function set_field_select($table, $newfield, $newvalue, $select, array $params=null) {}
|
||||
public function delete_records_select($table, $select, array $params=null) {}
|
||||
public function sql_concat() {}
|
||||
public function sql_concat(...$arr) {}
|
||||
public function sql_concat_join($separator="' '", $elements=array()) {}
|
||||
public function sql_group_concat(string $field, string $separator = ', ', string $sort = ''): string {
|
||||
return '';
|
||||
|
||||
+2
-2
@@ -326,10 +326,10 @@ abstract class test_moodle_database extends \moodle_database {
|
||||
|
||||
/**
|
||||
* Default implementation, throws Exception
|
||||
* @return string $sql
|
||||
* @return string $arr,...
|
||||
* @throws Exception
|
||||
*/
|
||||
public function sql_concat() {
|
||||
public function sql_concat(...$arr) {
|
||||
throw new Exception("sql_concat() not implemented");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user