-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from kristuff/dev
v0.2
- Loading branch information
Showing
47 changed files
with
490 additions
and
272 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# Changelog | ||
All notable changes to this project will be documented in this file. | ||
|
||
|
||
## [v0.2] - 2020-04-15 | ||
|
||
### Added | ||
- Best support for sub queries filters : when using the WHERE or HAVING clause, the prefix _PATABASE_COLUMN_LITERALL_ in the filter value allows to match with the result of the main query (insead of a non dynamic value). | ||
|
||
### Changed | ||
- **Possible break change** Drop support for php < 7.1 | ||
- **Possible break change** Columns, other than primary key, are now nullable by default when creating a table (constraint 'NULL'). In previous releases, columns other than primary key created without explicit 'NULL' or 'NOT NULL' argument was created with 'NOT NULL' constraint. | ||
- **Possible break change** Removed DatabaseDriver::getVersion() and Datasource::getVersion(). | ||
|
||
|
||
## [v0.1] - 2017-06-30 | ||
|
||
### Initial release | ||
- Support for Sqlite, Mysql, Postgresql | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
<?php | ||
|
||
/* | ||
* ____ _ _ | ||
* | _ \ __ _ | |_ __ _ | |__ __ _ ___ ___ | ||
* | |_) |/ _` || __|/ _` || '_ \ / _` |/ __| / _ \ | ||
* | __/| (_| || |_| (_| || |_) || (_| |\__ \| __/ | ||
* |_| \__,_| \__|\__,_||_.__/ \__,_||___/ \___| | ||
* | ||
* This file is part of Kristuff\Patabase. | ||
* | ||
* (c) Kristuff <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
* | ||
* @version 0.2.0 | ||
* @copyright 2017-2020 Kristuff | ||
*/ | ||
|
||
namespace Kristuff\Patabase; | ||
|
||
/** | ||
* Class Constants | ||
* | ||
* Define api constants | ||
*/ | ||
class Constants | ||
{ | ||
/** | ||
* Define the constant _PATABASE_COLUMN_LITERALL_ to indicate to the clause WHERE or HAVING in sub queries to refer | ||
* to the result of a main query, instead of a non dynamic value | ||
*/ | ||
const COLUMN_LITERALL = '_PATABASE_COLUMN_LITERALL_'; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,21 @@ | ||
<?php | ||
|
||
/* | ||
* ____ _ _ | ||
* | _ \ __ _ | |_ __ _ | |__ __ _ ___ ___ | ||
* | |_) |/ _` || __|/ _` || '_ \ / _` |/ __| / _ \ | ||
* | __/| (_| || |_| (_| || |_) || (_| |\__ \| __/ | ||
* |_| \__,_| \__|\__,_||_.__/ \__,_||___/ \___| | ||
* | ||
* This file is part of Kristuff\Patabase. | ||
* | ||
* (c) Kristuff <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
* | ||
* @version 0.1.0 | ||
* @copyright 2017 Kristuff | ||
* @version 0.2.0 | ||
* @copyright 2017-2020 Kristuff | ||
*/ | ||
|
||
namespace Kristuff\Patabase; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,22 @@ | ||
<?php | ||
|
||
/* | ||
* ____ _ _ | ||
* | _ \ __ _ | |_ __ _ | |__ __ _ ___ ___ | ||
* | |_) |/ _` || __|/ _` || '_ \ / _` |/ __| / _ \ | ||
* | __/| (_| || |_| (_| || |_) || (_| |\__ \| __/ | ||
* |_| \__,_| \__|\__,_||_.__/ \__,_||___/ \___| | ||
* | ||
* This file is part of Kristuff\Patabase. | ||
* | ||
* (c) Kristuff <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
* | ||
* @version 0.1.0 | ||
* @copyright 2017 Kristuff | ||
* @version 0.2.0 | ||
* | ||
* @copyright 2017-2020 Kristuff | ||
*/ | ||
|
||
namespace Kristuff\Patabase; | ||
|
@@ -46,18 +53,6 @@ abstract class Datasource | |
*/ | ||
abstract protected function openConnection(); | ||
|
||
/** | ||
* Get Patabase Version | ||
* | ||
* @access public | ||
* @method static | ||
* @return string format (0.0.0) | ||
*/ | ||
public static function getVersion() | ||
{ | ||
return DatabaseDriver::getVersion(); | ||
} | ||
|
||
/** | ||
* Get the current driver name | ||
* | ||
|
@@ -159,5 +154,4 @@ public function closeConnection() | |
$this->driver = null; | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,22 @@ | ||
<?php | ||
|
||
/* | ||
* ____ _ _ | ||
* | _ \ __ _ | |_ __ _ | |__ __ _ ___ ___ | ||
* | |_) |/ _` || __|/ _` || '_ \ / _` |/ __| / _ \ | ||
* | __/| (_| || |_| (_| || |_) || (_| |\__ \| __/ | ||
* |_| \__,_| \__|\__,_||_.__/ \__,_||___/ \___| | ||
* | ||
* This file is part of Kristuff\Patabase. | ||
* | ||
* (c) Kristuff <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
* | ||
* @version 0.1.0 | ||
* @copyright 2017 Kristuff | ||
* @version 0.2.0 | ||
* | ||
* @copyright 2017-2020 Kristuff | ||
*/ | ||
|
||
namespace Kristuff\Patabase\Driver; | ||
|
@@ -25,15 +32,7 @@ | |
*/ | ||
abstract class DatabaseDriver | ||
{ | ||
/** | ||
* Version | ||
* | ||
* @access protected | ||
* @var string | ||
*/ | ||
protected static $version = "0.1.0"; | ||
|
||
/** | ||
/** | ||
* PDO connection | ||
* | ||
* @access protected | ||
|
@@ -185,17 +184,6 @@ public function __construct(array $settings) | |
$this->driverName = $settings['driver']; | ||
} | ||
|
||
/** | ||
* Get the current version (format: 0.0.0) | ||
* | ||
* @access public | ||
* @return string | ||
*/ | ||
public static function getVersion() | ||
{ | ||
return self::$version; | ||
} | ||
|
||
/** | ||
* Has error | ||
* | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,21 @@ | ||
<?php | ||
|
||
/* | ||
* ____ _ _ | ||
* | _ \ __ _ | |_ __ _ | |__ __ _ ___ ___ | ||
* | |_) |/ _` || __|/ _` || '_ \ / _` |/ __| / _ \ | ||
* | __/| (_| || |_| (_| || |_) || (_| |\__ \| __/ | ||
* |_| \__,_| \__|\__,_||_.__/ \__,_||___/ \___| | ||
* | ||
* This file is part of Kristuff\Patabase. | ||
* | ||
* (c) Kristuff <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
* | ||
* @version 0.1.0 | ||
* @copyright 2017 Kristuff | ||
* @version 0.2.0 | ||
* @copyright 2017-2020 Kristuff | ||
*/ | ||
|
||
namespace Kristuff\Patabase\Driver; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,22 @@ | ||
<?php | ||
|
||
/* | ||
* ____ _ _ | ||
* | _ \ __ _ | |_ __ _ | |__ __ _ ___ ___ | ||
* | |_) |/ _` || __|/ _` || '_ \ / _` |/ __| / _ \ | ||
* | __/| (_| || |_| (_| || |_) || (_| |\__ \| __/ | ||
* |_| \__,_| \__|\__,_||_.__/ \__,_||___/ \___| | ||
* | ||
* This file is part of Kristuff\Patabase. | ||
* | ||
* (c) Kristuff <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
* | ||
* @version 0.1.0 | ||
* @copyright 2017 Kristuff | ||
* @version 0.2.0 | ||
* | ||
* @copyright 2017-2020 Kristuff | ||
*/ | ||
|
||
namespace Kristuff\Patabase\Driver\Mysql; | ||
|
@@ -81,10 +88,9 @@ public function createConnection(array $settings) | |
$charset = !empty($settings['charset']) ? ';charset='.$settings['charset'] : ';charset=utf8'; | ||
$port = !empty($settings['port']) ? ';port='.$settings['port'] : ''; | ||
$dbname = !empty($settings['database']) ? ';dbname='.$settings['database'] : ''; | ||
$dsn = 'mysql:host='.$settings['hostname'] .$port .$dbname .$charset ; | ||
|
||
$this->pdo = new \PDO( | ||
$dsn, | ||
'mysql:host='.$settings['hostname'] .$port .$dbname .$charset, | ||
$settings['username'], | ||
$settings['password'], | ||
array() | ||
|
@@ -123,7 +129,6 @@ public function enableForeignKeys() | |
*/ | ||
public function disableForeignKeys() | ||
{ | ||
// TODO return $this->prepareAndExecuteSql('SET FOREIGN_KEY_CHECKS=0'); | ||
$this->pdo->exec('SET FOREIGN_KEY_CHECKS=0'); | ||
} | ||
|
||
|
@@ -315,8 +320,7 @@ public function sqlCreateTableOptions() | |
*/ | ||
public function sqlRandom($seed = null) | ||
{ | ||
$seed = !empty($seed) ? $seed : ''; | ||
return sprintf('rand(%s)', $seed); | ||
return sprintf('rand(%s)', !empty($seed) ? $seed : ''); | ||
} | ||
|
||
/** | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,21 @@ | ||
<?php | ||
|
||
/* | ||
* ____ _ _ | ||
* | _ \ __ _ | |_ __ _ | |__ __ _ ___ ___ | ||
* | |_) |/ _` || __|/ _` || '_ \ / _` |/ __| / _ \ | ||
* | __/| (_| || |_| (_| || |_) || (_| |\__ \| __/ | ||
* |_| \__,_| \__|\__,_||_.__/ \__,_||___/ \___| | ||
* | ||
* This file is part of Kristuff\Patabase. | ||
* | ||
* (c) Kristuff <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
* | ||
* @version 0.1.0 | ||
* @copyright 2017 Kristuff | ||
* @version 0.2.0 | ||
* @copyright 2017-2020 Kristuff | ||
*/ | ||
|
||
namespace Kristuff\Patabase\Driver\Postgres; | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,21 @@ | ||
<?php | ||
|
||
/* | ||
* ____ _ _ | ||
* | _ \ __ _ | |_ __ _ | |__ __ _ ___ ___ | ||
* | |_) |/ _` || __|/ _` || '_ \ / _` |/ __| / _ \ | ||
* | __/| (_| || |_| (_| || |_) || (_| |\__ \| __/ | ||
* |_| \__,_| \__|\__,_||_.__/ \__,_||___/ \___| | ||
* | ||
* This file is part of Kristuff\Patabase. | ||
* | ||
* (c) Kristuff <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
* | ||
* @version 0.1.0 | ||
* @copyright 2017 Kristuff | ||
* @version 0.2.0 | ||
* @copyright 2017-2020 Kristuff | ||
*/ | ||
|
||
namespace Kristuff\Patabase\Driver; | ||
|
Oops, something went wrong.