Zend 3/Laminas database select subqueries

I’ve been working on some refactoring of queries and got some trouble with making subqueries with TableGateway entity. Unfortunately there’s no solution for that on internets πŸ™ so I had to find it by myself:

$select = new Select();
$select->columns([
    'custom_column' => new Expression('?', [
        (new Select)
          ->...subselect query...
    ])
]);

As you can see it simply works with named params. When select see Query as a part of expression, it casts it to string.

Click to rate this post!
[Total: 1 Average: 5]

Π’Π°ΠΌ Ρ‚Π°ΠΊΠΆΠ΅ ΠΌΠΎΠΆΠ΅Ρ‚ ΠΏΠΎΠ½Ρ€Π°Π²ΠΈΡ‚ΡŒΡΡ

About the Author: deniskoronets

Π”ΠΎΠ±Π°Π²ΠΈΡ‚ΡŒ ΠΊΠΎΠΌΠΌΠ΅Π½Ρ‚Π°Ρ€ΠΈΠΉ

Π’Π°Ρˆ адрСс email Π½Π΅ Π±ΡƒΠ΄Π΅Ρ‚ ΠΎΠΏΡƒΠ±Π»ΠΈΠΊΠΎΠ²Π°Π½. ΠžΠ±ΡΠ·Π°Ρ‚Π΅Π»ΡŒΠ½Ρ‹Π΅ поля ΠΏΠΎΠΌΠ΅Ρ‡Π΅Π½Ρ‹ *