• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

codeigniter4 / CodeIgniter4 / 28458540300

30 Jun 2026 04:06PM UTC coverage: 89.181% (+0.01%) from 89.168%
28458540300

Pull #10359

github

web-flow
Merge 12e51280b into 7b7742fd8
Pull Request #10359: feat: add constraint violation database exceptions

42 of 42 new or added lines in 6 files covered. (100.0%)

67 existing lines in 2 files now uncovered.

25092 of 28136 relevant lines covered (89.18%)

226.67 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

70.81
/system/Database/MySQLi/Connection.php
1
<?php
2

3
declare(strict_types=1);
4

5
/**
6
 * This file is part of CodeIgniter 4 framework.
7
 *
8
 * (c) CodeIgniter Foundation <admin@codeigniter.com>
9
 *
10
 * For the full copyright and license information, please view
11
 * the LICENSE file that was distributed with this source code.
12
 */
13

14
namespace CodeIgniter\Database\MySQLi;
15

16
use CodeIgniter\Database\BaseConnection;
17
use CodeIgniter\Database\Exceptions\DatabaseException;
18
use CodeIgniter\Database\TableName;
19
use CodeIgniter\Exceptions\LogicException;
20
use mysqli;
21
use mysqli_result;
22
use mysqli_sql_exception;
23
use stdClass;
24
use Throwable;
25

26
/**
27
 * Connection for MySQLi
28
 *
29
 * @extends BaseConnection<mysqli, mysqli_result>
30
 */
31
class Connection extends BaseConnection
32
{
33
    /**
34
     * Database driver
35
     *
36
     * @var string
37
     */
38
    public $DBDriver = 'MySQLi';
39

40
    /**
41
     * DELETE hack flag
42
     *
43
     * Whether to use the MySQL "delete hack" which allows the number
44
     * of affected rows to be shown. Uses a preg_replace when enabled,
45
     * adding a bit more processing to all queries.
46
     *
47
     * @var bool
48
     */
49
    public $deleteHack = true;
50

51
    /**
52
     * Identifier escape character
53
     *
54
     * @var string
55
     */
56
    public $escapeChar = '`';
57

58
    /**
59
     * MySQLi object
60
     *
61
     * Has to be preserved without being assigned to $connId.
62
     *
63
     * @var false|mysqli
64
     */
65
    public $mysqli;
66

67
    /**
68
     * MySQLi constant
69
     *
70
     * For unbuffered queries use `MYSQLI_USE_RESULT`.
71
     *
72
     * Default mode for buffered queries uses `MYSQLI_STORE_RESULT`.
73
     *
74
     * @var int
75
     */
76
    public $resultMode = MYSQLI_STORE_RESULT;
77

78
    /**
79
     * Use MYSQLI_OPT_INT_AND_FLOAT_NATIVE
80
     *
81
     * @var bool
82
     */
83
    public $numberNative = false;
84

85
    /**
86
     * Use MYSQLI_CLIENT_FOUND_ROWS
87
     *
88
     * Whether affectedRows() should return number of rows found,
89
     * or number of rows changed, after an UPDATE query.
90
     *
91
     * @var bool
92
     */
93
    public $foundRows = false;
94

95
    /**
96
     * Strict SQL mode
97
     */
98
    protected bool $strictOn = false;
99

100
    /**
101
     * Checks whether the native database error represents a unique constraint violation.
102
     */
103
    protected function isUniqueConstraintViolation(int|string $code, string $message): bool
104
    {
105
        // ER_DUP_ENTRY: duplicate key value.
106
        return $code === 1062;
65✔
107
    }
108

109
    /**
110
     * Checks whether the native database error represents a foreign key constraint violation.
111
     */
112
    protected function isForeignKeyConstraintViolation(int|string $code, string $message): bool
113
    {
114
        // ER_ROW_IS_REFERENCED_2, ER_NO_REFERENCED_ROW_2.
115
        return in_array($code, [1451, 1452], true);
29✔
116
    }
117

118
    /**
119
     * Checks whether the native database error represents a NOT NULL constraint violation.
120
     */
121
    protected function isNotNullConstraintViolation(int|string $code, string $message): bool
122
    {
123
        // ER_BAD_NULL_ERROR: column cannot be null.
124
        return $code === 1048;
27✔
125
    }
126

127
    /**
128
     * Checks whether the native database error represents a CHECK constraint violation.
129
     */
130
    protected function isCheckConstraintViolation(int|string $code, string $message): bool
131
    {
132
        // ER_CHECK_CONSTRAINT_VIOLATED: check constraint is violated.
133
        return $code === 3819;
22✔
134
    }
135

136
    /**
137
     * Checks whether the native database code represents a retryable transaction failure.
138
     */
139
    protected function isRetryableTransactionErrorCode(int|string $code): bool
140
    {
141
        // ER_LOCK_DEADLOCK: InnoDB rolls back the full transaction.
142
        return $code === 1213;
21✔
143
    }
144

145
    /**
146
     * Connect to the database.
147
     *
148
     * @return false|mysqli
149
     *
150
     * @throws DatabaseException
151
     */
152
    public function connect(bool $persistent = false)
153
    {
154
        // Do we have a socket path?
155
        if ($this->hostname[0] === '/') {
79✔
UNCOV
156
            $hostname = null;
×
UNCOV
157
            $port     = null;
×
UNCOV
158
            $socket   = $this->hostname;
×
159
        } else {
160
            $hostname = $persistent ? 'p:' . $this->hostname : $this->hostname;
79✔
161
            $port     = empty($this->port) ? null : $this->port;
79✔
162
            $socket   = '';
79✔
163
        }
164

165
        $clientFlags  = ($this->compress === true) ? MYSQLI_CLIENT_COMPRESS : 0;
79✔
166
        $this->mysqli = mysqli_init();
79✔
167

168
        mysqli_report(MYSQLI_REPORT_ALL & ~MYSQLI_REPORT_INDEX);
79✔
169

170
        $this->mysqli->options(MYSQLI_OPT_CONNECT_TIMEOUT, 10);
79✔
171

172
        if ($this->numberNative === true) {
79✔
173
            $this->mysqli->options(MYSQLI_OPT_INT_AND_FLOAT_NATIVE, 1);
1✔
174
        }
175

176
        $initCommands = [];
79✔
177

178
        if ($this->strictOn) {
79✔
179
            $initCommands[] = "sql_mode = CONCAT(@@sql_mode, ',', 'STRICT_ALL_TABLES')";
79✔
180
        } else {
UNCOV
181
            $initCommands[] = "sql_mode = REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(
×
182
                                @@sql_mode,
183
                                'STRICT_ALL_TABLES,', ''),
184
                            ',STRICT_ALL_TABLES', ''),
185
                        'STRICT_ALL_TABLES', ''),
