简体   繁体   中英

Zend DB select with literal

I have a sql statement with a union between two tables. For simplicity lets say that table A has a column called columnA and table B has a column called cloumnB . Since table A doesn't have a columnB in it and vice-versa, I want to place a static value for the records from table A in the union, something like this

$select->from ( array (
                'A' => 'tableA' 
        ), array (
                'id',
                'column1',
                .....
                'columnB' => "'nonExistingValue'",
                .....
        ) )

The problem is that Zend is searching for a column called nonExistingValue instead of treating it as a string literal. How can I make Zend treat this as a literal?

I ended up working it around like this:

$select->from ( array (
                'A' => 'tableA' 
        ), array (
                'id',
                'column1',
                .....
                'columnB' => "CONCAT('n','onExistingValue')",
                .....
        ) )

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM