@@ -12,54 +12,54 @@ |
||
| 12 | 12 | use EmmetBlue\Core\Database\Abstraction\InsertQueryBuilder; |
| 13 | 13 | |
| 14 | 14 | /** |
| 15 | - * class QueryBuilderTest. |
|
| 16 | - * |
|
| 17 | - * @author Samuel Adeshina <[email protected]> |
|
| 18 | - * |
|
| 19 | - * @since v0.0.1 27/05/2016 14:27 |
|
| 20 | - */ |
|
| 15 | + * class QueryBuilderTest. |
|
| 16 | + * |
|
| 17 | + * @author Samuel Adeshina <[email protected]> |
|
| 18 | + * |
|
| 19 | + * @since v0.0.1 27/05/2016 14:27 |
|
| 20 | + */ |
|
| 21 | 21 | class InsertQueryBuilderTest extends \PHPUnit_Framework_TestCase |
| 22 | 22 | { |
| 23 | - public function testInsertBuilderWithOnlyConstructorParameter() |
|
| 24 | - { |
|
| 25 | - $queryBuilder = new InsertQueryBuilder('tbl_name'); |
|
| 23 | + public function testInsertBuilderWithOnlyConstructorParameter() |
|
| 24 | + { |
|
| 25 | + $queryBuilder = new InsertQueryBuilder('tbl_name'); |
|
| 26 | 26 | |
| 27 | - $builtQuery = (string) $queryBuilder; |
|
| 28 | - $expectedQuery = 'INSERT INTO tbl_name'; |
|
| 27 | + $builtQuery = (string) $queryBuilder; |
|
| 28 | + $expectedQuery = 'INSERT INTO tbl_name'; |
|
| 29 | 29 | |
| 30 | - $this->assertEquals($expectedQuery, $builtQuery); |
|
| 31 | - } |
|
| 30 | + $this->assertEquals($expectedQuery, $builtQuery); |
|
| 31 | + } |
|
| 32 | 32 | |
| 33 | - public function testInsertBuilderWithIntoMethod() |
|
| 34 | - { |
|
| 35 | - $queryBuilder = new InsertQueryBuilder(); |
|
| 36 | - $queryBuilder = $queryBuilder->into('tbl_name'); |
|
| 33 | + public function testInsertBuilderWithIntoMethod() |
|
| 34 | + { |
|
| 35 | + $queryBuilder = new InsertQueryBuilder(); |
|
| 36 | + $queryBuilder = $queryBuilder->into('tbl_name'); |
|
| 37 | 37 | |
| 38 | - $builtQuery = (string) $queryBuilder; |
|
| 39 | - $expectedQuery = 'INSERT INTO tbl_name'; |
|
| 38 | + $builtQuery = (string) $queryBuilder; |
|
| 39 | + $expectedQuery = 'INSERT INTO tbl_name'; |
|
| 40 | 40 | |
| 41 | - $this->assertEquals($expectedQuery, $builtQuery); |
|
| 42 | - } |
|
| 41 | + $this->assertEquals($expectedQuery, $builtQuery); |
|
| 42 | + } |
|
| 43 | 43 | |
| 44 | - public function testInsertBuilderWithIntoAndTableColumnsMethod() |
|
| 45 | - { |
|
| 46 | - $queryBuilder = new InsertQueryBuilder(); |
|
| 47 | - $queryBuilder = $queryBuilder->into('tbl_name', ['tbl_col1', 'tbl_col2']); |
|
| 44 | + public function testInsertBuilderWithIntoAndTableColumnsMethod() |
|
| 45 | + { |
|
| 46 | + $queryBuilder = new InsertQueryBuilder(); |
|
| 47 | + $queryBuilder = $queryBuilder->into('tbl_name', ['tbl_col1', 'tbl_col2']); |
|
| 48 | 48 | |
| 49 | - $builtQuery = (string) $queryBuilder; |
|
| 50 | - $expectedQuery = 'INSERT INTO tbl_name(tbl_col1,tbl_col2)'; |
|
| 49 | + $builtQuery = (string) $queryBuilder; |
|
| 50 | + $expectedQuery = 'INSERT INTO tbl_name(tbl_col1,tbl_col2)'; |
|
| 51 | 51 | |
| 52 | - $this->assertEquals($expectedQuery, $builtQuery); |
|
| 53 | - } |
|
| 52 | + $this->assertEquals($expectedQuery, $builtQuery); |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | - public function testInsertBuilderWithConstructorParameterAndValuesKeyword() |
|
| 56 | - { |
|
| 57 | - $queryBuilder = new InsertQueryBuilder('tbl_name'); |
|
| 58 | - $queryBuilder = $queryBuilder->values(['tbl_col_val1', 'tbl_col_val2']); |
|
| 55 | + public function testInsertBuilderWithConstructorParameterAndValuesKeyword() |
|
| 56 | + { |
|
| 57 | + $queryBuilder = new InsertQueryBuilder('tbl_name'); |
|
| 58 | + $queryBuilder = $queryBuilder->values(['tbl_col_val1', 'tbl_col_val2']); |
|
| 59 | 59 | |
| 60 | - $expectedQuery = 'INSERT INTO tbl_name VALUES (tbl_col_val1,tbl_col_val2)'; |
|
| 61 | - $builtQuery = (string) $queryBuilder; |
|
| 60 | + $expectedQuery = 'INSERT INTO tbl_name VALUES (tbl_col_val1,tbl_col_val2)'; |
|
| 61 | + $builtQuery = (string) $queryBuilder; |
|
| 62 | 62 | |
| 63 | - $this->assertEquals($expectedQuery, $builtQuery); |
|
| 64 | - } |
|
| 63 | + $this->assertEquals($expectedQuery, $builtQuery); |
|
| 64 | + } |
|
| 65 | 65 | } |
@@ -11,27 +11,27 @@ |
||
| 11 | 11 | use EmmetBlue\Core\Database\Abstraction\QueryBuilder; |
| 12 | 12 | |
| 13 | 13 | /** |
| 14 | - * class QueryBuilderTest. |
|
| 15 | - * |
|
| 16 | - * @author Samuel Adeshina <[email protected]> |
|
| 17 | - * |
|
| 18 | - * @since v0.0.1 27/05/2016 14:27 |
|
| 19 | - */ |
|
| 14 | + * class QueryBuilderTest. |
|
| 15 | + * |
|
| 16 | + * @author Samuel Adeshina <[email protected]> |
|
| 17 | + * |
|
| 18 | + * @since v0.0.1 27/05/2016 14:27 |
|
| 19 | + */ |
|
| 20 | 20 | class QueryBuilderTest extends \PHPUnit_Framework_TestCase |
| 21 | 21 | { |
| 22 | - public function testBuilderActuallyBuilding() |
|
| 23 | - { |
|
| 24 | - $queryBuilder = new QueryBuilder('INSERT INTO tbl_name'); |
|
| 25 | - $queryBuilder = $queryBuilder->build("VALUES ('tbl_col1', 'tbl_col2')"); |
|
| 22 | + public function testBuilderActuallyBuilding() |
|
| 23 | + { |
|
| 24 | + $queryBuilder = new QueryBuilder('INSERT INTO tbl_name'); |
|
| 25 | + $queryBuilder = $queryBuilder->build("VALUES ('tbl_col1', 'tbl_col2')"); |
|
| 26 | 26 | |
| 27 | - $builtQuery = (string) $queryBuilder; |
|
| 28 | - $expectedQuery = "INSERT INTO tbl_name VALUES ('tbl_col1', 'tbl_col2')"; |
|
| 27 | + $builtQuery = (string) $queryBuilder; |
|
| 28 | + $expectedQuery = "INSERT INTO tbl_name VALUES ('tbl_col1', 'tbl_col2')"; |
|
| 29 | 29 | |
| 30 | - $this->assertEquals($expectedQuery, $builtQuery); |
|
| 31 | - } |
|
| 30 | + $this->assertEquals($expectedQuery, $builtQuery); |
|
| 31 | + } |
|
| 32 | 32 | |
| 33 | - public function testWrapStringFunctionBehavesStatically() |
|
| 34 | - { |
|
| 35 | - $built = QueryBuilder::wrapString('Name', "'"); |
|
| 36 | - } |
|
| 33 | + public function testWrapStringFunctionBehavesStatically() |
|
| 34 | + { |
|
| 35 | + $built = QueryBuilder::wrapString('Name', "'"); |
|
| 36 | + } |
|
| 37 | 37 | } |
@@ -1,4 +1,4 @@ discard block |
||
| 1 | -<?php declare(strict_types=1); |
|
| 1 | +<?php declare(strict_types = 1); |
|
| 2 | 2 | /** |
| 3 | 3 | * @license MIT |
| 4 | 4 | * @author Samuel Adeshina <[email protected]> |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | * @throws \EmmetBlue\Core\Exception\SQLException |
| 61 | 61 | * @return void |
| 62 | 62 | */ |
| 63 | - public function connect(string $username, string $password="") |
|
| 63 | + public function connect(string $username, string $password = "") |
|
| 64 | 64 | { |
| 65 | 65 | $server = $this->dsn[0]; |
| 66 | 66 | $database = $this->dsn[1]; |
@@ -21,110 +21,110 @@ |
||
| 21 | 21 | */ |
| 22 | 22 | class SQlServer implements ConnectableInterface |
| 23 | 23 | { |
| 24 | - /** |
|
| 25 | - * @var string $dsn |
|
| 26 | - */ |
|
| 27 | - protected $dsn; |
|
| 24 | + /** |
|
| 25 | + * @var string $dsn |
|
| 26 | + */ |
|
| 27 | + protected $dsn; |
|
| 28 | 28 | |
| 29 | - /** |
|
| 30 | - * @var \PDO $connectionObject |
|
| 31 | - */ |
|
| 32 | - protected $connectionObject; |
|
| 29 | + /** |
|
| 30 | + * @var \PDO $connectionObject |
|
| 31 | + */ |
|
| 32 | + protected $connectionObject; |
|
| 33 | 33 | |
| 34 | - /** |
|
| 35 | - * @var array loginData |
|
| 36 | - */ |
|
| 37 | - private $loginData = []; |
|
| 34 | + /** |
|
| 35 | + * @var array loginData |
|
| 36 | + */ |
|
| 37 | + private $loginData = []; |
|
| 38 | 38 | |
| 39 | - /** |
|
| 40 | - * Setter for the DSN string {@see $dsn} |
|
| 41 | - * |
|
| 42 | - * MSSQl Server DSN Structure: sqlsrv:Server={srv};Database={db}" |
|
| 43 | - * `$dsnArray[0] = {srv}` |
|
| 44 | - * `$dsnArray[1] = {db}` |
|
| 45 | - * Attributes = [2 - infinity] |
|
| 46 | - * |
|
| 47 | - * @param array $dsnArray |
|
| 48 | - * @return void |
|
| 49 | - */ |
|
| 50 | - public function setDsn(array $dsnArray) |
|
| 51 | - { |
|
| 52 | - $this->dsn = $dsnArray; |
|
| 53 | - } |
|
| 39 | + /** |
|
| 40 | + * Setter for the DSN string {@see $dsn} |
|
| 41 | + * |
|
| 42 | + * MSSQl Server DSN Structure: sqlsrv:Server={srv};Database={db}" |
|
| 43 | + * `$dsnArray[0] = {srv}` |
|
| 44 | + * `$dsnArray[1] = {db}` |
|
| 45 | + * Attributes = [2 - infinity] |
|
| 46 | + * |
|
| 47 | + * @param array $dsnArray |
|
| 48 | + * @return void |
|
| 49 | + */ |
|
| 50 | + public function setDsn(array $dsnArray) |
|
| 51 | + { |
|
| 52 | + $this->dsn = $dsnArray; |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | - /** |
|
| 56 | - * Establishes connection |
|
| 57 | - * |
|
| 58 | - * @param string $username |
|
| 59 | - * @param string $password optional |
|
| 60 | - * @throws \EmmetBlue\Core\Exception\SQLException |
|
| 61 | - * @return void |
|
| 62 | - */ |
|
| 63 | - public function connect(string $username, string $password="") |
|
| 64 | - { |
|
| 65 | - $server = $this->dsn[0]; |
|
| 66 | - $database = $this->dsn[1]; |
|
| 55 | + /** |
|
| 56 | + * Establishes connection |
|
| 57 | + * |
|
| 58 | + * @param string $username |
|
| 59 | + * @param string $password optional |
|
| 60 | + * @throws \EmmetBlue\Core\Exception\SQLException |
|
| 61 | + * @return void |
|
| 62 | + */ |
|
| 63 | + public function connect(string $username, string $password="") |
|
| 64 | + { |
|
| 65 | + $server = $this->dsn[0]; |
|
| 66 | + $database = $this->dsn[1]; |
|
| 67 | 67 | |
| 68 | - $this->loginData['username'] = $username; |
|
| 69 | - $this->loginData['password'] = $password; |
|
| 68 | + $this->loginData['username'] = $username; |
|
| 69 | + $this->loginData['password'] = $password; |
|
| 70 | 70 | |
| 71 | - try |
|
| 72 | - { |
|
| 73 | - $this->connectionObject = new \PDO("sqlsrv:Server=$server;Database=$database;ConnectionPooling=0", $username, $password); |
|
| 74 | - } |
|
| 75 | - catch (\PDOException $e) |
|
| 76 | - { |
|
| 77 | - throw new SQLException("Unable to connect to database", 400, $e); |
|
| 78 | - } |
|
| 71 | + try |
|
| 72 | + { |
|
| 73 | + $this->connectionObject = new \PDO("sqlsrv:Server=$server;Database=$database;ConnectionPooling=0", $username, $password); |
|
| 74 | + } |
|
| 75 | + catch (\PDOException $e) |
|
| 76 | + { |
|
| 77 | + throw new SQLException("Unable to connect to database", 400, $e); |
|
| 78 | + } |
|
| 79 | 79 | |
| 80 | - $dsn = $this->dsn; |
|
| 81 | - unset($dsn[0], $dsn[1]); |
|
| 80 | + $dsn = $this->dsn; |
|
| 81 | + unset($dsn[0], $dsn[1]); |
|
| 82 | 82 | |
| 83 | - foreach ($dsn as $attribute) |
|
| 84 | - { |
|
| 85 | - foreach ($attribute as $key=>$value) |
|
| 86 | - { |
|
| 87 | - $this->connectionObject->setAttribute($key, $value); |
|
| 88 | - } |
|
| 89 | - } |
|
| 90 | - } |
|
| 83 | + foreach ($dsn as $attribute) |
|
| 84 | + { |
|
| 85 | + foreach ($attribute as $key=>$value) |
|
| 86 | + { |
|
| 87 | + $this->connectionObject->setAttribute($key, $value); |
|
| 88 | + } |
|
| 89 | + } |
|
| 90 | + } |
|
| 91 | 91 | |
| 92 | - /** |
|
| 93 | - * Returns an instance a pdo intance of the connection object |
|
| 94 | - * |
|
| 95 | - * @return \PDO |
|
| 96 | - */ |
|
| 97 | - public function getConnection() : \PDO |
|
| 98 | - { |
|
| 99 | - if ($this->connectionObject instanceof \PDO) |
|
| 100 | - { |
|
| 101 | - return $this->connectionObject; |
|
| 102 | - } |
|
| 92 | + /** |
|
| 93 | + * Returns an instance a pdo intance of the connection object |
|
| 94 | + * |
|
| 95 | + * @return \PDO |
|
| 96 | + */ |
|
| 97 | + public function getConnection() : \PDO |
|
| 98 | + { |
|
| 99 | + if ($this->connectionObject instanceof \PDO) |
|
| 100 | + { |
|
| 101 | + return $this->connectionObject; |
|
| 102 | + } |
|
| 103 | 103 | |
| 104 | - $this->connect( |
|
| 105 | - $this->loginData['username'] ?? '', |
|
| 106 | - $this->loginData['password'] ?? '' |
|
| 107 | - ); |
|
| 104 | + $this->connect( |
|
| 105 | + $this->loginData['username'] ?? '', |
|
| 106 | + $this->loginData['password'] ?? '' |
|
| 107 | + ); |
|
| 108 | 108 | |
| 109 | - return $this->connectionObject; |
|
| 110 | - } |
|
| 109 | + return $this->connectionObject; |
|
| 110 | + } |
|
| 111 | 111 | |
| 112 | - /** |
|
| 113 | - * Closes connection |
|
| 114 | - */ |
|
| 115 | - public function disableConnection() |
|
| 116 | - { |
|
| 117 | - $this->connectionObject = null; |
|
| 118 | - } |
|
| 112 | + /** |
|
| 113 | + * Closes connection |
|
| 114 | + */ |
|
| 115 | + public function disableConnection() |
|
| 116 | + { |
|
| 117 | + $this->connectionObject = null; |
|
| 118 | + } |
|
| 119 | 119 | |
| 120 | - /** |
|
| 121 | - * Sets attributes for the PDO object |
|
| 122 | - * |
|
| 123 | - * @param \PDO $attribute |
|
| 124 | - * @param \PDO $value |
|
| 125 | - */ |
|
| 126 | - public function setAttribute(\PDO $attribute, \PDO $value) |
|
| 127 | - { |
|
| 128 | - $this->connectionObject->setAttribute($attribute, $value); |
|
| 129 | - } |
|
| 120 | + /** |
|
| 121 | + * Sets attributes for the PDO object |
|
| 122 | + * |
|
| 123 | + * @param \PDO $attribute |
|
| 124 | + * @param \PDO $value |
|
| 125 | + */ |
|
| 126 | + public function setAttribute(\PDO $attribute, \PDO $value) |
|
| 127 | + { |
|
| 128 | + $this->connectionObject->setAttribute($attribute, $value); |
|
| 129 | + } |
|
| 130 | 130 | } |
@@ -18,33 +18,33 @@ |
||
| 18 | 18 | */ |
| 19 | 19 | interface ConnectableInterface |
| 20 | 20 | { |
| 21 | - /** |
|
| 22 | - * Setter for the DSN string {@see $dsn} |
|
| 23 | - * |
|
| 24 | - * @param array $dsnArray |
|
| 25 | - * @return void |
|
| 26 | - */ |
|
| 27 | - public function setDsn(array $dsnArray); |
|
| 21 | + /** |
|
| 22 | + * Setter for the DSN string {@see $dsn} |
|
| 23 | + * |
|
| 24 | + * @param array $dsnArray |
|
| 25 | + * @return void |
|
| 26 | + */ |
|
| 27 | + public function setDsn(array $dsnArray); |
|
| 28 | 28 | |
| 29 | - /** |
|
| 30 | - * Establishes connection |
|
| 31 | - * |
|
| 32 | - * @param string $username optional |
|
| 33 | - * @param string $password optional |
|
| 34 | - * @throws [@todo get exceptions] |
|
| 35 | - * @return void |
|
| 36 | - */ |
|
| 37 | - public function connect(string $username, string $password=""); |
|
| 29 | + /** |
|
| 30 | + * Establishes connection |
|
| 31 | + * |
|
| 32 | + * @param string $username optional |
|
| 33 | + * @param string $password optional |
|
| 34 | + * @throws [@todo get exceptions] |
|
| 35 | + * @return void |
|
| 36 | + */ |
|
| 37 | + public function connect(string $username, string $password=""); |
|
| 38 | 38 | |
| 39 | - /** |
|
| 40 | - * Returns an instance a pdo intance of the connection object |
|
| 41 | - * |
|
| 42 | - * @return \PDO |
|
| 43 | - */ |
|
| 44 | - public function getConnection() : \PDO; |
|
| 39 | + /** |
|
| 40 | + * Returns an instance a pdo intance of the connection object |
|
| 41 | + * |
|
| 42 | + * @return \PDO |
|
| 43 | + */ |
|
| 44 | + public function getConnection() : \PDO; |
|
| 45 | 45 | |
| 46 | - /** |
|
| 47 | - * Closes connection |
|
| 48 | - */ |
|
| 49 | - public function disableConnection(); |
|
| 46 | + /** |
|
| 47 | + * Closes connection |
|
| 48 | + */ |
|
| 49 | + public function disableConnection(); |
|
| 50 | 50 | } |
@@ -1,4 +1,4 @@ discard block |
||
| 1 | -<?php declare(strict_types=1); |
|
| 1 | +<?php declare(strict_types = 1); |
|
| 2 | 2 | /** |
| 3 | 3 | * @license MIT |
| 4 | 4 | * @author Samuel Adeshina <[email protected]> |
@@ -34,7 +34,7 @@ discard block |
||
| 34 | 34 | * @throws [@todo get exceptions] |
| 35 | 35 | * @return void |
| 36 | 36 | */ |
| 37 | - public function connect(string $username, string $password=""); |
|
| 37 | + public function connect(string $username, string $password = ""); |
|
| 38 | 38 | |
| 39 | 39 | /** |
| 40 | 40 | * Returns an instance a pdo intance of the connection object |
@@ -20,22 +20,22 @@ |
||
| 20 | 20 | { |
| 21 | 21 | public $connection; |
| 22 | 22 | |
| 23 | - public function __construct(string $adapter, array $dsnArray, string $username=null, string $password=null) |
|
| 24 | - { |
|
| 25 | - $class = __NAMESPACE__."\\Adapters\\$adapter"; |
|
| 26 | - $adapterObject = new $class; |
|
| 23 | + public function __construct(string $adapter, array $dsnArray, string $username=null, string $password=null) |
|
| 24 | + { |
|
| 25 | + $class = __NAMESPACE__."\\Adapters\\$adapter"; |
|
| 26 | + $adapterObject = new $class; |
|
| 27 | 27 | |
| 28 | - if ($adapterObject instanceof ConnectableInterface) |
|
| 29 | - { |
|
| 30 | - $adapterObject->setDsn($dsnArray); |
|
| 31 | - $adapterObject->connect($username, $password); |
|
| 32 | - } |
|
| 28 | + if ($adapterObject instanceof ConnectableInterface) |
|
| 29 | + { |
|
| 30 | + $adapterObject->setDsn($dsnArray); |
|
| 31 | + $adapterObject->connect($username, $password); |
|
| 32 | + } |
|
| 33 | 33 | |
| 34 | - $this->connection = $adapterObject->getConnection(); |
|
| 35 | - } |
|
| 34 | + $this->connection = $adapterObject->getConnection(); |
|
| 35 | + } |
|
| 36 | 36 | |
| 37 | - public function getConnection() : \PDO |
|
| 38 | - { |
|
| 39 | - return $this->connection; |
|
| 40 | - } |
|
| 37 | + public function getConnection() : \PDO |
|
| 38 | + { |
|
| 39 | + return $this->connection; |
|
| 40 | + } |
|
| 41 | 41 | } |
| 42 | 42 | \ No newline at end of file |
@@ -1,4 +1,4 @@ discard block |
||
| 1 | -<?php declare(strict_types=1); |
|
| 1 | +<?php declare(strict_types = 1); |
|
| 2 | 2 | /** |
| 3 | 3 | * @license MIT |
| 4 | 4 | * @author Samuel Adeshina <[email protected](clent, data)om> |
@@ -20,7 +20,7 @@ discard block |
||
| 20 | 20 | { |
| 21 | 21 | public $connection; |
| 22 | 22 | |
| 23 | - public function __construct(string $adapter, array $dsnArray, string $username=null, string $password=null) |
|
| 23 | + public function __construct(string $adapter, array $dsnArray, string $username = null, string $password = null) |
|
| 24 | 24 | { |
| 25 | 25 | $class = __NAMESPACE__."\\Adapters\\$adapter"; |
| 26 | 26 | $adapterObject = new $class; |
@@ -1,4 +1,4 @@ |
||
| 1 | -<?php declare(strict_types=1); |
|
| 1 | +<?php declare(strict_types = 1); |
|
| 2 | 2 | /** |
| 3 | 3 | * @license MIT |
| 4 | 4 | * @author Samuel Adeshina <[email protected]> |
@@ -17,37 +17,37 @@ |
||
| 17 | 17 | */ |
| 18 | 18 | class Session |
| 19 | 19 | { |
| 20 | - protected $session; |
|
| 20 | + protected $session; |
|
| 21 | 21 | |
| 22 | - /** |
|
| 23 | - * |
|
| 24 | - */ |
|
| 25 | - public static function init($session = "") |
|
| 26 | - { |
|
| 27 | - $this->session = $session; |
|
| 28 | - } |
|
| 22 | + /** |
|
| 23 | + * |
|
| 24 | + */ |
|
| 25 | + public static function init($session = "") |
|
| 26 | + { |
|
| 27 | + $this->session = $session; |
|
| 28 | + } |
|
| 29 | 29 | |
| 30 | - /** |
|
| 31 | - * |
|
| 32 | - */ |
|
| 33 | - public static function save($key, $value) |
|
| 34 | - { |
|
| 35 | - $session[$key] = $value; |
|
| 36 | - } |
|
| 30 | + /** |
|
| 31 | + * |
|
| 32 | + */ |
|
| 33 | + public static function save($key, $value) |
|
| 34 | + { |
|
| 35 | + $session[$key] = $value; |
|
| 36 | + } |
|
| 37 | 37 | |
| 38 | - /** |
|
| 39 | - * |
|
| 40 | - */ |
|
| 41 | - public static function get($key) |
|
| 42 | - { |
|
| 43 | - return $session[$key] ?? ''; |
|
| 44 | - } |
|
| 38 | + /** |
|
| 39 | + * |
|
| 40 | + */ |
|
| 41 | + public static function get($key) |
|
| 42 | + { |
|
| 43 | + return $session[$key] ?? ''; |
|
| 44 | + } |
|
| 45 | 45 | |
| 46 | - /** |
|
| 47 | - * |
|
| 48 | - */ |
|
| 49 | - public static function delete($key) |
|
| 50 | - { |
|
| 51 | - unset($session[$key]); |
|
| 52 | - } |
|
| 46 | + /** |
|
| 47 | + * |
|
| 48 | + */ |
|
| 49 | + public static function delete($key) |
|
| 50 | + { |
|
| 51 | + unset($session[$key]); |
|
| 52 | + } |
|
| 53 | 53 | } |
@@ -20,43 +20,43 @@ |
||
| 20 | 20 | */ |
| 21 | 21 | class DatabaseConnectionFactory |
| 22 | 22 | { |
| 23 | - /** |
|
| 24 | - * @var \PDO $connectionObject |
|
| 25 | - */ |
|
| 26 | - private static $connectionObject; |
|
| 27 | - |
|
| 28 | - /** |
|
| 29 | - * Gets the config values defined in the database-config.json file |
|
| 30 | - * and uses the values to create a new connection object. |
|
| 31 | - */ |
|
| 32 | - public static function bootstrap() |
|
| 33 | - { |
|
| 34 | - $databaseConfigJson = file_get_contents("bin/configs/database-config.json"); |
|
| 35 | - |
|
| 36 | - $databaseConfig = json_decode($databaseConfigJson); |
|
| 37 | - |
|
| 38 | - $adapter = $databaseConfig->adapter; |
|
| 39 | - $server = $databaseConfig->server; |
|
| 40 | - $database = $databaseConfig->database; |
|
| 41 | - $username = $databaseConfig->username; |
|
| 42 | - $password = $databaseConfig->password; |
|
| 43 | - |
|
| 44 | - self::$connectionObject = new Connection($adapter, [$server, $database], $username, $password); |
|
| 45 | - |
|
| 46 | - if ($databaseConfig->showError) |
|
| 47 | - { |
|
| 48 | - self::$connectionObject->getConnection()->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); |
|
| 49 | - } |
|
| 50 | - } |
|
| 51 | - |
|
| 52 | - /** |
|
| 53 | - * Returns a new connection object |
|
| 54 | - * |
|
| 55 | - * @return \PDO |
|
| 56 | - */ |
|
| 57 | - public static function getConnection() : \PDO |
|
| 58 | - { |
|
| 59 | - self::bootstrap(); |
|
| 60 | - return self::$connectionObject->getConnection(); |
|
| 61 | - } |
|
| 23 | + /** |
|
| 24 | + * @var \PDO $connectionObject |
|
| 25 | + */ |
|
| 26 | + private static $connectionObject; |
|
| 27 | + |
|
| 28 | + /** |
|
| 29 | + * Gets the config values defined in the database-config.json file |
|
| 30 | + * and uses the values to create a new connection object. |
|
| 31 | + */ |
|
| 32 | + public static function bootstrap() |
|
| 33 | + { |
|
| 34 | + $databaseConfigJson = file_get_contents("bin/configs/database-config.json"); |
|
| 35 | + |
|
| 36 | + $databaseConfig = json_decode($databaseConfigJson); |
|
| 37 | + |
|
| 38 | + $adapter = $databaseConfig->adapter; |
|
| 39 | + $server = $databaseConfig->server; |
|
| 40 | + $database = $databaseConfig->database; |
|
| 41 | + $username = $databaseConfig->username; |
|
| 42 | + $password = $databaseConfig->password; |
|
| 43 | + |
|
| 44 | + self::$connectionObject = new Connection($adapter, [$server, $database], $username, $password); |
|
| 45 | + |
|
| 46 | + if ($databaseConfig->showError) |
|
| 47 | + { |
|
| 48 | + self::$connectionObject->getConnection()->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION); |
|
| 49 | + } |
|
| 50 | + } |
|
| 51 | + |
|
| 52 | + /** |
|
| 53 | + * Returns a new connection object |
|
| 54 | + * |
|
| 55 | + * @return \PDO |
|
| 56 | + */ |
|
| 57 | + public static function getConnection() : \PDO |
|
| 58 | + { |
|
| 59 | + self::bootstrap(); |
|
| 60 | + return self::$connectionObject->getConnection(); |
|
| 61 | + } |
|
| 62 | 62 | } |
@@ -1,4 +1,4 @@ |
||
| 1 | -<?php declare(strict_types=1); |
|
| 1 | +<?php declare(strict_types = 1); |
|
| 2 | 2 | /** |
| 3 | 3 | * @license MIT |
| 4 | 4 | * @author Samuel Adeshina <[email protected]> |
@@ -1,4 +1,4 @@ |
||
| 1 | -<?php declare (strict_types=1); |
|
| 1 | +<?php declare (strict_types = 1); |
|
| 2 | 2 | /** |
| 3 | 3 | * @license MIT |
| 4 | 4 | * @author Samuel Adeshina <[email protected]> |
@@ -17,84 +17,84 @@ |
||
| 17 | 17 | */ |
| 18 | 18 | class SelectQueryBuilder extends QueryBuilder |
| 19 | 19 | { |
| 20 | - /** |
|
| 21 | - * @var \EmmetBlue\Core\Builder\QueryBuilder |
|
| 22 | - */ |
|
| 23 | - protected $queryBuilder; |
|
| 20 | + /** |
|
| 21 | + * @var \EmmetBlue\Core\Builder\QueryBuilder |
|
| 22 | + */ |
|
| 23 | + protected $queryBuilder; |
|
| 24 | 24 | |
| 25 | - /** |
|
| 26 | - * @param string|null $tableName |
|
| 27 | - */ |
|
| 28 | - public function __construct() |
|
| 29 | - { |
|
| 30 | - $SelectKeyword = "SELECT"; |
|
| 31 | - $this->queryBuilder = $this->build($SelectKeyword); |
|
| 32 | - } |
|
| 25 | + /** |
|
| 26 | + * @param string|null $tableName |
|
| 27 | + */ |
|
| 28 | + public function __construct() |
|
| 29 | + { |
|
| 30 | + $SelectKeyword = "SELECT"; |
|
| 31 | + $this->queryBuilder = $this->build($SelectKeyword); |
|
| 32 | + } |
|
| 33 | 33 | |
| 34 | - /** |
|
| 35 | - * {@inheritdoc} |
|
| 36 | - * |
|
| 37 | - * @param int $topValue |
|
| 38 | - * |
|
| 39 | - * @return \EmmetBlue\Core\Builder\SelectQueryBuilder |
|
| 40 | - */ |
|
| 41 | - public function top(int $topValue) |
|
| 42 | - { |
|
| 43 | - $this->queryBuilder = $this->queryBuilder->build("TOP ".$topValue); |
|
| 34 | + /** |
|
| 35 | + * {@inheritdoc} |
|
| 36 | + * |
|
| 37 | + * @param int $topValue |
|
| 38 | + * |
|
| 39 | + * @return \EmmetBlue\Core\Builder\SelectQueryBuilder |
|
| 40 | + */ |
|
| 41 | + public function top(int $topValue) |
|
| 42 | + { |
|
| 43 | + $this->queryBuilder = $this->queryBuilder->build("TOP ".$topValue); |
|
| 44 | 44 | |
| 45 | - return $this; |
|
| 46 | - } |
|
| 47 | - /** |
|
| 48 | - * This method handles situations that requires to |
|
| 49 | - * select all from the table. |
|
| 50 | - * @param * |
|
| 51 | - */ |
|
| 52 | - public function all() |
|
| 53 | - { |
|
| 54 | - $this->queryBuilder = $this->queryBuilder->build("*"); |
|
| 55 | - return $this; |
|
| 56 | - } |
|
| 57 | - /** |
|
| 58 | - * {@inheritdoc} |
|
| 59 | - * |
|
| 60 | - * @param string $columns |
|
| 61 | - * |
|
| 62 | - * @return \EmmetBlue\Core\Builder\SelectQueryBuilder |
|
| 63 | - */ |
|
| 64 | - public function columns(string ...$columns) |
|
| 65 | - { |
|
| 66 | - $this->queryBuilder = $this->queryBuilder->build(self::getImplodedString($columns)); |
|
| 45 | + return $this; |
|
| 46 | + } |
|
| 47 | + /** |
|
| 48 | + * This method handles situations that requires to |
|
| 49 | + * select all from the table. |
|
| 50 | + * @param * |
|
| 51 | + */ |
|
| 52 | + public function all() |
|
| 53 | + { |
|
| 54 | + $this->queryBuilder = $this->queryBuilder->build("*"); |
|
| 55 | + return $this; |
|
| 56 | + } |
|
| 57 | + /** |
|
| 58 | + * {@inheritdoc} |
|
| 59 | + * |
|
| 60 | + * @param string $columns |
|
| 61 | + * |
|
| 62 | + * @return \EmmetBlue\Core\Builder\SelectQueryBuilder |
|
| 63 | + */ |
|
| 64 | + public function columns(string ...$columns) |
|
| 65 | + { |
|
| 66 | + $this->queryBuilder = $this->queryBuilder->build(self::getImplodedString($columns)); |
|
| 67 | 67 | |
| 68 | - return $this; |
|
| 69 | - } |
|
| 68 | + return $this; |
|
| 69 | + } |
|
| 70 | 70 | |
| 71 | - /** |
|
| 72 | - * {@inheritdoc} |
|
| 73 | - * |
|
| 74 | - * @param string $tableName |
|
| 75 | - * |
|
| 76 | - * @return \EmmetBlue\Core\Builder\SelectQueryBuilder |
|
| 77 | - */ |
|
| 78 | - public function from(string $tableName) |
|
| 79 | - { |
|
| 80 | - $this->queryBuilder = $this->queryBuilder->build("FROM ".$tableName); |
|
| 71 | + /** |
|
| 72 | + * {@inheritdoc} |
|
| 73 | + * |
|
| 74 | + * @param string $tableName |
|
| 75 | + * |
|
| 76 | + * @return \EmmetBlue\Core\Builder\SelectQueryBuilder |
|
| 77 | + */ |
|
| 78 | + public function from(string $tableName) |
|
| 79 | + { |
|
| 80 | + $this->queryBuilder = $this->queryBuilder->build("FROM ".$tableName); |
|
| 81 | 81 | |
| 82 | - return $this; |
|
| 83 | - } |
|
| 82 | + return $this; |
|
| 83 | + } |
|
| 84 | 84 | |
| 85 | - /** |
|
| 86 | - * {@inheritdoc} |
|
| 87 | - * |
|
| 88 | - * @param string $tableName |
|
| 89 | - * @param string $condition |
|
| 90 | - * |
|
| 91 | - * @return \EmmetBlue\Core\Builder\SelectQueryBuilder |
|
| 92 | - */ |
|
| 93 | - public function innerJoin(string $tableName, string $condition) |
|
| 94 | - { |
|
| 95 | - $string = "INNER JOIN ".$tableName." ON ".$condition; |
|
| 96 | - $this->queryBuilder = $this->queryBuilder->build($string); |
|
| 85 | + /** |
|
| 86 | + * {@inheritdoc} |
|
| 87 | + * |
|
| 88 | + * @param string $tableName |
|
| 89 | + * @param string $condition |
|
| 90 | + * |
|
| 91 | + * @return \EmmetBlue\Core\Builder\SelectQueryBuilder |
|
| 92 | + */ |
|
| 93 | + public function innerJoin(string $tableName, string $condition) |
|
| 94 | + { |
|
| 95 | + $string = "INNER JOIN ".$tableName." ON ".$condition; |
|
| 96 | + $this->queryBuilder = $this->queryBuilder->build($string); |
|
| 97 | 97 | |
| 98 | - return $this; |
|
| 99 | - } |
|
| 98 | + return $this; |
|
| 99 | + } |
|
| 100 | 100 | } |
@@ -17,31 +17,31 @@ |
||
| 17 | 17 | */ |
| 18 | 18 | class DeleteQueryBuilder extends QueryBuilder |
| 19 | 19 | { |
| 20 | - /** |
|
| 21 | - * @var \EmmetBlue\Core\Builder\QueryBuilder |
|
| 22 | - */ |
|
| 23 | - protected $queryBuilder; |
|
| 20 | + /** |
|
| 21 | + * @var \EmmetBlue\Core\Builder\QueryBuilder |
|
| 22 | + */ |
|
| 23 | + protected $queryBuilder; |
|
| 24 | 24 | |
| 25 | - /** |
|
| 26 | - * @param string|null $tableName |
|
| 27 | - */ |
|
| 28 | - public function __construct() |
|
| 29 | - { |
|
| 30 | - $DeleteKeyword = "Delete"; |
|
| 31 | - $this->queryBuilder = $this->build($DeleteKeyword); |
|
| 32 | - } |
|
| 25 | + /** |
|
| 26 | + * @param string|null $tableName |
|
| 27 | + */ |
|
| 28 | + public function __construct() |
|
| 29 | + { |
|
| 30 | + $DeleteKeyword = "Delete"; |
|
| 31 | + $this->queryBuilder = $this->build($DeleteKeyword); |
|
| 32 | + } |
|
| 33 | 33 | |
| 34 | - /** |
|
| 35 | - * {@inheritdoc} |
|
| 36 | - * |
|
| 37 | - * @param string $tableName |
|
| 38 | - * |
|
| 39 | - * @return \EmmetBlue\Core\Builder\DeleteQueryBuilder |
|
| 40 | - */ |
|
| 41 | - public function from(string $tableName) |
|
| 42 | - { |
|
| 43 | - $this->queryBuilder = $this->queryBuilder->build("FROM ".$tableName); |
|
| 34 | + /** |
|
| 35 | + * {@inheritdoc} |
|
| 36 | + * |
|
| 37 | + * @param string $tableName |
|
| 38 | + * |
|
| 39 | + * @return \EmmetBlue\Core\Builder\DeleteQueryBuilder |
|
| 40 | + */ |
|
| 41 | + public function from(string $tableName) |
|
| 42 | + { |
|
| 43 | + $this->queryBuilder = $this->queryBuilder->build("FROM ".$tableName); |
|
| 44 | 44 | |
| 45 | - return $this; |
|
| 46 | - } |
|
| 45 | + return $this; |
|
| 46 | + } |
|
| 47 | 47 | } |
@@ -1,4 +1,4 @@ |
||
| 1 | -<?php declare (strict_types=1); |
|
| 1 | +<?php declare (strict_types = 1); |
|
| 2 | 2 | /** |
| 3 | 3 | * @license MIT |
| 4 | 4 | * @author Samuel Adeshina <[email protected]> |