Skip to content

Commit

Permalink
Update to PeachySQL dev-master
Browse files Browse the repository at this point in the history
  • Loading branch information
theodorejb committed Oct 23, 2024
1 parent 0b3a293 commit 91d7d1f
Show file tree
Hide file tree
Showing 8 changed files with 27 additions and 37 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class Users extends Entities
If it is necessary to bind parameters in the base query, use `getBaseSelect` instead:

```php
use PeachySQL\QueryBuilder\SqlParams;
use DevTheorem\PeachySQL\QueryBuilder\SqlParams;
// ...
protected function getBaseSelect(QueryOptions $options): SqlParams
{
Expand Down
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@
"require": {
"php": ">=8.1",
"ext-json": "*",
"devtheorem/peachy-sql": "^6.3.1",
"ext-pdo": "*",
"devtheorem/peachy-sql": "dev-master",
"psr/http-message": "^1.1 || ^2.0",
"shrikeh/teapot": "^2.3.1"
"shrikeh/teapot": "^3.0"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^3.64",
Expand Down
4 changes: 2 additions & 2 deletions src/Entities.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

namespace DevTheorem\Phaster;

use PeachySQL\PeachySql;
use PeachySQL\QueryBuilder\SqlParams;
use DevTheorem\PeachySQL\PeachySql;
use DevTheorem\PeachySQL\QueryBuilder\SqlParams;
use Teapot\{HttpException, StatusCode};

abstract class Entities
Expand Down
2 changes: 1 addition & 1 deletion test/DbTestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

namespace DevTheorem\Phaster\Test;

use DevTheorem\PeachySQL\PeachySql;
use DevTheorem\Phaster\Test\src\{LegacyUsers, ModernUsers, Users};
use PeachySQL\PeachySql;
use PHPUnit\Framework\TestCase;

abstract class DbTestCase extends TestCase
Expand Down
18 changes: 11 additions & 7 deletions test/MssqlDbTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

namespace DevTheorem\Phaster\Test;

use DevTheorem\PeachySQL\PeachySql;
use DevTheorem\Phaster\Test\src\App;
use PeachySQL\PeachySql;
use PeachySQL\SqlServer;
use PDO;

/**
* @group mssql
Expand All @@ -17,13 +17,17 @@ public static function dbProvider(): PeachySql
{
if (!self::$db) {
$c = App::$config;
$conn = sqlsrv_connect($c->getSqlsrvServer(), $c->getSqlsrvConnInfo());
$server = $c->getSqlsrvServer();
$username = '';
$password = '';

if (!$conn) {
throw new \Exception('Failed to connect to SQL server: ' . print_r(sqlsrv_errors(), true));
}
$pdo = new PDO("sqlsrv:server=$server", $username, $password, [
PDO::ATTR_EMULATE_PREPARES => false,
PDO::SQLSRV_ATTR_FETCHES_NUMERIC_TYPE => true,
'Database' => 'PeachySQL',
]);

self::$db = new SqlServer($conn);
self::$db = new PeachySql($pdo);
self::createTestTable(self::$db);
}

Expand Down
13 changes: 6 additions & 7 deletions test/MysqlDbTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

namespace DevTheorem\Phaster\Test;

use DevTheorem\PeachySQL\PeachySql;
use DevTheorem\Phaster\Test\src\App;
use PeachySQL\Mysql;
use PeachySQL\PeachySql;
use PDO;

/**
* @group mysql
Expand All @@ -17,13 +17,12 @@ public static function dbProvider(): PeachySql
{
if (!self::$db) {
$c = App::$config;
$conn = new \mysqli($c->getMysqlHost(), $c->getMysqlUser(), $c->getMysqlPassword(), $c->getMysqlDatabase());

if ($conn->connect_error !== null) {
throw new \Exception('Failed to connect to MySQL: ' . $conn->connect_error);
}
$pdo = new PDO($c->getMysqlDsn(), $c->getMysqlUser(), $c->getMysqlPassword(), [
PDO::ATTR_EMULATE_PREPARES => false,
]);

self::$db = new Mysql($conn);
self::$db = new PeachySql($pdo);
self::createTestTable(self::$db);
}

Expand Down
18 changes: 2 additions & 16 deletions test/src/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
*/
class Config
{
public function getMysqlHost(): string
public function getMysqlDsn(): string
{
return '127.0.0.1';
return "mysql:host=127.0.0.1;port=3306;dbname=Phaster";
}

public function getMysqlUser(): string
Expand All @@ -22,22 +22,8 @@ public function getMysqlPassword(): string
return '';
}

public function getMysqlDatabase(): string
{
return 'Phaster';
}

public function getSqlsrvServer(): string
{
return '(local)\SQLEXPRESS';
}

public function getSqlsrvConnInfo(): array
{
return [
'Database' => 'Phaster',
'ReturnDatesAsStrings' => true,
'CharacterSet' => 'UTF-8',
];
}
}
2 changes: 1 addition & 1 deletion test/src/LegacyUsers.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@

namespace DevTheorem\Phaster\Test\src;

use DevTheorem\PeachySQL\QueryBuilder\SqlParams;
use DevTheorem\Phaster\{Entities, QueryOptions};
use PeachySQL\QueryBuilder\SqlParams;

class LegacyUsers extends Entities
{
Expand Down

0 comments on commit 91d7d1f

Please sign in to comment.