Proyectos de Subversion Moodle

Rev

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

Rev 1 Rev 1441
Línea 13... Línea 13...
13
// GNU General Public License for more details.
13
// GNU General Public License for more details.
14
//
14
//
15
// You should have received a copy of the GNU General Public License
15
// You should have received a copy of the GNU General Public License
16
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
16
// along with Moodle.  If not, see <http://www.gnu.org/licenses/>.
Línea -... Línea 17...
-
 
17
 
-
 
18
use core\exception\response_aware_exception;
Línea 17... Línea 19...
17
 
19
use core\router\response\not_found_response;
18
 
20
 
19
/**
21
/**
20
 * This library contains all the Data Manipulation Language (DML) functions
22
 * This library contains all the Data Manipulation Language (DML) functions
21
 * used to interact with the DB
23
 * used to interact with the DB
22
 *
24
 *
23
 * This library contains all the Data Manipulation Language (DML) functions
25
 * This library contains all the Data Manipulation Language (DML) functions
24
 * used to interact with the DB. All the dunctions in this library must be
26
 * used to interact with the DB. All the dunctions in this library must be
25
 * generic and work against the major number of RDBMS possible. This is the
27
 * generic and work against the major number of RDBMS possible. This is the
26
 * list of currently supported and tested DBs: mysql, postresql, mssql, oracle
28
 * list of currently supported and tested DBs: mysql, postresql, and mssql.
27
 *
29
 *
28
 * This library is automatically included by Moodle core so you never need to
30
 * This library is automatically included by Moodle core so you never need to
29
 * include it yourself.
31
 * include it yourself.
Línea 130... Línea 132...
130
     * Constructor
132
     * Constructor
131
     * @param string $error The name of the string from error.php to print.
133
     * @param string $error The name of the string from error.php to print.
132
     * @param string $sql The SQL that ran just before this read error.
134
     * @param string $sql The SQL that ran just before this read error.
133
     * @param array $params The SQL's related parameters.(optional)
135
     * @param array $params The SQL's related parameters.(optional)
134
     */
136
     */
135
    function __construct($error, $sql=null, array $params=null) {
137
    function __construct($error, $sql=null, ?array $params=null) {
136
        $this->error  = $error;
138
        $this->error  = $error;
137
        $this->sql    = $sql;
139
        $this->sql    = $sql;
138
        $this->params = $params;
140
        $this->params = $params;
139
        $errorinfo = $error."\n".$sql."\n[".var_export($params, true).']';
141
        $errorinfo = $error."\n".$sql."\n[".var_export($params, true).']';
140
        parent::__construct('dmlreadexception', NULL, $errorinfo);
142
        parent::__construct('dmlreadexception', NULL, $errorinfo);
Línea 159... Línea 161...
159
    /**
161
    /**
160
     * Constructor
162
     * Constructor
161
     * @param string $sql The SQL that ran just before this read error.
163
     * @param string $sql The SQL that ran just before this read error.
162
     * @param array $params The SQL's related parameters.(optional)
164
     * @param array $params The SQL's related parameters.(optional)
163
     */
165
     */
164
    function __construct($sql='', array $params=null) {
166
    function __construct($sql='', ?array $params=null) {
165
        $errorinfo = $sql."\n[".var_export($params, true).']';
167
        $errorinfo = $sql."\n[".var_export($params, true).']';
166
        parent::__construct('multiplerecordsfound', null, $errorinfo);
168
        parent::__construct('multiplerecordsfound', null, $errorinfo);
167
    }
169
    }
168
}
170
}
Línea 174... Línea 176...
174
 * @category   dml
176
 * @category   dml
175
 * @subpackage dml
177
 * @subpackage dml
176
 * @copyright  2008 Petr Skoda (http://skodak.org)
178
 * @copyright  2008 Petr Skoda (http://skodak.org)
177
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
179
 * @license    http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
178
 */
180
 */
179
class dml_missing_record_exception extends dml_exception {
181
class dml_missing_record_exception extends dml_exception implements response_aware_exception {
180
    /** @var string A table's name.*/
182
    /** @var string A table's name.*/
181
    public $tablename;
183
    public $tablename;
182
    /** @var string An SQL query.*/
184
    /** @var string An SQL query.*/
183
    public $sql;
185
    public $sql;
184
    /** @var array The SQL's parameters.*/
186
    /** @var array The SQL's parameters.*/
Línea 188... Línea 190...
188
     * Constructor
190
     * Constructor
189
     * @param string $tablename The table name if known, '' if unknown.
191
     * @param string $tablename The table name if known, '' if unknown.
190
     * @param string $sql Optional SQL query.
192
     * @param string $sql Optional SQL query.
191
     * @param array $params Optional SQL query's parameters.
193
     * @param array $params Optional SQL query's parameters.
192
     */
194
     */
193
    function __construct($tablename, $sql='', array $params=null) {
195
    function __construct($tablename, $sql='', ?array $params=null) {
-
 
196
        // If the debug is disabled the database information should not be displayed.
194
        if (empty($tablename)) {
197
        if (empty($tablename) || !debugging()) {
195
            $tablename = null;
198
            $tablename = null;
196
        }
199
        }
197
        $this->tablename = $tablename;
200
        $this->tablename = $tablename;
198
        $this->sql       = $sql;
201
        $this->sql       = $sql;
199
        $this->params    = $params;
202
        $this->params    = $params;
Línea 216... Línea 219...
216
                break;
219
                break;
217
        }
220
        }
218
        $errorinfo = $sql."\n[".var_export($params, true).']';
221
        $errorinfo = $sql."\n[".var_export($params, true).']';
219
        parent::__construct($errcode, $tablename, $errorinfo);
222
        parent::__construct($errcode, $tablename, $errorinfo);
220
    }
223
    }
-
 
224
 
-
 
225
    #[\Override]
-
 
226
    public function get_response_classname(): string {
-
 
227
        return not_found_response::class;
-
 
228
    }
221
}
229
}
Línea 222... Línea 230...
222
 
230
 
223
/**
231
/**
224
 * DML write exception - triggered by some SQL syntax errors, etc.
232
 * DML write exception - triggered by some SQL syntax errors, etc.
Línea 241... Línea 249...
241
     * Constructor
249
     * Constructor
242
     * @param string $error The name of the string from error.php to print.
250
     * @param string $error The name of the string from error.php to print.
243
     * @param string $sql The SQL that ran just before this write error.
251
     * @param string $sql The SQL that ran just before this write error.
244
     * @param array $params The SQL's related parameters.(optional)
252
     * @param array $params The SQL's related parameters.(optional)
245
     */
253
     */
246
    function __construct($error, $sql=null, array $params=null) {
254
    function __construct($error, $sql=null, ?array $params=null) {
247
        $this->error  = $error;
255
        $this->error  = $error;
248
        $this->sql    = $sql;
256
        $this->sql    = $sql;
249
        $this->params = $params;
257
        $this->params = $params;
250
        $errorinfo = $error."\n".$sql."\n[".var_export($params, true).']';
258
        $errorinfo = $error."\n".$sql."\n[".var_export($params, true).']';
251
        parent::__construct('dmlwriteexception', NULL, $errorinfo);
259
        parent::__construct('dmlwriteexception', NULL, $errorinfo);
Línea 312... Línea 320...
312
        switch ($CFG->dbtype) {
320
        switch ($CFG->dbtype) {
313
            case 'postgres7' :
321
            case 'postgres7' :
314
                $CFG->dbtype = 'pgsql';
322
                $CFG->dbtype = 'pgsql';
315
                break;
323
                break;
Línea 316... Línea -...
316
 
-
 
317
            case 'oci8po':
-
 
318
                $CFG->dbtype = 'oci';
-
 
319
                break;
-
 
320
 
324
 
321
            case 'mysql' :
325
            case 'mysql' :
322
                $CFG->dbtype = 'mysqli';
326
                $CFG->dbtype = 'mysqli';
323
                break;
327
                break;
324
        }
328
        }