| Línea 57... |
Línea 57... |
| 57 |
* @param string $dbname The name of the database being connected to.
|
57 |
* @param string $dbname The name of the database being connected to.
|
| 58 |
* @param mixed $prefix string means moodle db prefix, false used for external databases where prefix not used
|
58 |
* @param mixed $prefix string means moodle db prefix, false used for external databases where prefix not used
|
| 59 |
* @param array $dboptions driver specific options
|
59 |
* @param array $dboptions driver specific options
|
| 60 |
* @return bool success
|
60 |
* @return bool success
|
| 61 |
*/
|
61 |
*/
|
| 62 |
public function connect($dbhost, $dbuser, $dbpass, $dbname, $prefix, array $dboptions=null) {
|
62 |
public function connect($dbhost, $dbuser, $dbpass, $dbname, $prefix, ?array $dboptions=null) {
|
| 63 |
$driverstatus = $this->driver_installed();
|
63 |
$driverstatus = $this->driver_installed();
|
| Línea 64... |
Línea 64... |
| 64 |
|
64 |
|
| 65 |
if ($driverstatus !== true) {
|
65 |
if ($driverstatus !== true) {
|
| 66 |
throw new dml_exception('dbdriverproblem', $driverstatus);
|
66 |
throw new dml_exception('dbdriverproblem', $driverstatus);
|
| Línea 203... |
Línea 203... |
| 203 |
|
203 |
|
| 204 |
$this->reset_caches($tablenames);
|
204 |
$this->reset_caches($tablenames);
|
| 205 |
return true;
|
205 |
return true;
|
| Línea 206... |
Línea 206... |
| 206 |
}
|
206 |
}
|
| 207 |
|
207 |
|
| 208 |
public function delete_records_select($table, $select, array $params=null) {
|
208 |
public function delete_records_select($table, $select, ?array $params=null) {
|
| 209 |
$sql = "DELETE FROM {{$table}}";
|
209 |
$sql = "DELETE FROM {{$table}}";
|
| 210 |
if ($select) {
|
210 |
if ($select) {
|
| 211 |
$sql .= " WHERE $select";
|
211 |
$sql .= " WHERE $select";
|
| Línea 229... |
Línea 229... |
| 229 |
* Do NOT use this to make changes in db structure, use database_manager methods instead!
|
229 |
* Do NOT use this to make changes in db structure, use database_manager methods instead!
|
| 230 |
* @param string $sql query
|
230 |
* @param string $sql query
|
| 231 |
* @param array $params query parameters
|
231 |
* @param array $params query parameters
|
| 232 |
* @return bool success
|
232 |
* @return bool success
|
| 233 |
*/
|
233 |
*/
|
| 234 |
public function execute($sql, array $params=null) {
|
234 |
public function execute($sql, ?array $params=null) {
|
| 235 |
list($sql, $params, $type) = $this->fix_sql_params($sql, $params);
|
235 |
list($sql, $params, $type) = $this->fix_sql_params($sql, $params);
|
| Línea 236... |
Línea 236... |
| 236 |
|
236 |
|
| 237 |
$result = true;
|
237 |
$result = true;
|
| Línea 262... |
Línea 262... |
| 262 |
* @param array $params array of sql parameters
|
262 |
* @param array $params array of sql parameters
|
| 263 |
* @param int $limitfrom return a subset of records, starting at this point (optional, required if $limitnum is set).
|
263 |
* @param int $limitfrom return a subset of records, starting at this point (optional, required if $limitnum is set).
|
| 264 |
* @param int $limitnum return a subset comprising this many records (optional, required if $limitfrom is set).
|
264 |
* @param int $limitnum return a subset comprising this many records (optional, required if $limitfrom is set).
|
| 265 |
* @return moodle_recordset instance
|
265 |
* @return moodle_recordset instance
|
| 266 |
*/
|
266 |
*/
|
| 267 |
public function get_recordset_sql($sql, array $params=null, $limitfrom=0, $limitnum=0) {
|
267 |
public function get_recordset_sql($sql, ?array $params=null, $limitfrom=0, $limitnum=0) {
|
| Línea 268... |
Línea 268... |
| 268 |
|
268 |
|
| Línea 269... |
Línea 269... |
| 269 |
$result = true;
|
269 |
$result = true;
|
| 270 |
|
270 |
|
| Línea 290... |
Línea 290... |
| 290 |
*
|
290 |
*
|
| 291 |
* @param string $sql The SQL query
|
291 |
* @param string $sql The SQL query
|
| 292 |
* @param array $params array of sql parameters
|
292 |
* @param array $params array of sql parameters
|
| 293 |
* @return array of values
|
293 |
* @return array of values
|
| 294 |
*/
|
294 |
*/
|
| 295 |
public function get_fieldset_sql($sql, array $params=null) {
|
295 |
public function get_fieldset_sql($sql, ?array $params=null) {
|
| 296 |
$rs = $this->get_recordset_sql($sql, $params);
|
296 |
$rs = $this->get_recordset_sql($sql, $params);
|
| 297 |
if (!$rs->valid()) {
|
297 |
if (!$rs->valid()) {
|
| 298 |
$rs->close(); // Not going to iterate (but exit), close rs
|
298 |
$rs->close(); // Not going to iterate (but exit), close rs
|
| 299 |
return false;
|
299 |
return false;
|
| 300 |
}
|
300 |
}
|
| Línea 318... |
Línea 318... |
| 318 |
* @param array $params array of sql parameters
|
318 |
* @param array $params array of sql parameters
|
| 319 |
* @param int $limitfrom return a subset of records, starting at this point (optional, required if $limitnum is set).
|
319 |
* @param int $limitfrom return a subset of records, starting at this point (optional, required if $limitnum is set).
|
| 320 |
* @param int $limitnum return a subset comprising this many records (optional, required if $limitfrom is set).
|
320 |
* @param int $limitnum return a subset comprising this many records (optional, required if $limitfrom is set).
|
| 321 |
* @return array of objects, or empty array if no records were found, or false if an error occurred.
|
321 |
* @return array of objects, or empty array if no records were found, or false if an error occurred.
|
| 322 |
*/
|
322 |
*/
|
| 323 |
public function get_records_sql($sql, array $params=null, $limitfrom=0, $limitnum=0) {
|
323 |
public function get_records_sql($sql, ?array $params=null, $limitfrom=0, $limitnum=0) {
|
| 324 |
global $CFG;
|
324 |
global $CFG;
|
| Línea 325... |
Línea 325... |
| 325 |
|
325 |
|
| 326 |
$rs = $this->get_recordset_sql($sql, $params, $limitfrom, $limitnum);
|
326 |
$rs = $this->get_recordset_sql($sql, $params, $limitfrom, $limitnum);
|
| 327 |
if (!$rs->valid()) {
|
327 |
if (!$rs->valid()) {
|
| Línea 497... |
Línea 497... |
| 497 |
* @param string $newvalue the value to set the field to.
|
497 |
* @param string $newvalue the value to set the field to.
|
| 498 |
* @param string $select A fragment of SQL to be used in a where clause in the SQL call.
|
498 |
* @param string $select A fragment of SQL to be used in a where clause in the SQL call.
|
| 499 |
* @param array $params array of sql parameters
|
499 |
* @param array $params array of sql parameters
|
| 500 |
* @return bool success
|
500 |
* @return bool success
|
| 501 |
*/
|
501 |
*/
|
| 502 |
public function set_field_select($table, $newfield, $newvalue, $select, array $params=null) {
|
502 |
public function set_field_select($table, $newfield, $newvalue, $select, ?array $params=null) {
|
| 503 |
if ($select) {
|
503 |
if ($select) {
|
| 504 |
$select = "WHERE $select";
|
504 |
$select = "WHERE $select";
|
| 505 |
}
|
505 |
}
|
| 506 |
if (is_null($params)) {
|
506 |
if (is_null($params)) {
|
| 507 |
$params = array();
|
507 |
$params = array();
|