186
                    'STRICT_TRANS_TABLES,', ''),
187
                ',STRICT_TRANS_TABLES', ''),
UNCOV
188
            'STRICT_TRANS_TABLES', '')";
×
189
        }
190

191
        // Set session timezone if configured
192
        $timezoneOffset = $this->getSessionTimezone();
79✔
193
        if ($timezoneOffset !== null) {
79✔
194
            $initCommands[] = "time_zone = '{$timezoneOffset}'";
3✔
195
        }
196

197
        $this->mysqli->options(
79✔
198
            MYSQLI_INIT_COMMAND,
79✔
199
            'SET SESSION ' . implode(', ', $initCommands),
79✔
200
        );
79✔
201

202
        if (is_array($this->encrypt)) {
79✔
UNCOV
203
            $ssl = [];
×
204

UNCOV
205
            if (! empty($this->encrypt['ssl_key'])) {
×
UNCOV
206
                $ssl['key'] = $this->encrypt['ssl_key'];
×
207
            }
UNCOV
208
            if (! empty($this->encrypt['ssl_cert'])) {
×
UNCOV
209
                $ssl['cert'] = $this->encrypt['ssl_cert'];
×
210
            }
UNCOV
211
            if (! empty($this->encrypt['ssl_ca'])) {
×
UNCOV
212
                $ssl['ca'] = $this->encrypt['ssl_ca'];
×
213
            }
UNCOV
214
            if (! empty($this->encrypt['ssl_capath'])) {
×
215
                $ssl['capath'] = $this->encrypt['ssl_capath'];
×
216
            }
UNCOV
217
            if (! empty($this->encrypt['ssl_cipher'])) {
×
218
                $ssl['cipher'] = $this->encrypt['ssl_cipher'];
×
219
            }
220

221
            if ($ssl !== []) {
×
222
                if (isset($this->encrypt['ssl_verify'])) {
×
UNCOV
223
                    if ($this->encrypt['ssl_verify']) {
×
224
                        if (defined('MYSQLI_OPT_SSL_VERIFY_SERVER_CERT')) {
×
225
                            $this->mysqli->options(MYSQLI_OPT_SSL_VERIFY_SERVER_CERT, 1);
×
226
                        }
227
                    }
228
                    // Apparently (when it exists), setting MYSQLI_OPT_SSL_VERIFY_SERVER_CERT
229
                    // to FALSE didn't do anything, so PHP 5.6.16 introduced yet another
230
                    // constant ...
231
                    //
232
                    // https://secure.php.net/ChangeLog-5.php#5.6.16
233
                    // https://bugs.php.net/bug.php?id=68344
234
                    elseif (defined('MYSQLI_CLIENT_SSL_DONT_VERIFY_SERVER_CERT') && version_compare($this->mysqli->client_info, 'mysqlnd 5.6', '>=')) {
×
235
                        $clientFlags += MYSQLI_CLIENT_SSL_DONT_VERIFY_SERVER_CERT;
×
236
                    }
237
                }
238

UNCOV
239
                $this->mysqli->ssl_set(
×
UNCOV
240
                    $ssl['key'] ?? null,
×
UNCOV
241
                    $ssl['cert'] ?? null,
×
UNCOV
242
                    $ssl['ca'] ?? null,
×
UNCOV
243
                    $ssl['capath'] ?? null,
×
244
                    $ssl['cipher'] ?? null,
×
245
                );
×
246
            }
247

UNCOV
248
            $clientFlags += MYSQLI_CLIENT_SSL;
×
249
        }
