@@ -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 | } |
@@ -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 | } |
@@ -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 |
@@ -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 | } |
@@ -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 | } |
@@ -17,49 +17,49 @@ |
||
| 17 | 17 | */ |
| 18 | 18 | class UpdateQueryBuilder 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(string $tableName = null) |
|
| 29 | - { |
|
| 30 | - $updateKeyword = (is_null($tableName)) ? 'UPDATE' : 'UPDATE '.$tableName; |
|
| 31 | - $this->queryBuilder = $this->build($updateKeyword); |
|
| 32 | - } |
|
| 25 | + /** |
|
| 26 | + * @param string|null $tableName |
|
| 27 | + */ |
|
| 28 | + public function __construct(string $tableName = null) |
|
| 29 | + { |
|
| 30 | + $updateKeyword = (is_null($tableName)) ? 'UPDATE' : 'UPDATE '.$tableName; |
|
| 31 | + $this->queryBuilder = $this->build($updateKeyword); |
|
| 32 | + } |
|
| 33 | 33 | |
| 34 | - /** |
|
| 35 | - * {@inheritdoc} |
|
| 36 | - * |
|
| 37 | - * @param string $tableName |
|
| 38 | - * |
|
| 39 | - * @return \EmmetBlue\Core\Builder\UpdateQueryBuilder |
|
| 40 | - */ |
|
| 41 | - public function table(string $tableName) |
|
| 42 | - { |
|
| 43 | - $this->queryBuilder = $this->queryBuilder->build($tableName); |
|
| 34 | + /** |
|
| 35 | + * {@inheritdoc} |
|
| 36 | + * |
|
| 37 | + * @param string $tableName |
|
| 38 | + * |
|
| 39 | + * @return \EmmetBlue\Core\Builder\UpdateQueryBuilder |
|
| 40 | + */ |
|
| 41 | + public function table(string $tableName) |
|
| 42 | + { |
|
| 43 | + $this->queryBuilder = $this->queryBuilder->build($tableName); |
|
| 44 | 44 | |
| 45 | - return $this; |
|
| 46 | - } |
|
| 45 | + return $this; |
|
| 46 | + } |
|
| 47 | 47 | |
| 48 | - /** |
|
| 49 | - * {@inheritdoc} |
|
| 50 | - * |
|
| 51 | - * @param string[] $inputValues |
|
| 52 | - * |
|
| 53 | - * @return \EmmetBlue\Core\Builder\UpdateQueryBuilder |
|
| 54 | - */ |
|
| 55 | - public function set(array $inputValues) |
|
| 56 | - { |
|
| 57 | - $valuesKeyword = 'SET '; |
|
| 48 | + /** |
|
| 49 | + * {@inheritdoc} |
|
| 50 | + * |
|
| 51 | + * @param string[] $inputValues |
|
| 52 | + * |
|
| 53 | + * @return \EmmetBlue\Core\Builder\UpdateQueryBuilder |
|
| 54 | + */ |
|
| 55 | + public function set(array $inputValues) |
|
| 56 | + { |
|
| 57 | + $valuesKeyword = 'SET '; |
|
| 58 | 58 | |
| 59 | - $valuesKeyword .= self::getImplodedStringWithKeys($inputValues); |
|
| 59 | + $valuesKeyword .= self::getImplodedStringWithKeys($inputValues); |
|
| 60 | 60 | |
| 61 | - $this->queryBuilder = $this->queryBuilder->build($valuesKeyword); |
|
| 61 | + $this->queryBuilder = $this->queryBuilder->build($valuesKeyword); |
|
| 62 | 62 | |
| 63 | - return $this; |
|
| 64 | - } |
|
| 63 | + return $this; |
|
| 64 | + } |
|
| 65 | 65 | } |
@@ -17,68 +17,68 @@ |
||
| 17 | 17 | */ |
| 18 | 18 | class InsertQueryBuilder extends QueryBuilder |
| 19 | 19 | { |
| 20 | - /** |
|
| 21 | - * @var \EmmetBlue\Core\Abstraction\QueryBuilder |
|
| 22 | - */ |
|
| 23 | - protected $queryBuilder; |
|
| 20 | + /** |
|
| 21 | + * @var \EmmetBlue\Core\Abstraction\QueryBuilder |
|
| 22 | + */ |
|
| 23 | + protected $queryBuilder; |
|
| 24 | 24 | |
| 25 | - /** |
|
| 26 | - * @param string|null $tableName |
|
| 27 | - */ |
|
| 28 | - public function __construct(string $tableName = null) |
|
| 29 | - { |
|
| 30 | - $insertKeyword = (is_null($tableName)) ? 'INSERT' : 'INSERT INTO '.$tableName; |
|
| 31 | - $this->queryBuilder = $this->build($insertKeyword); |
|
| 32 | - } |
|
| 25 | + /** |
|
| 26 | + * @param string|null $tableName |
|
| 27 | + */ |
|
| 28 | + public function __construct(string $tableName = null) |
|
| 29 | + { |
|
| 30 | + $insertKeyword = (is_null($tableName)) ? 'INSERT' : 'INSERT INTO '.$tableName; |
|
| 31 | + $this->queryBuilder = $this->build($insertKeyword); |
|
| 32 | + } |
|
| 33 | 33 | |
| 34 | - /** |
|
| 35 | - * {@inheritdoc} |
|
| 36 | - * |
|
| 37 | - * @param string $tableName |
|
| 38 | - * @param string[] $tableColumns Optional, provide this to specify the |
|
| 39 | - * columns that should be acted on |
|
| 40 | - * |
|
| 41 | - * @return \EmmetBlue\Core\Abstraction\InsertQueryBuilder |
|
| 42 | - */ |
|
| 43 | - public function into(string $tableName, array $tableColumns = []) |
|
| 44 | - { |
|
| 45 | - $intoKeyword = 'INTO '.$tableName; |
|
| 34 | + /** |
|
| 35 | + * {@inheritdoc} |
|
| 36 | + * |
|
| 37 | + * @param string $tableName |
|
| 38 | + * @param string[] $tableColumns Optional, provide this to specify the |
|
| 39 | + * columns that should be acted on |
|
| 40 | + * |
|
| 41 | + * @return \EmmetBlue\Core\Abstraction\InsertQueryBuilder |
|
| 42 | + */ |
|
| 43 | + public function into(string $tableName, array $tableColumns = []) |
|
| 44 | + { |
|
| 45 | + $intoKeyword = 'INTO '.$tableName; |
|
| 46 | 46 | |
| 47 | - if (!empty($tableColumns)) { |
|
| 48 | - $intoKeyword .= $this->wrapString(self::getImplodedString($tableColumns), '(', ')'); |
|
| 49 | - } |
|
| 47 | + if (!empty($tableColumns)) { |
|
| 48 | + $intoKeyword .= $this->wrapString(self::getImplodedString($tableColumns), '(', ')'); |
|
| 49 | + } |
|
| 50 | 50 | |
| 51 | - $this->queryBuilder = $this->queryBuilder->build($intoKeyword); |
|
| 51 | + $this->queryBuilder = $this->queryBuilder->build($intoKeyword); |
|
| 52 | 52 | |
| 53 | - return $this; |
|
| 54 | - } |
|
| 53 | + return $this; |
|
| 54 | + } |
|
| 55 | 55 | |
| 56 | - /** |
|
| 57 | - * {@inheritdoc} |
|
| 58 | - * |
|
| 59 | - * @param string[] $inputValues |
|
| 60 | - * |
|
| 61 | - * @return \EmmetBlue\Core\Abstraction\InsertQueryBuilder |
|
| 62 | - */ |
|
| 63 | - public function values(array $inputValues) |
|
| 64 | - { |
|
| 65 | - $valuesKeyword = 'VALUES '; |
|
| 66 | - $isMultidimentional = is_array($inputValues[0]); |
|
| 56 | + /** |
|
| 57 | + * {@inheritdoc} |
|
| 58 | + * |
|
| 59 | + * @param string[] $inputValues |
|
| 60 | + * |
|
| 61 | + * @return \EmmetBlue\Core\Abstraction\InsertQueryBuilder |
|
| 62 | + */ |
|
| 63 | + public function values(array $inputValues) |
|
| 64 | + { |
|
| 65 | + $valuesKeyword = 'VALUES '; |
|
| 66 | + $isMultidimentional = is_array($inputValues[0]); |
|
| 67 | 67 | |
| 68 | - if (!$isMultidimentional) { |
|
| 69 | - $valuesKeyword .= $this->wrapString(self::getImplodedString($inputValues), '(', ')'); |
|
| 70 | - } else { |
|
| 71 | - $tempValuesKeywords = []; |
|
| 72 | - foreach ($inputValues as $inputValue) { |
|
| 73 | - $tempValuesKeywords[] = $this->wrapString(self::getImplodedString($inputValue), '(', ')'); |
|
| 74 | - } |
|
| 68 | + if (!$isMultidimentional) { |
|
| 69 | + $valuesKeyword .= $this->wrapString(self::getImplodedString($inputValues), '(', ')'); |
|
| 70 | + } else { |
|
| 71 | + $tempValuesKeywords = []; |
|
| 72 | + foreach ($inputValues as $inputValue) { |
|
| 73 | + $tempValuesKeywords[] = $this->wrapString(self::getImplodedString($inputValue), '(', ')'); |
|
| 74 | + } |
|
| 75 | 75 | |
| 76 | - $valuesKeyword .= self::getImplodedString($tempValuesKeywords); |
|
| 77 | - unset($tempValuesKeywords); |
|
| 78 | - } |
|
| 76 | + $valuesKeyword .= self::getImplodedString($tempValuesKeywords); |
|
| 77 | + unset($tempValuesKeywords); |
|
| 78 | + } |
|
| 79 | 79 | |
| 80 | - $this->queryBuilder = $this->queryBuilder->build($valuesKeyword); |
|
| 80 | + $this->queryBuilder = $this->queryBuilder->build($valuesKeyword); |
|
| 81 | 81 | |
| 82 | - return $this; |
|
| 83 | - } |
|
| 82 | + return $this; |
|
| 83 | + } |
|
| 84 | 84 | } |
@@ -13,36 +13,36 @@ |
||
| 13 | 13 | */ |
| 14 | 14 | class BuilderFactory |
| 15 | 15 | { |
| 16 | - /** |
|
| 17 | - * @var string |
|
| 18 | - */ |
|
| 19 | - protected $builder; |
|
| 16 | + /** |
|
| 17 | + * @var string |
|
| 18 | + */ |
|
| 19 | + protected $builder; |
|
| 20 | 20 | |
| 21 | - /** |
|
| 22 | - * @param string $builder |
|
| 23 | - * @param string $builderType |
|
| 24 | - * @throws \Exception |
|
| 25 | - */ |
|
| 26 | - public function __construct(string $builder, string $builderType) |
|
| 27 | - { |
|
| 28 | - $builder = __NAMESPACE__."\\$builder\\$builderType$builder"; |
|
| 29 | - $builder = new $builder; |
|
| 21 | + /** |
|
| 22 | + * @param string $builder |
|
| 23 | + * @param string $builderType |
|
| 24 | + * @throws \Exception |
|
| 25 | + */ |
|
| 26 | + public function __construct(string $builder, string $builderType) |
|
| 27 | + { |
|
| 28 | + $builder = __NAMESPACE__."\\$builder\\$builderType$builder"; |
|
| 29 | + $builder = new $builder; |
|
| 30 | 30 | |
| 31 | - if (!($builder instanceof BuildableInterface)) |
|
| 32 | - { |
|
| 33 | - throw new \Exception(); |
|
| 34 | - } |
|
| 31 | + if (!($builder instanceof BuildableInterface)) |
|
| 32 | + { |
|
| 33 | + throw new \Exception(); |
|
| 34 | + } |
|
| 35 | 35 | |
| 36 | - $this->builder = $builder; |
|
| 37 | - } |
|
| 36 | + $this->builder = $builder; |
|
| 37 | + } |
|
| 38 | 38 | |
| 39 | - /** |
|
| 40 | - * Returns a new instance of the requested builder object |
|
| 41 | - * |
|
| 42 | - * @return EmmetBlue\Core\Database\Builder\BuildableInterface |
|
| 43 | - */ |
|
| 44 | - public function getBuilder() : BuildableInterface |
|
| 45 | - { |
|
| 46 | - return $this->builder; |
|
| 47 | - } |
|
| 39 | + /** |
|
| 40 | + * Returns a new instance of the requested builder object |
|
| 41 | + * |
|
| 42 | + * @return EmmetBlue\Core\Database\Builder\BuildableInterface |
|
| 43 | + */ |
|
| 44 | + public function getBuilder() : BuildableInterface |
|
| 45 | + { |
|
| 46 | + return $this->builder; |
|
| 47 | + } |
|
| 48 | 48 | } |