DEPRECATION NOTICE: this package has been moved and improved at grizz-it/dbal-sql
Ulrack DBAL SQL provides a SQL implementation for Ulrack DBAL. This package only implements the query assembly part.
To install the package run the following command:
composer require ulrack/dbal-sql
Some queries accept filters. Filters are used to narrow down the amount of
returned results. These filters are based on the QueryFilterInterface
from the
ulrack/dbal
package.
Filters can be grouped in the QueryFilterGroup
object. All filters inside this
group are separated by an AND statement. If a query object accepts multiple filter
groups, the filter groups will be separated by an OR statement.
- QueryFilterGroup: The base filter object expected by most queries.
Filters can be added to the group after instantiation:
use Ulrack\Dbal\Sql\Component\Filter\QueryFilterGroup;
use Ulrack\Dbal\Sql\Component\Filter\ComparatorFilter;
use Ulrack\Dbal\Sql\Common\ComparatorEnum;
// Create the filter group
$filterGroup = new QueryFilterGroup;
//Create the filter "column='value'"
$filter = new ComparatorFilter(
'column',
'value',
ComparatorEnum::EQ()
);
//Add the filter
$filterGroup->addFilter($filter);
- ComparatorFilter: Compare a column to a value with a standard comparator.
- ExistsFilter: Adds an EXISTS statement with a sub-query as a filter.
- QueryInFilter: Connects a default comparator with a sub-query as a filter.
- QueryOperatorFilter: Create a ANY or ALL filter in combination with a comparator for a sub-query.
- RelationalComparatorFilter: Creates
a direct value injected filter. This filter does not use a parameter, but
operates similar to the
ComparatorFilter
.
Queries are created by instantiating and configuring and object, before passing it to the connection.
Some queries have shared logic and thus implement common traits.
- FilterableQueryTrait: This trait is implemented by queries that support filters.
- JoinableQueryTrait: This trait is implemented by queries that support joining multiple tables in a single query.
- PageableQueryTrait: This trait is
implemented by queries that support paging (
LIMIT
with(out) anOFFSET
). - SortableQueryTrait: This trait is implemented by queries that support sorting.
Some options and queries have a limitation in the options that can be passed to the object. Enums are used for this.
- ColumnAttributeEnum
- ColumnDefaultEnum
- ColumnTypeEnum
- ComparatorEnum
- IndexTypeEnum
- OperatorEnum
- ShowTypeEnum
- UnionEnum
The queries are sorted by their affecting goal. There are also a few standard queries which don't fit in any category.
- BatchQuery: Joins multiple queries for a single line execution.
- RawQuery: If none of the query object fit the bill, this object can be used to execute a custom query.
- AbstractTableQuery: Forms the base for the other table queries.
- AlterTableQuery
- CreateTableQuery
- DropTableQuery
Column operations are defined through:
Please see CHANGELOG for more information on what has changed recently.
Please see CONTRIBUTING and CODE_OF_CONDUCT for details.
Copyright (c) GrizzIT
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.