250

251
        if ($this->foundRows) {
79✔
252
            $clientFlags += MYSQLI_CLIENT_FOUND_ROWS;
1✔
253
        }
254

255
        try {
256
            if ($this->mysqli->real_connect(
79✔
257
                $hostname,
79✔
258
                $this->username,
79✔
259
                $this->password,
79✔
260
                $this->database,
79✔
261
                $port,
79✔
262
                $socket,
79✔
263
                $clientFlags,
79✔
264
            )) {
79✔
265
                if (! $this->mysqli->set_charset($this->charset)) {
79✔
UNCOV
266
                    log_message('error', "Database: Unable to set the configured connection charset ('{$this->charset}').");
×
267

UNCOV
268
                    $this->mysqli->close();
×
269

UNCOV
270
                    if ($this->DBDebug) {
×
UNCOV
271
                        throw new DatabaseException('Unable to set client connection character set: ' . $this->charset);
×
272
                    }
273

UNCOV
274
                    return false;
×
275
                }
276

277
                return $this->mysqli;
79✔
278
            }
279
        } catch (Throwable $e) {
1✔
280
            // Clean sensitive information from errors.
281
            $msg = $e->getMessage();
1✔
282

283
            $msg = str_replace($this->username, '****', $msg);
1✔
284
            $msg = str_replace($this->password, '****', $msg);
1✔
285

286
            throw new DatabaseException($msg, $e->getCode(), $e);
1✔
287
        }
288

UNCOV
289
        return false;
×
290
    }
291

292
    /**
293
     * Close the database connection.
294
     *
295
     * @return void
296
     */
297
    protected function _close()
298
    {
299
        $this->connID->close();
6✔
300
    }
301

302
    /**
303
     * Select a specific database table to use.
304
     */
305
    public function setDatabase(string $databaseName): bool
306
    {
UNCOV
307
        if ($databaseName === '') {
×
UNCOV
308
            $databaseName = $this->database;
×
309
        }
310

UNCOV
311
        if (empty($this->connID)) {
×
UNCOV
312
            $this->initialize();
×
313
        }
314

UNCOV
315
        if ($this->connID->select_db($databaseName)) {
×
UNCOV
316
            $this->database = $databaseName;
×
317

318
            return true;
×
319
        }
320

321
        return false;
×
322
    }
323

324
    /**
325
     * Returns a string containing the version of the database being used.
326
     */
327
    public function getVersion(): string
328
    {
329
        if (isset($this->dataCache['version'])) {
4✔
330
            return $this->dataCache['version'];
3✔
331
        }
332

333
        if (empty($this->mysqli)) {
2✔
334
            $this->initialize();
1✔
335
        }
336

337
        return $this->dataCache['version'] = $this->mysqli->server_info;
2✔
338
    }
339

340
    /**
341
     * Executes the query against the database.
342
     *
343
     * @return false|mysqli_result
344
     */
345
    protected function execute(string $sql)
346
    {
347
        while ($this->connID->more_results()) {
925✔
UNCOV
348
            $this->connID->next_result();
×
UNCOV
349
            if ($res = $this->connID->store_result()) {
×
UNCOV
350
                $res->free();
×
351
            }
352
        }
353

354
        try {
355
            return $this->connID->query($this->prepQuery($sql), $this->resultMode);
925✔
356
        } catch (mysqli_sql_exception $e) {
48✔
357
            log_message('error', "{message}\nin {exFile} on line {exLine}.\n{trace}", [
48✔
358
                'message' => $e->getMessage(),
48✔
359
                'exFile'  => clean_path($e->getFile()),
48✔
360
                'exLine'  => $e->getLine(),
48✔
361
                'trace'   => render_backtrace($e->getTrace()),
48✔
362
            ]);
48✔
363

364
            $exception = $this->createDatabaseException($e->getMessage(), $e->getCode(), $e);
48✔
365

366
            if ($this->DBDebug) {
48✔
367
                throw $exception;
21✔
368
            }
369

370
            $this->lastException = $exception;
27✔
371
        }
372

373
        return false;
27✔
374
    }
375

376
    /**
377
     * Prep the query. If needed, each database adapter can prep the query string
378
     */
379
    protected function prepQuery(string $sql): string
380
    {
381
        // mysqli_affected_rows() returns 0 for "DELETE FROM TABLE" queries. This hack
382
        // modifies the query so that it a proper number of affected rows is returned.
383
        if ($this->deleteHack === true && preg_match('/^\s*DELETE\s+FROM\s+(\S+)\s*$/i', $sql)) {
925✔
384
            return trim($sql) . ' WHERE 1=1';
3✔
385
        }
386

387
        return $sql;
925✔
388
    }
389

390
    /**
391
     * Returns the total number of rows affected by this query.
392
     */
393
    public function affectedRows(): int
394
    {
395
        return $this->connID->affected_rows ?? 0;
63✔
396
    }
397

398
    /**
399
     * Platform-dependant string escape
400
     */
401
    protected function _escapeString(string $str): string
402
    {
403
        if (! $this->connID) {
901✔
UNCOV
404
            $this->initialize();
×
405
        }
406

407
        return $this->connID->real_escape_string($str);
901✔
408
    }
409

410
    /**
411
     * Escape Like String Direct
412
     * There are a few instances where MySQLi queries cannot take the
413
     * additional "ESCAPE x" parameter for specifying the escape character
414
     * in "LIKE" strings, and this handles those directly with a backslash.
415
     *
416
     * @param list<string>|string $str Input string
417
     *
418
     * @return list<string>|string
419
     */
420
    public function escapeLikeStringDirect($str)
421
    {
422
        if (is_array($str)) {
1✔
UNCOV
423
            foreach ($str as $key => $val) {
×
UNCOV
424
                $str[$key] = $this->escapeLikeStringDirect($val);
×
425
            }
426

UNCOV
427
            return $str;
×
428
        }
429

430
        $str = $this->_escapeString($str);
1✔
431

432
        // Escape LIKE condition wildcards
433
        return str_replace(
1✔
434
            [$this->likeEscapeChar, '%', '_'],
1✔
435
            ['\\' . $this->likeEscapeChar, '\\%', '\\_'],
1✔
436
            $str,
1✔
437
        );
1✔
438
    }
439

440
    /**
441
     * Generates the SQL for listing tables in a platform-dependent manner.
442
     * Uses escapeLikeStringDirect().
443
     *
444
     * @param string|null $tableName If $tableName is provided will return only this table if exists.
445
     */
446
    protected function _listTables(bool $prefixLimit = false, ?string $tableName = null): string
447
    {
448
        $sql = 'SHOW TABLES FROM ' . $this->escapeIdentifier($this->database);
844✔
449

450
        if ((string) $tableName !== '') {
844✔
451
            return $sql . ' LIKE ' . $this->escape($tableName);
843✔
452
        }
453

454
        if ($prefixLimit && $this->DBPrefix !== '') {
87✔
UNCOV
455
            return $sql . " LIKE '" . $this->escapeLikeStringDirect($this->DBPrefix) . "%'";
×
456
        }
457

458
        return $sql;
87✔
459
    }
