Ah, thank you! Perfect.
-- Phillip Winn -- http://blogcritics.org/ -- 214/402-9466 --


On Wed, Aug 19, 2009 at 3:48 PM, Hector Virgen <[email protected]> wrote:

> That's because objects are copied by reference in PHP. Use clone instead:
> $firstSelect = clone $baseSelect;
>
> --
> Hector
>
>
>
> On Wed, Aug 19, 2009 at 1:38 PM, Phillip Winn <[email protected]> wrote:
>
>> I would like to start with a base query and try first one where clause,
>> and if that fails, another. However, it seems that when changing what I
>> think is a copy of the select(), it changes both the copy and the original.
>> First I use:
>>
>> $baseSelect = $this->select()
>>     ->from($this, array())
>>     ->columns(...
>> [bunches of things, including joins, three wheres, and an order]
>>
>> At this point, an examination of $baseSelect shows everything as I expect
>> it. So I use:
>>
>> $firstSelect = $baseSelect;
>>
>> At this point, I'd expect both variables to be the same, and they are.
>>
>> What I don't expect is that further changes to $firstSelect also update
>> $baseSelect, but that's what happens.
>>
>> How can I create a *copy* of $baseSelect, so that if $firstSelect fails, I
>> don't have to build the entire select() again to get rid of the last where
>> clause?
>>
>>
>> ZF 1.9.0, PHP 5.2.6
>>
>> -- Phillip Winn -- http://blogcritics.org/ -- 214/402-9466 --
>>
>
>

Reply via email to