We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

How to bind to column value with Builder

Hello,

I want to bind a value to column with Phalcon\Mvc\Model\Query\Builder

public function findSomething($value)
{
    $this->getModelsManager()->createBuilder()
    ->columns(':value: as someValue, ...')
    // ->bind(['value' => $value])  // like this
    ->from(...)
    ->where(...)
}

Is there any way?

Best Regards,



93.7k
Accepted
answer
edited Apr '18

Hmm, you really want to have dynamic column names?

Try like this:

->execute([
    'value' => $value,
])
edited Apr '18

Thank you for your response.

I want to have dynamic column values. (not names)

In my example, column name is someValue.

Anyway, I will try it later.

Thanks.

Hello Nikolay,

It worked fine.

Thank you so much.