460

461
    /**
462
     * Generates a platform-specific query string so that the column names can be fetched.
463
     *
464
     * @param string|TableName $table
465
     */
466
    protected function _listColumns($table = ''): string
467
    {
468
        $tableName = $this->protectIdentifiers(
13✔
469
            $table,
13✔
470
            true,
13✔
471
            null,
13✔
472
            false,
13✔
473
        );
13✔
474

475
        return 'SHOW COLUMNS FROM ' . $tableName;
13✔
476
    }
477

478
    /**
479
     * Returns an array of objects with field data
480
     *
481
     * @return list<stdClass>
482
     *
483
     * @throws DatabaseException
484
     */
485
    protected function _fieldData(string $table): array
486
    {
487
        $table = $this->protectIdentifiers($table, true, null, false);
16✔
488

489
        if (($query = $this->query('SHOW COLUMNS FROM ' . $table)) === false) {
16✔
UNCOV
490
            throw new DatabaseException(lang('Database.failGetFieldData'));
×
491
        }
492
        $query = $query->getResultObject();
16✔
493

494
        $retVal = [];
16✔
495

496
        for ($i = 0, $c = count($query); $i < $c; $i++) {
16✔
497
            $retVal[$i]       = new stdClass();
16✔
498
            $retVal[$i]->name = $query[$i]->Field;
16✔
499

500
            sscanf($query[$i]->Type, '%[a-z](%d)', $retVal[$i]->type, $retVal[$i]->max_length);
16✔
501

502
            $retVal[$i]->nullable    = $query[$i]->Null === 'YES';
16✔
503
            $retVal[$i]->default     = $query[$i]->Default;
16✔
504
            $retVal[$i]->primary_key = (int) ($query[$i]->Key === 'PRI');
16✔
505
        }
506

507
        return $retVal;
16✔
508
    }
509

510
    /**
511
     * Returns an array of objects with index data
512
     *
513
     * @return array<string, stdClass>
514
     *
515
     * @throws DatabaseException
516
     * @throws LogicException
517
     */
518
    protected function _indexData(string $table): array
519
    {
520
        $table = $this->protectIdentifiers($table, true, null, false);
8✔
521

522
        if (($query = $this->query('SHOW INDEX FROM ' . $table)) === false) {
8✔
UNCOV
523
            throw new DatabaseException(lang('Database.failGetIndexData'));
×
524
        }
525

526
        $indexes = $query->getResultArray();
8✔
527

528
        if ($indexes === []) {
8✔
529
            return [];
3✔
530
        }
531

532
        $keys = [];
7✔
533

534
        foreach ($indexes as $index) {
7✔
535
            if (empty($keys[$index['Key_name']])) {
7✔
536
                $keys[$index['Key_name']]       = new stdClass();
7✔
537
                $keys[$index['Key_name']]->name = $index['Key_name'];
7✔
538

539
                if ($index['Key_name'] === 'PRIMARY') {
7✔
540
                    $type = 'PRIMARY';
5✔
541
                } elseif ($index['Index_type'] === 'FULLTEXT') {
5✔
UNCOV
542
                    $type = 'FULLTEXT';
×
543
                } elseif ($index['Non_unique']) {
5✔
544
                    $type = $index['Index_type'] === 'SPATIAL' ? 'SPATIAL' : 'INDEX';
5✔
545
                } else {
546
                    $type = 'UNIQUE';
3✔
547
                }
548

549
                $keys[$index['Key_name']]->type = $type;
7✔
550
            }
551

552
            $keys[$index['Key_name']]->fields[] = $index['Column_name'];
7✔
553
        }
554

555
        return $keys;
7✔
556
    }
557

558
    /**
559
     * Returns an array of objects with Foreign key data
560
     *
561
     * @return array<string, stdClass>
562
     *
563
     * @throws DatabaseException
564
     */
565
    protected function _foreignKeyData(string $table): array
