Proyectos de Subversion Moodle

Rev

Rev 1 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1 Rev 1441
Línea 100... Línea 100...
100
    }
100
    }
Línea 101... Línea 101...
101
 
101
 
102
    /**
102
    /**
103
     * Returns database family type - describes SQL dialect
103
     * Returns database family type - describes SQL dialect
104
     * Note: can be used before connect()
104
     * Note: can be used before connect()
105
     * @return string db family name (mysql, postgres, mssql, sqlsrv, oracle, etc.)
105
     * @return string db family name (mysql, postgres, mssql, sqlsrv, etc.)
106
     */
106
     */
107
    public function get_dbfamily() {
107
    public function get_dbfamily() {
108
        return 'mssql';
108
        return 'mssql';
Línea 109... Línea 109...
109
    }
109
    }
110
 
110
 
111
    /**
111
    /**
112
     * Returns more specific database driver type
112
     * Returns more specific database driver type
113
     * Note: can be used before connect()
113
     * Note: can be used before connect()
114
     * @return string db type mysqli, pgsql, oci, mssql, sqlsrv
114
     * @return string db type mysqli, pgsql, mssql, sqlsrv
115
     */
115
     */
116
    protected function get_dbtype() {
116
    protected function get_dbtype() {
Línea 185... Línea 185...
185
     * @param mixed $prefix string|bool The moodle db table name's prefix. false is used for external databases where prefix not used
185
     * @param mixed $prefix string|bool The moodle db table name's prefix. false is used for external databases where prefix not used
186
     * @param array $dboptions driver specific options
186
     * @param array $dboptions driver specific options
187
     * @return bool true
187
     * @return bool true
188
     * @throws dml_connection_exception if error
188
     * @throws dml_connection_exception if error
189
     */
189
     */
190
    public function connect($dbhost, $dbuser, $dbpass, $dbname, $prefix, array $dboptions=null) {
190
    public function connect($dbhost, $dbuser, $dbpass, $dbname, $prefix, ?array $dboptions=null) {
191
        if ($prefix == '' and !$this->external) {
191
        if ($prefix == '' and !$this->external) {
192
            // Enforce prefixes for everybody but mysql.
192
            // Enforce prefixes for everybody but mysql.
193
            throw new dml_exception('prefixcannotbeempty', $this->get_dbfamily());
193
            throw new dml_exception('prefixcannotbeempty', $this->get_dbfamily());
194
        }
194
        }
Línea 770... Línea 770...
770
    }
770
    }
Línea 771... Línea 771...
771
 
771
 
772
    /**
772
    /**
773
     * Prepare the array of params for native binding
773
     * Prepare the array of params for native binding
774
     */
774
     */
Línea 775... Línea 775...
775
    protected function build_native_bound_params(array $params = null) {
775
    protected function build_native_bound_params(?array $params = null) {
776
 
776
 
Línea 777... Línea 777...
777
        return null;
777
        return null;
778
    }
778
    }
779
 
779
 
780
    /**
780
    /**
781
     * Workaround for SQL*Server Native driver similar to MSSQL driver for
781
     * Workaround for SQL*Server Native driver similar to MSSQL driver for
Línea 782... Línea 782...
782
     * consistent behavior.
782
     * consistent behavior.
783
     */
783
     */
784
    protected function emulate_bound_params($sql, array $params = null) {
784
    protected function emulate_bound_params($sql, ?array $params = null) {
785
 
785
 
Línea 820... Línea 820...
820
     * @param string $sql query
820
     * @param string $sql query
821
     * @param array $params query parameters
821
     * @param array $params query parameters
822
     * @return bool true
822
     * @return bool true
823
     * @throws dml_exception A DML specific exception is thrown for any errors.
823
     * @throws dml_exception A DML specific exception is thrown for any errors.
824
     */
824
     */
825
    public function execute($sql, array $params = null) {
825
    public function execute($sql, ?array $params = null) {
826
        if (strpos($sql, ';') !== false) {
826
        if (strpos($sql, ';') !== false) {
827
            throw new coding_exception('moodle_database::execute() Multiple sql statements found or bound parameters not used properly in query!');
827
            throw new coding_exception('moodle_database::execute() Multiple sql statements found or bound parameters not used properly in query!');
828
        }
828
        }
829
        $this->do_query($sql, $params, SQL_QUERY_UPDATE);
829
        $this->do_query($sql, $params, SQL_QUERY_UPDATE);
830
        return true;
830
        return true;
Línea 869... Línea 869...
869
     * @param int $limitfrom return a subset of records, starting at this point (optional, required if $limitnum is set).
869
     * @param int $limitfrom return a subset of records, starting at this point (optional, required if $limitnum is set).
870
     * @param int $limitnum return a subset comprising this many records (optional, required if $limitfrom is set).
870
     * @param int $limitnum return a subset comprising this many records (optional, required if $limitfrom is set).
871
     * @return moodle_recordset instance
871
     * @return moodle_recordset instance
872
     * @throws dml_exception A DML specific exception is thrown for any errors.
872
     * @throws dml_exception A DML specific exception is thrown for any errors.
873
     */
873
     */
874
    public function get_recordset_sql($sql, array $params = null, $limitfrom = 0, $limitnum = 0) {
874
    public function get_recordset_sql($sql, ?array $params = null, $limitfrom = 0, $limitnum = 0) {
Línea 875... Línea 875...
875
 
875
 
876
        list($limitfrom, $limitnum) = $this->normalise_limit_from_num($limitfrom, $limitnum);
876
        list($limitfrom, $limitnum) = $this->normalise_limit_from_num($limitfrom, $limitnum);
Línea 877... Línea 877...
877
        $needscrollable = (bool)$limitfrom; // To determine if we'll need to perform scroll to $limitfrom.
877
        $needscrollable = (bool)$limitfrom; // To determine if we'll need to perform scroll to $limitfrom.
Línea 978... Línea 978...
978
     * @param int $limitfrom return a subset of records, starting at this point (optional, required if $limitnum is set).
978
     * @param int $limitfrom return a subset of records, starting at this point (optional, required if $limitnum is set).
979
     * @param int $limitnum return a subset comprising this many records (optional, required if $limitfrom is set).
979
     * @param int $limitnum return a subset comprising this many records (optional, required if $limitfrom is set).
980
     * @return array of objects, or empty array if no records were found
980
     * @return array of objects, or empty array if no records were found
981
     * @throws dml_exception A DML specific exception is thrown for any errors.
981
     * @throws dml_exception A DML specific exception is thrown for any errors.
982
     */
982
     */
983
    public function get_records_sql($sql, array $params = null, $limitfrom = 0, $limitnum = 0) {
983
    public function get_records_sql($sql, ?array $params = null, $limitfrom = 0, $limitnum = 0) {
Línea 984... Línea 984...
984
 
984
 
Línea 985... Línea 985...
985
        $rs = $this->get_recordset_sql($sql, $params, $limitfrom, $limitnum);
985
        $rs = $this->get_recordset_sql($sql, $params, $limitfrom, $limitnum);
Línea 1007... Línea 1007...
1007
     * @param string $sql The SQL query
1007
     * @param string $sql The SQL query
1008
     * @param array $params array of sql parameters
1008
     * @param array $params array of sql parameters
1009
     * @return array of values
1009
     * @return array of values
1010
     * @throws dml_exception A DML specific exception is thrown for any errors.
1010
     * @throws dml_exception A DML specific exception is thrown for any errors.
1011
     */
1011
     */
1012
    public function get_fieldset_sql($sql, array $params = null) {
1012
    public function get_fieldset_sql($sql, ?array $params = null) {
Línea 1013... Línea 1013...
1013
 
1013
 
Línea 1014... Línea 1014...
1014
        $rs = $this->get_recordset_sql($sql, $params);
1014
        $rs = $this->get_recordset_sql($sql, $params);
Línea 1265... Línea 1265...
1265
     * @param string $select A fragment of SQL to be used in a where clause in the SQL call.
1265
     * @param string $select A fragment of SQL to be used in a where clause in the SQL call.
1266
     * @param array $params array of sql parameters
1266
     * @param array $params array of sql parameters
1267
     * @return bool true
1267
     * @return bool true
1268
     * @throws dml_exception A DML specific exception is thrown for any errors.
1268
     * @throws dml_exception A DML specific exception is thrown for any errors.
1269
     */
1269
     */
1270
    public function set_field_select($table, $newfield, $newvalue, $select, array $params = null) {
1270
    public function set_field_select($table, $newfield, $newvalue, $select, ?array $params = null) {
1271
        if ($select) {
1271
        if ($select) {
1272
            $select = "WHERE $select";
1272
            $select = "WHERE $select";
1273
        }
1273
        }
Línea 1274... Línea 1274...
1274
 
1274
 
Línea 1305... Línea 1305...
1305
     * @param string $select A fragment of SQL to be used in a where clause in the SQL call (used to define the selection criteria).
1305
     * @param string $select A fragment of SQL to be used in a where clause in the SQL call (used to define the selection criteria).
1306
     * @param array $params array of sql parameters
1306
     * @param array $params array of sql parameters
1307
     * @return bool true
1307
     * @return bool true
1308
     * @throws dml_exception A DML specific exception is thrown for any errors.
1308
     * @throws dml_exception A DML specific exception is thrown for any errors.
1309
     */
1309
     */
1310
    public function delete_records_select($table, $select, array $params = null) {
1310
    public function delete_records_select($table, $select, ?array $params = null) {
1311
        if ($select) {
1311
        if ($select) {
1312
            $select = "WHERE $select";
1312
            $select = "WHERE $select";
1313
        }
1313
        }
Línea 1314... Línea 1314...
1314
 
1314