public static function prepare($db, $query)
{
if (empty($db) || !$db instanceof Db) {
throw new InvalidArgumentException("Database handler not provided or is of wrong type");
}
if (!$query) {
throw new InvalidArgumentException("Query object not provided");
}
if (!$query->table) {
throw new InvalidArgumentException("Table name cannot be empty");
}
if (self::isEmptyResult($query)) {
return new EmptyQueryExecutor();
}
return new QueryExecutor($db, $query);
}