566
    {
567
        $sql = '
6✔
568
                SELECT
569
                    tc.CONSTRAINT_NAME,
570
                    tc.TABLE_NAME,
571
                    kcu.COLUMN_NAME,
572
                    rc.REFERENCED_TABLE_NAME,
573
                    kcu.REFERENCED_COLUMN_NAME,
574
                    rc.DELETE_RULE,
575
                    rc.UPDATE_RULE,
576
                    rc.MATCH_OPTION
577
                FROM information_schema.table_constraints AS tc
578
                INNER JOIN information_schema.referential_constraints AS rc
579
                    ON tc.constraint_name = rc.constraint_name
580
                    AND tc.constraint_schema = rc.constraint_schema
581
                INNER JOIN information_schema.key_column_usage AS kcu
582
                    ON tc.constraint_name = kcu.constraint_name
583
                    AND tc.constraint_schema = kcu.constraint_schema
584
                WHERE
585
                    tc.constraint_type = ' . $this->escape('FOREIGN KEY') . ' AND
6✔
586
                    tc.table_schema = ' . $this->escape($this->database) . ' AND
6✔
587
                    tc.table_name = ' . $this->escape($table);
6✔
588

589
        if (($query = $this->query($sql)) === false) {
6✔
UNCOV
590
            throw new DatabaseException(lang('Database.failGetForeignKeyData'));
×
591
        }
592

593
        $query   = $query->getResultObject();
6✔
594
        $indexes = [];
6✔
595

596
        foreach ($query as $row) {
6✔
597
            $indexes[$row->CONSTRAINT_NAME]['constraint_name']       = $row->CONSTRAINT_NAME;
5✔
598
            $indexes[$row->CONSTRAINT_NAME]['table_name']            = $row->TABLE_NAME;
5✔
599
            $indexes[$row->CONSTRAINT_NAME]['column_name'][]         = $row->COLUMN_NAME;
5✔
600
            $indexes[$row->CONSTRAINT_NAME]['foreign_table_name']    = $row->REFERENCED_TABLE_NAME;
5✔
601
            $indexes[$row->CONSTRAINT_NAME]['foreign_column_name'][] = $row->REFERENCED_COLUMN_NAME;
5✔
602
            $indexes[$row->CONSTRAINT_NAME]['on_delete']             = $row->DELETE_RULE;
5✔
603
            $indexes[$row->CONSTRAINT_NAME]['on_update']             = $row->UPDATE_RULE;
5✔
604
            $indexes[$row->CONSTRAINT_NAME]['match']                 = $row->MATCH_OPTION;
5✔
605
        }
606

607
        return $this->foreignKeyDataToObjects($indexes);
6✔
608
    }
609

610
    /**
611
     * Returns platform-specific SQL to disable foreign key checks.
612
     *
613
     * @return string
614
     */
615
    protected function _disableForeignKeyChecks()
616
    {
617
        return 'SET FOREIGN_KEY_CHECKS=0';
849✔
618
    }
619

620
    /**
621
     * Returns platform-specific SQL to enable foreign key checks.
622
     *
623
     * @return string
624
     */
625
    protected function _enableForeignKeyChecks()
626
    {
627
        return 'SET FOREIGN_KEY_CHECKS=1';
849✔
628
    }
629

630
    /**
631
     * Returns the last error code and message.
632
     * Must return this format: ['code' => string|int, 'message' => string]
633
     * intval(code) === 0 means "no error".
634
     *
635
     * @return array{code: int|string|null, message: string|null}
636
     */
637
    public function error(): array
638
    {
639
        if (! empty($this->mysqli->connect_errno)) {
3✔
UNCOV
640
            return [
×
UNCOV
641
                'code'    => $this->mysqli->connect_errno,
×
UNCOV
642
                'message' => $this->mysqli->connect_error,
×
UNCOV
643
            ];
×
644
        }
645

646
        return [
3✔
647
            'code'    => $this->connID->errno,
3✔
648
            'message' => $this->connID->error,
3✔
649
        ];
3✔
650
    }
651

652
    /**
653
     * Insert ID
654
     */
655
    public function insertID(): int
656
    {
657
        return $this->connID->insert_id;
89✔
658
    }
659

660
    /**
661
     * Begin Transaction
662
     */
663
    protected function _transBegin(): bool
664
    {
665
        return $this->connID->begin_transaction();
58✔
666
    }
667

668
    /**
669
     * Commit Transaction
670
     */
671
    protected function _transCommit(): bool
672
    {
673
        return $this->connID->commit();
21✔
674
    }
675

676
    /**
677
     * Rollback Transaction
678
     */
679
    protected function _transRollback(): bool
680
    {
681
        return $this->connID->rollback();
46✔
682
    }
683
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc