Welcome Guest, Not a member yet? Register   Sign In
Nontrivial active records question
#1

[eluser]german.zvonchuk[/eluser]
The query itself is not complicated, I just wanted to write it using the Active records, without passing SQL code.

Using the array below, I need to make Active Records query, which will produce SQL code shown below.

Example array:
Code:
Array
(
    [id_item_type] => Array
        (
            [0] => 1
            [1] => 2
        )

    [id_street] => Array
        (
            [0] => 158
            [1] => 209
        )

    [id_item_target] => Array
        (
            [0] => 1
            [1] => 2
        )

)


Code:
SELECT COUNT(*) AS `numrows`
FROM (`item`)
WHERE
(`id_item_type` = '1'
OR `id_item_type` = '2')
AND
(`id_street` = '158'
OR `id_street` = '209')
AND
(`id_item_target` = '1'
OR `id_item_target` = '2')


Messages In This Thread
Nontrivial active records question - by El Forum - 01-06-2011, 02:45 AM
Nontrivial active records question - by El Forum - 01-06-2011, 02:48 AM
Nontrivial active records question - by El Forum - 01-06-2011, 04:18 AM
Nontrivial active records question - by El Forum - 01-06-2011, 06:50 AM
Nontrivial active records question - by El Forum - 01-06-2011, 07:02 AM



Theme © iAndrew 2016 - Forum software by © MyBB