Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
f03c341
[4.x] Remove deprecated and incorrect working quoteNameStr method (#330)
HLeithner Mar 30, 2025
24cdccd
Merge branch '3.x-dev' into 4.x-dev
richard67 May 10, 2025
cf50dda
[4.x] add createQuery to DatabaseInterface (#325)
heelc29 Jun 25, 2025
526a340
Merge branch '3.x-dev' into 4.x-dev
Hackwar Jul 3, 2025
37cbb88
Add PHP 8.4 to CI
Hackwar Jul 3, 2025
85f678d
Merge remote-tracking branch 'origin/4.x-dev' into 4.x-dev
Hackwar Jul 3, 2025
6c7deb3
Update phpstan to v2
Hackwar Jul 3, 2025
94c05f0
Merge branch '3.x-dev' into 4.x-dev
Hackwar Jul 3, 2025
ff9a35a
[4.x] typos (#342)
brianteeman Jul 8, 2025
64af708
composer updates
RobertDeutz Jul 9, 2025
853ffd0
Raise requirements to PHP 8.3, update dependencies
Hackwar Jul 11, 2025
5698194
Update documentation
Hackwar Jul 11, 2025
8a1de00
Remove deprecated interfaces and update QueryInterface
Hackwar Jul 11, 2025
b855c6f
Remove deprecated DatabaseQuery::castAsChar()
Hackwar Jul 11, 2025
d20f06d
Update unittests to phpunit 12
Hackwar Jul 11, 2025
9739b6e
Improvements from phpstan scan
Hackwar Jul 11, 2025
bdaa08b
Cleanup .gitattributes
Hackwar Jul 11, 2025
4add965
Merge branch '3.x-dev' into 4.x-update
Hackwar Jul 11, 2025
e6a3608
Merge branch '3.x-dev' into 4.x-dev
richard67 Jul 11, 2025
ddc5a93
Merge branch '4.x-dev' into 4.x-update
Hackwar Jul 13, 2025
cf27ee7
Updating Github Actions PHP versions
Hackwar Jul 13, 2025
0fa8276
Merge remote-tracking branch 'origin/4.x-update' into 4.x-update
Hackwar Jul 13, 2025
c1c92c8
Updating unittests to phpunit 12 - part 2
Hackwar Jul 13, 2025
7f403c1
Updating unittests to phpunit 12 - part 3
Hackwar Jul 13, 2025
ad1e06e
Adding baseline for phpstan
Hackwar Jul 13, 2025
d6ea03a
Merge pull request #343 from joomla-framework/4.x-update
richard67 Jul 13, 2025
0f7ab98
Merge branch '3.x-dev' into 4.x-dev
richard67 Jul 13, 2025
8e11153
Fix logging tests
Hackwar Jul 13, 2025
d6aa2bf
Revert bc breaks (#344)
rdeutz Jul 16, 2025
557bcc1
Merge branch '3.x-dev' into 4.x-dev
richard67 Jul 19, 2025
2e744e7
Joomla! Framework v4.0.0
Hackwar Jul 24, 2025
860ed8b
Merge branch '3.x-dev' into 4.x-dev-upmerge-2026-02-17
richard67 Feb 17, 2026
ce263fe
Merge pull request #360 from richard67/4.x-dev-upmerge-2026-02-17
richard67 Feb 18, 2026
02c86bd
phpstan should fail ci action
heelc29 Feb 19, 2026
5f202c3
return type should match with class 'DatabaseDriver'
heelc29 Feb 19, 2026
a981167
properties accept null
heelc29 Feb 19, 2026
8a22203
fix phpdoc type
heelc29 Feb 19, 2026
54528bd
clean baseline
heelc29 Feb 19, 2026
60f89b0
update baseline
heelc29 Feb 19, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
composer:
name: Install PHP dependencies
runs-on: ubuntu-latest
container: joomlaprojects/docker-images:php8.1
container: joomlaprojects/docker-images:php8.3
steps:
- uses: actions/checkout@v4
- uses: actions/cache@v4
Expand All @@ -32,7 +32,7 @@ jobs:
code-style-php:
name: Check PHP code style
runs-on: ubuntu-latest
container: joomlaprojects/docker-images:php8.1
container: joomlaprojects/docker-images:php8.3
needs: [composer]
steps:
- uses: actions/checkout@v4
Expand All @@ -50,7 +50,6 @@ jobs:
runs-on: ubuntu-latest
container: joomlaprojects/docker-images:php8.4
needs: [code-style-php]
continue-on-error: true
steps:
- uses: actions/checkout@v4
- uses: actions/cache/restore@v4
Expand All @@ -68,7 +67,7 @@ jobs:
needs: [code-style-php]
strategy:
matrix:
php_version: ['8.1', '8.2', '8.3']
php_version: ['8.3', '8.4']
steps:
- uses: actions/checkout@v4
- name: Run Unit tests
Expand All @@ -84,7 +83,7 @@ jobs:
needs: [code-style-php]
strategy:
matrix:
php_version: ['8.1', '8.2', '8.3']
php_version: ['8.3', '8.4']
db_engine: ['mysql', 'mysqli']
db_version: ['5.7', '8.0']
steps:
Expand All @@ -110,7 +109,7 @@ jobs:
needs: [code-style-php]
strategy:
matrix:
php_version: ['8.1', '8.2', '8.3']
php_version: ['8.3', '8.4']
steps:
- uses: actions/checkout@v4
- name: Run Unit tests
Expand All @@ -134,7 +133,7 @@ jobs:
needs: [code-style-php]
strategy:
matrix:
php_version: ['8.1', '8.2', '8.3']
php_version: ['8.3', '8.4']
db_version: ['10', '11']
steps:
- uses: actions/checkout@v4
Expand All @@ -158,7 +157,7 @@ jobs:
needs: [code-style-php]
strategy:
matrix:
php_version: ['8.1', '8.2', '8.3']
php_version: ['8.3', '8.4']
steps:
- uses: actions/checkout@v4
- name: Run Unit tests
Expand Down Expand Up @@ -190,7 +189,7 @@ jobs:
needs: [code-style-php]
strategy:
matrix:
php_version: ['8.1', '8.2', '8.3']
php_version: ['8.3', '8.4']
steps:
- uses: actions/checkout@v4
- name: Setup PHP
Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ function search($title)

In the first case, the title variable is simply escaped and quoted. Any quote characters in the title string will be prepended with a backslash and the whole string will be wrapped in quotes.

In the second case, the example shows how to treat a search string that will be used in a `LIKE` clause. In this case, the title variable is manually escaped using `escape` with a second argument of `true`. This will force other special characters to be escaped (otherwise you could set youself up for serious performance problems if the user includes too many wildcards). Then, the result is passed to the `quote` method but escaping is turned off (because it has already been done manually).
In the second case, the example shows how to treat a search string that will be used in a `LIKE` clause. In this case, the title variable is manually escaped using `escape` with a second argument of `true`. This will force other special characters to be escaped (otherwise you could set yourself up for serious performance problems if the user includes too many wildcards). Then, the result is passed to the `quote` method but escaping is turned off (because it has already been done manually).

In the third case, the title variable is an array so the whole array can be passed to the `quote` method (this saves using a closure and a )

Expand All @@ -102,7 +102,7 @@ The `Database\DatabaseIterator` class allows iteration over database results
```php
$db = DatabaseDriver::getInstance($options);
$iterator = $db->setQuery(
$db->getQuery(true)->select('*')->from('#__content')
$db->createQuery()->select('*')->from('#__content')
)->getIterator();

foreach ($iterator as $row)
Expand All @@ -118,7 +118,7 @@ $count = count($iterator);
```
## Logging

`Database\DatabaseDriver` implements the `Psr\Log\LoggerAwareInterface` so is ready for intergrating with a logging package that supports that standard.
`Database\DatabaseDriver` implements the `Psr\Log\LoggerAwareInterface` so is ready for integrating with a logging package that supports that standard.

Drivers log all errors with a log level of `LogLevel::ERROR`.

Expand Down Expand Up @@ -173,24 +173,24 @@ This is the log file:

## Installation via Composer

Add `"joomla/database": "~3.0"` to the require block in your composer.json and then run `composer install`.
Add `"joomla/database": "~4.0"` to the require block in your composer.json and then run `composer install`.

```json
{
"require": {
"joomla/database": "~3.0"
"joomla/database": "~4.0"
}
}
```

Alternatively, you can simply run the following from the command line:

```sh
composer require joomla/database "~3.0"
composer require joomla/database "~4.0"
```

If you want to include the test sources, use

```sh
composer require --prefer-source joomla/database "~3.0"
composer require --prefer-source joomla/database "~4.0"
```
3 changes: 2 additions & 1 deletion SECURITY.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
These versions are currently being supported with security updates:

| Version | Supported |
| ------- | ------------------ |
|---------| ------------------ |
| 4.x.x | :white_check_mark: |
| 3.x.x | :white_check_mark: |
| 2.0.x | :white_check_mark: |
| 1.8.x | :x: |
Expand Down
42 changes: 20 additions & 22 deletions Tests/AbstractDatabaseDriverTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use Joomla\Database\ParameterType;
use Joomla\Database\QueryInterface;
use Joomla\Test\DatabaseTestCase;
use PHPUnit\Framework\Attributes\DataProvider;

/**
* Base test class for Joomla\Database\DatabaseDriver
Expand Down Expand Up @@ -72,23 +73,24 @@ public function testIsConnectionEncryptionSupported()
/**
* Data provider for table dropping test cases
*
* @return \Generator
* @return array
*/
public function dataDropTable()
public static function dataDropTable(): array
{
yield 'database exists before query' => ['#__dbtest', true];
return [
'database exists before query' => ['#__dbtest', true],

yield 'database does not exist before query' => ['#__foo', false];
'database does not exist before query' => ['#__foo', false],
];
}

/**
* @testdox A database table can be dropped
*
* @param string $table The name of the database table to drop.
* @param boolean $alreadyExists Flag indicating the table should exist before the DROP TABLE query.
*
* @dataProvider dataDropTable
*/
#[DataProvider('dataDropTable')]
public function testDropTable(string $table, bool $alreadyExists)
{
$this->assertSame(
Expand All @@ -110,19 +112,18 @@ public function testDropTable(string $table, bool $alreadyExists)
/**
* Data provider for escaping test cases
*
* @return \Generator
* @return array
*/
abstract public function dataEscape(): \Generator;
abstract public static function dataEscape(): array;

/**
* @testdox Text can be escaped
*
* @param string $text The string to be escaped.
* @param boolean $extra Optional parameter to provide extra escaping.
* @param string $expected The expected result.
*
* @dataProvider dataEscape
*/
#[DataProvider('dataEscape')]
public function testEscape($text, $extra, $expected)
{
$this->assertSame(
Expand Down Expand Up @@ -240,19 +241,18 @@ public function testGetIterator()
/**
* Data provider for fetching table column test cases
*
* @return \Generator
* @return array
*/
abstract public function dataGetTableColumns(): \Generator;
abstract public static function dataGetTableColumns(): array;

/**
* @testdox Information about the columns of a database table is returned
*
* @param string $table The name of the database table.
* @param boolean $typeOnly True (default) to only return field types.
* @param array $expected Expected result.
*
* @dataProvider dataGetTableColumns
*/
#[DataProvider('dataGetTableColumns')]
public function testGetTableColumns(string $table, bool $typeOnly, array $expected)
{
$this->assertEquals(
Expand Down Expand Up @@ -596,18 +596,17 @@ public function testLockAndUnlockTable()
/**
* Data provider for binary quoting test cases
*
* @return \Generator
* @return array
*/
abstract public function dataQuoteBinary(): \Generator;
abstract public static function dataQuoteBinary(): array;

/**
* @testdox A binary value is quoted properly
*
* @param string $data The binary quoted input string.
* @param string $expected The expected result.
*
* @dataProvider dataQuoteBinary
*/
#[DataProvider('dataQuoteBinary')]
public function testQuoteBinary($data, $expected)
{
$this->assertSame($expected, static::$connection->quoteBinary($data));
Expand All @@ -616,19 +615,18 @@ public function testQuoteBinary($data, $expected)
/**
* Data provider for name quoting test cases
*
* @return \Generator
* @return array
*/
abstract public function dataQuoteName(): \Generator;
abstract public static function dataQuoteName(): array;

/**
* @testdox A value is name quoted properly
*
* @param array|string $name The identifier name to wrap in quotes, or an array of identifier names to wrap in quotes.
* @param array|string $as The AS query part associated to $name.
* @param array|string $expected The expected result.
*
* @dataProvider dataQuoteName
*/
#[DataProvider('dataQuoteName')]
public function testQuoteName($name, $as, $expected)
{
$this->assertSame(
Expand Down
Loading