Hi,
public static function deleteAll(){
$queryString = sprintf('DELETE FROM %s', self::getClass());
$query = new Model\Query($queryString);
$query->execute();
}
The code above does not works (because $query has no DI object). It doesnt throw errors eather, just silently drops request.
But if we use Model\Query\Builder to get Query object, $query will have proper DI object. So, this works:
public static function deleteAll(){
$queryString = sprintf('DELETE FROM %s', self::getClass());
$builder = new Model\Query\Builder();
$mocQuery = $builder->from(self::getClass())->getQuery();
$query = new Model\Query($queryString);
$query->setDi($mocQuery->GetDi())
$query->execute();
}
My questions is:
- Where Model\Query\Builder gets DI object?
- What is the correct way to make queries to DB from static methods like find or findFirst?