diff --git a/composer.lock b/composer.lock index 79d5f1d..ddbc4b4 100644 --- a/composer.lock +++ b/composer.lock @@ -53,16 +53,16 @@ }, { "name": "colibrilabs/collection", - "version": "0.2.0", + "version": "0.2.3", "source": { "type": "git", "url": "https://github.com/colibrilabs/collection.git", - "reference": "7ba718ebb890392bb7266db0dc6d96b5051e4ce3" + "reference": "85d61b52f9070da694d264b03a565a17b4347e0b" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/colibrilabs/collection/zipball/7ba718ebb890392bb7266db0dc6d96b5051e4ce3", - "reference": "7ba718ebb890392bb7266db0dc6d96b5051e4ce3", + "url": "https://api.github.com/repos/colibrilabs/collection/zipball/85d61b52f9070da694d264b03a565a17b4347e0b", + "reference": "85d61b52f9070da694d264b03a565a17b4347e0b", "shasum": "" }, "require": { @@ -89,7 +89,7 @@ "collection", "php collection" ], - "time": "2017-06-20 13:53:34" + "time": "2017-06-21 15:36:43" }, { "name": "colibrilabs/html", @@ -267,45 +267,45 @@ }, { "name": "symfony/console", - "version": "v3.3.2", + "version": "v3.4.2", "source": { "type": "git", "url": "https://github.com/symfony/console.git", - "reference": "70d2a29b2911cbdc91a7e268046c395278238b2e" + "reference": "9f21adfb92a9315b73ae2ed43138988ee4913d4e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/console/zipball/70d2a29b2911cbdc91a7e268046c395278238b2e", - "reference": "70d2a29b2911cbdc91a7e268046c395278238b2e", + "url": "https://api.github.com/repos/symfony/console/zipball/9f21adfb92a9315b73ae2ed43138988ee4913d4e", + "reference": "9f21adfb92a9315b73ae2ed43138988ee4913d4e", "shasum": "" }, "require": { - "php": ">=5.5.9", - "symfony/debug": "~2.8|~3.0", + "php": "^5.5.9|>=7.0.8", + "symfony/debug": "~2.8|~3.0|~4.0", "symfony/polyfill-mbstring": "~1.0" }, "conflict": { - "symfony/dependency-injection": "<3.3" + "symfony/dependency-injection": "<3.4", + "symfony/process": "<3.3" }, "require-dev": { "psr/log": "~1.0", - "symfony/config": "~3.3", - "symfony/dependency-injection": "~3.3", - "symfony/event-dispatcher": "~2.8|~3.0", - "symfony/filesystem": "~2.8|~3.0", - "symfony/http-kernel": "~2.8|~3.0", - "symfony/process": "~2.8|~3.0" + "symfony/config": "~3.3|~4.0", + "symfony/dependency-injection": "~3.4|~4.0", + "symfony/event-dispatcher": "~2.8|~3.0|~4.0", + "symfony/lock": "~3.4|~4.0", + "symfony/process": "~3.3|~4.0" }, "suggest": { "psr/log": "For using the console logger", "symfony/event-dispatcher": "", - "symfony/filesystem": "", + "symfony/lock": "", "symfony/process": "" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.3-dev" + "dev-master": "3.4-dev" } }, "autoload": { @@ -332,36 +332,36 @@ ], "description": "Symfony Console Component", "homepage": "https://symfony.com", - "time": "2017-06-02 19:24:58" + "time": "2017-12-14 19:40:10" }, { "name": "symfony/debug", - "version": "v3.3.2", + "version": "v3.4.2", "source": { "type": "git", "url": "https://github.com/symfony/debug.git", - "reference": "e9c50482841ef696e8fa1470d950a79c8921f45d" + "reference": "543deab3ffff94402440b326fc94153bae2dfa7a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/debug/zipball/e9c50482841ef696e8fa1470d950a79c8921f45d", - "reference": "e9c50482841ef696e8fa1470d950a79c8921f45d", + "url": "https://api.github.com/repos/symfony/debug/zipball/543deab3ffff94402440b326fc94153bae2dfa7a", + "reference": "543deab3ffff94402440b326fc94153bae2dfa7a", "shasum": "" }, "require": { - "php": ">=5.5.9", + "php": "^5.5.9|>=7.0.8", "psr/log": "~1.0" }, "conflict": { "symfony/http-kernel": ">=2.3,<2.3.24|~2.4.0|>=2.5,<2.5.9|>=2.6,<2.6.2" }, "require-dev": { - "symfony/http-kernel": "~2.8|~3.0" + "symfony/http-kernel": "~2.8|~3.0|~4.0" }, "type": "library", "extra": { "branch-alias": { - "dev-master": "3.3-dev" + "dev-master": "3.4-dev" } }, "autoload": { @@ -388,20 +388,20 @@ ], "description": "Symfony Debug Component", "homepage": "https://symfony.com", - "time": "2017-06-01 21:01:25" + "time": "2017-12-12 08:27:14" }, { "name": "symfony/polyfill-mbstring", - "version": "v1.4.0", + "version": "v1.6.0", "source": { "type": "git", "url": "https://github.com/symfony/polyfill-mbstring.git", - "reference": "f29dca382a6485c3cbe6379f0c61230167681937" + "reference": "2ec8b39c38cb16674bbf3fea2b6ce5bf117e1296" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/f29dca382a6485c3cbe6379f0c61230167681937", - "reference": "f29dca382a6485c3cbe6379f0c61230167681937", + "url": "https://api.github.com/repos/symfony/polyfill-mbstring/zipball/2ec8b39c38cb16674bbf3fea2b6ce5bf117e1296", + "reference": "2ec8b39c38cb16674bbf3fea2b6ce5bf117e1296", "shasum": "" }, "require": { @@ -413,7 +413,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "1.4-dev" + "dev-master": "1.6-dev" } }, "autoload": { @@ -447,27 +447,30 @@ "portable", "shim" ], - "time": "2017-06-09 14:24:12" + "time": "2017-10-11 12:05:26" }, { "name": "symfony/yaml", - "version": "v3.3.2", + "version": "v3.4.2", "source": { "type": "git", "url": "https://github.com/symfony/yaml.git", - "reference": "9752a30000a8ca9f4b34b5227d15d0101b96b063" + "reference": "afe0cd38486505c9703707707d91450cfc1bd536" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/yaml/zipball/9752a30000a8ca9f4b34b5227d15d0101b96b063", - "reference": "9752a30000a8ca9f4b34b5227d15d0101b96b063", + "url": "https://api.github.com/repos/symfony/yaml/zipball/afe0cd38486505c9703707707d91450cfc1bd536", + "reference": "afe0cd38486505c9703707707d91450cfc1bd536", "shasum": "" }, "require": { - "php": ">=5.5.9" + "php": "^5.5.9|>=7.0.8" + }, + "conflict": { + "symfony/console": "<3.4" }, "require-dev": { - "symfony/console": "~2.8|~3.0" + "symfony/console": "~3.4|~4.0" }, "suggest": { "symfony/console": "For validating YAML files using the lint command" @@ -475,7 +478,7 @@ "type": "library", "extra": { "branch-alias": { - "dev-master": "3.3-dev" + "dev-master": "3.4-dev" } }, "autoload": { @@ -502,7 +505,7 @@ ], "description": "Symfony Yaml Component", "homepage": "https://symfony.com", - "time": "2017-06-02 22:05:06" + "time": "2017-12-11 20:38:23" } ], "packages-dev": [], diff --git a/src/Colibri/Core/Collection/ObjectStorage.php b/src/Colibri/Core/Collection/ObjectStorage.php new file mode 100644 index 0000000..7939f72 --- /dev/null +++ b/src/Colibri/Core/Collection/ObjectStorage.php @@ -0,0 +1,10 @@ +getInsertQuery(); + } /** diff --git a/src/Colibri/Query/Builder.php b/src/Colibri/Query/Builder.php index 9985fb3..9d6c29f 100644 --- a/src/Colibri/Query/Builder.php +++ b/src/Colibri/Query/Builder.php @@ -11,7 +11,7 @@ * Class Builder * @package Colibri\Query */ -abstract class Builder implements SqlableInterface +abstract class Builder implements SqlableInterface, BuilderInterface { /** diff --git a/src/Colibri/Query/Builder/Common/BaseBuilderTrait.php b/src/Colibri/Query/Builder/Common/BaseBuilderTrait.php new file mode 100644 index 0000000..557c495 --- /dev/null +++ b/src/Colibri/Query/Builder/Common/BaseBuilderTrait.php @@ -0,0 +1,414 @@ +getBuilderObject()->table($table); + + return $this; + } + + /** + * @inheritDoc + */ + public function cleanup() + { + $this->getBuilderObject()->cleanup(); + + return $this; + } + + /** + * @inheritDoc + */ + public function isReplaceAliases() + { + return $this->getBuilderObject()->isReplaceAliases(); + } + + /** + * @inheritDoc + */ + public function setReplaceAliases($replaceAliases) + { + $this->getBuilderObject()->setReplaceAliases($replaceAliases); + + return $this; + } + + /** + * @inheritDoc + */ + public function isParameterized() + { + return $this->getBuilderObject()->isParameterized(); + } + + /** + * @inheritDoc + */ + public function setParameterized($parameterized) + { + $this->getBuilderObject()->setParameterized($parameterized); + + return $this; + } + + /** + * @inheritDoc + */ + public function stringifyExpression(Expression $expression) + { + return $this->getBuilderObject()->stringifyExpression($expression); + } + + /** + * @inheritDoc + */ + public function normalizeExpression(Expression $expression) + { + return $this->getBuilderObject()->normalizeExpression($expression); + } + + /** + * @inheritDoc + */ + public function postProcessExpression(Expression $expression) + { + return $this->getBuilderObject()->postProcessExpression($expression); + } + + /** + * @inheritDoc + */ + public function preProcessExpression(Expression $expression) + { + return $this->getBuilderObject()->preProcessExpression($expression); + } + + /** + * @inheritDoc + */ + public function completeExpression(Expression $expression, $alias = null) + { + return $this->getBuilderObject()->completeExpression($expression, $alias); + } + + /** + * @inheritDoc + */ + public function createTable($definition) + { + return $this->getBuilderObject()->createTable($definition); + } + + /** + * @inheritDoc + */ + public function createColumn($definition) + { + return $this->getBuilderObject()->createColumn($definition); + } + + /** + * @inheritDoc + */ + public function hasColumnAlias($alias) + { + return $this->getBuilderObject()->hasColumnAlias($alias); + } + + /** + * @inheritDoc + */ + public function hasTableAlias($alias) + { + return $this->getBuilderObject()->hasTableAlias($alias); + } + + /** + * @inheritDoc + */ + public function hasFunctionAlias($alias) + { + return $this->getBuilderObject()->hasFunctionAlias($alias); + } + + /** + * @inheritDoc + */ + public function hasSubqueryAlias($alias) + { + return $this->getBuilderObject()->hasSubqueryAlias($alias); + } + + /** + * @inheritDoc + */ + public function getColumnByAlias($alias) + { + return $this->getBuilderObject()->getColumnByAlias($alias); + } + + /** + * @inheritDoc + */ + public function getTableByAlias($alias) + { + return $this->getBuilderObject()->getTableByAlias($alias); + } + + /** + * @inheritDoc + */ + public function getFunctionByAlias($alias) + { + return $this->getBuilderObject()->getFunctionByAlias($alias); + } + + /** + * @inheritDoc + */ + public function getSubqueryByAlias($alias) + { + return $this->getBuilderObject()->getSubqueryByAlias($alias); + } + + /** + * @inheritDoc + */ + public function setColumnAlias(Expr\Column $column, $alias) + { + $this->getBuilderObject()->setColumnAlias($column, $alias); + + return $this; + } + + /** + * @inheritDoc + */ + public function setTableAlias(Expr\Table $table, $alias) + { + $this->getBuilderObject()->setTableAlias($table, $alias); + + return $this; + } + + /** + * @inheritDoc + */ + public function setFunctionAlias(Expr\Func $function, $alias) + { + $this->getBuilderObject()->setFunctionAlias($function, $alias); + + return $this; + } + + /** + * @inheritDoc + */ + public function setAlias(Expression $expression, $alias) + { + $this->getBuilderObject()->setAlias($expression, $alias); + + return $this; + } + + /** + * @inheritDoc + */ + public function setExpression(Expression $expression) + { + $this->getBuilderObject()->setExpression($expression); + + return $this; + } + + /** + * @inheritDoc + */ + public function hasExpression(Expression $expression) + { + return $this->getBuilderObject()->hasExpression($expression); + } + + /** + * @inheritDoc + */ + public function hasExpressionHash($hashCode) + { + return $this->getBuilderObject()->hasExpressionHash($hashCode); + } + + /** + * @inheritDoc + */ + public function getExpression($hashCode) + { + return $this->getBuilderObject()->getExpression($hashCode); + } + + /** + * @inheritDoc + */ + public function getExpressions() + { + return $this->getBuilderObject()->getExpressions(); + } + + /** + * @inheritDoc + */ + public function getAliases() + { + return $this->getBuilderObject()->getAliases(); + } + + /** + * @inheritDoc + */ + public function hasAlias($alias) + { + return $this->getBuilderObject()->hasAlias($alias); + } + + /** + * @inheritDoc + */ + public function getAlias($hash) + { + return $this->getBuilderObject()->getAlias($hash); + } + + /** + * @inheritDoc + */ + public function getHashes() + { + return $this->getBuilderObject()->getHashes(); + } + + /** + * @inheritDoc + */ + public function hasHash($hashCode) + { + return $this->getBuilderObject()->hasHash($hashCode); + } + + /** + * @inheritDoc + */ + public function getHash($alias) + { + return $this->getBuilderObject()->getHash($alias); + } + + /** + * @inheritDoc + */ + public function getPlaceholders() + { + return $this->getBuilderObject()->getPlaceholders(); + } + + /** + * @inheritDoc + */ + public function setPlaceholder($hashCode, Expr\Raw $placeholder) + { + $this->getBuilderObject()->setPlaceholder($hashCode, $placeholder); + + return $this; + } + + /** + * @inheritDoc + */ + public function getPlaceholder($hashCode) + { + return $this->getBuilderObject()->getPlaceholder($hashCode); + } + + /** + * @inheritDoc + */ + public function getPlaceholderForExpression(Expression $expression) + { + return $this->getBuilderObject()->getPlaceholderForExpression($expression); + } + + /** + * @inheritDoc + */ + public function quoteIdentifier($string) + { + return $this->getBuilderObject()->quoteIdentifier($string); + } + + /** + * @inheritDoc + */ + public function getConnection() + { + return $this->getBuilderObject()->getConnection(); + } + + /** + * @inheritDoc + */ + public function setConnection(ConnectionInterface $connection) + { + $this->getBuilderObject()->setConnection($connection); + + return $this; + } + + /** + * @inheritDoc + */ + public function getComment() + { + return $this->getBuilderObject()->getComment(); + } + + /** + * @inheritDoc + */ + public function getCommentSql() + { + return $this->getBuilderObject()->getCommentSql(); + } + + /** + * @inheritDoc + */ + public function setComment($comment) + { + $this->getBuilderObject()->setComment($comment); + + return $this; + } + + /** + * @return BuilderInterface + */ + abstract public function getBuilderObject(); + +} \ No newline at end of file diff --git a/src/Colibri/Query/Builder/Common/SelectTrait.php b/src/Colibri/Query/Builder/Common/SelectTrait.php new file mode 100644 index 0000000..b58bfbf --- /dev/null +++ b/src/Colibri/Query/Builder/Common/SelectTrait.php @@ -0,0 +1,109 @@ +getSelectBuilderObject()->from($table); + + return $this; + } + + /** + * @inheritDoc + */ + public function setFromTable($table) + { + $this->getSelectBuilderObject()->setFromTable($table); + + return $this; + } + + /** + * @inheritDoc + */ + public function addSelectColumns(array $columns) + { + $this->getSelectBuilderObject()->addSelectColumns($columns); + + return $this; + } + + /** + * @inheritDoc + */ + public function addSelectColumn($expression, $alias = null) + { + $this->getSelectBuilderObject()->addSelectColumn($expression, $alias); + + return $this; + } + + /** + * @inheritDoc + */ + public function clearSelectColumns() + { + $this->getSelectBuilderObject()->clearSelectColumns(); + + return $this; + } + + /** + * @inheritDoc + */ + public function avg($column, $alias) + { + $this->getSelectBuilderObject()->avg($column, $alias); + + return $this; + } + + /** + * @inheritDoc + */ + public function count($column, $alias) + { + $this->getSelectBuilderObject()->count($column, $alias); + + return $this; + } + + /** + * @inheritDoc + */ + public function max($column, $alias) + { + $this->getSelectBuilderObject()->max($column, $alias); + + return $this; + } + + /** + * @inheritDoc + */ + public function min($column, $alias) + { + $this->getSelectBuilderObject()->min($column, $alias); + + return $this; + } + + /** + * @return SelectInterface + */ + abstract public function getSelectBuilderObject(); + +} \ No newline at end of file diff --git a/src/Colibri/Query/Builder/Select.php b/src/Colibri/Query/Builder/Select.php index 96d5176..c249d12 100644 --- a/src/Colibri/Query/Builder/Select.php +++ b/src/Colibri/Query/Builder/Select.php @@ -21,7 +21,7 @@ * Class Select * @package Colibri\Query\Builder */ -class Select extends Builder +class Select extends Builder implements SelectInterface { use Syntax\WhereTrait; diff --git a/src/Colibri/Query/Builder/SelectInterface.php b/src/Colibri/Query/Builder/SelectInterface.php new file mode 100644 index 0000000..73e5b03 --- /dev/null +++ b/src/Colibri/Query/Builder/SelectInterface.php @@ -0,0 +1,75 @@ +builder = new Select(ServiceLocator::instance()->getConnection()); } + /** + * @inheritDoc + */ + public function getBuilderObject() + { + return $this->builder; + } + + /** + * @inheritDoc + */ + public function getSelectBuilderObject() + { + return $this->builder; + } + /** * @inheritDoc */