n1crack / datatables

Simplify your Datatables server-side processing effortlessly using our lightning-fast PHP library, streamlining your workflow seamlessly.
https://datatables.ozdemir.be/
MIT License
267 stars 90 forks source link

Conditional where clauses for PhalconAdapter #80

Closed PollyCatZ closed 2 years ago

PollyCatZ commented 3 years ago

Hello friend, what if aliases and PhalconAdapter are used?

` $builder = $this->modelsManager->createBuilder()

->from(['o' => Orders::class])
->columns([
    'o.id as id', 
    'o.sticker as sticker',
    'o.status as status',
    'item.id as item_id',
    'item.name as item_name',
    'c.id as client_id',
    'c.phone as client_phone',
    'section.title as section_title',
    'cat.title as cat_title',
    'brand.title as brand_title',
])
->leftJoin(Items::class, 'item.barcode = o.barcode', 'item')
->leftJoin(Sections::class, 'section.id = item.section_id', 'section')
->leftJoin(Cats::class, 'cat.id = item.cat_id', 'cat')
->leftJoin(Brands::class, 'brand.id = item.brand_id', 'brand')
->leftJoin(Clients::class, 'c.id = o.client_id', 'c')
->getQuery()
->getSql();

$dt = new Datatables(new PhalconAdapter($this->di, 'db'));
$dt->query($builder['sql']);

$dt->filter('status', function ($status) {
    $this->log(123); //this code is not executed at all <<<<<<<<<<<<<<<<<<<<<<<<<<<
    return 'o.status = 1';
});

echo $dt->generate()->toJson();`
n1crack commented 2 years ago

That's because $this refers to FilterHelper class. If I have find free time, I will change it to normal behavior.