-
ExpressionInterface
JsonSerializable
(jsonSerialize()
)active()
raw()
data()
- GroupInterface
Iterator
/Traversable
type()
items()
conjunction()
add(ExpressionInterface $expression)
- FilterInterface
property()
val()
operator()
- OrderInterface
property()
mode()
value()
- PaginationInterface
page()
num()
(was: numPerPage())
- QueryInterface
- `filters()
orders()
pagination()
- DatabaseQueryInterface
sql()
pdoStatement(PDO $pdo)
-
DatabaseExpression
- DatabaseFilter
- DatabaseOrder
- DatabasePagination
- DatabaseQuery
Last active
October 6, 2017 13:58
-
-
Save mducharme/91691c1f4e292f77185798faf23fb242 to your computer and use it in GitHub Desktop.
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
<?php | |
$query = new DatabaseQuery(); | |
$query->setData([ | |
'filters' => [ | |
'property'=>'active', | |
'value' => 'true | |
], | |
'orders' => [ | |
], | |
'pagination' => [ | |
] | |
]); | |
$sql = $query->sql(); | |
echo $sql['query']; | |
// Alternative ways... | |
$query = new DatabaseQuery([ | |
]); | |
$query->filters()->add([ | |
'property' => | |
]); | |
$filter = new DatabaseFilter([ | |
'property' => 'active', | |
'value' => true | |
]); | |
$query->filter()->add($filter); | |
// With new CollectionLoader | |
$loader = new \Charcoal\Model\Service\CollectionLoader([ | |
'pdo' => $container['database'], | |
'model' => MyModel::class | |
]); | |
$transformer = function($model) | |
{ | |
$model['new-property'] = rand(0,100); | |
return $model; | |
}; | |
$models = $loader->loadModels($query, $transformer); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment