Skip to content

Commit 6ccc422

Browse files
committed
Use match to qutote identifiers
1 parent 4ae7c5b commit 6ccc422

File tree

3 files changed

+16
-17
lines changed

3 files changed

+16
-17
lines changed

.gitignore

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
.buildpath
2-
.project
3-
.settings
1+
notes.md
42
coverage
53
vendor
64
composer.lock

README.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,20 @@
1-
# Piko DbRecord
1+
# Piko Db Record
22

33
[![build](https://github.com/piko-framework/db-record/actions/workflows/php.yml/badge.svg)](https://github.com/piko-framework/db-record/actions/workflows/php.yml)
44
[![Coverage Status](https://coveralls.io/repos/github/piko-framework/db-record/badge.svg?branch=main)](https://coveralls.io/github/piko-framework/db-record?branch=main)
55

66
Piko Db Record is a lightweight Active Record implementation built on top of PDO.
77

8+
It has been tested and works with the following databases:
9+
10+
- SQLite
11+
- MySQL
12+
- PostgreSQL
13+
- MSSQL
14+
815
## Installation
916

10-
It's recommended that you use Composer to install Piko Db.
17+
It's recommended that you use Composer to install Piko Db Record.
1118

1219
```bash
1320
composer require piko/db-record

src/DbRecord.php

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -96,18 +96,12 @@ public function quoteIdentifier($identifier): string
9696
{
9797
$driver = $this->db->getAttribute(PDO::ATTR_DRIVER_NAME);
9898

99-
switch ($driver) {
100-
case 'mysql':
101-
case 'sqlite':
102-
return '`' . $identifier . '`';
103-
case 'pgsql':
104-
return '"' . $identifier . '"';
105-
case 'sqlsrv':
106-
case 'dblib':
107-
return '[' . $identifier . ']';
108-
default:
109-
return $identifier;
110-
}
99+
return match ($driver) {
100+
'mysql', 'sqlite' => '`' . $identifier . '`',
101+
'pgsql' => '"' . $identifier . '"',
102+
'sqlsrv', 'dblib' => '[' . $identifier . ']',
103+
default => $identifier,
104+
};
111105
}
112106

113107
/**

0 commit comments

Comments
 (0)