Alter the conditions in a DatabaseCondition object Would there happen to be a way to alter the conditions in a DatabaseCondition object? Say I have this:

DatabaseCondition Object
(
    [conditions:protected] =&gt; Array
        (
            [#conjunction] =&gt; AND
            [0] =&gt; Array
                (
                    [field] =&gt; search_index.type
                    [value] =&gt; node
                    [operator] =&gt; =
                )

            [1] =&gt; Array
                (
                    [field] =&gt; DatabaseCondition Object
                        (
                            [conditions:protected] =&gt; Array
                                (
                                    [#conjunction] =&gt; OR
                                    [0] =&gt; Array
                                        (
                                            [field] =&gt; search_index.word
                                            [value] =&gt; foo
                                            [operator] =&gt; =
                                        )

                                    [1] =&gt; Array
                                        (
                                            [field] =&gt; search_index.word
                                            [value] =&gt; bar
                                            [operator] =&gt; =
                                        )

                                )

                            [arguments:protected] =&gt; Array
                                (
                                )

                            [changed:protected] =&gt; 1
                            [queryPlaceholderIdentifier:protected] =&gt; 
                        )

                    [value] =&gt; 
                    [operator] =&gt; IS NULL
                )

        )

    [arguments:protected] =&gt; Array
        (
        )

    [changed:protected] =&gt; 1
    [queryPlaceholderIdentifier:protected] =&gt; 
)


I would like to make changes on the conditions. Any ideas?
You can grab the conditions array for the full query like this:

$conditions =&amp; $query-&gt;conditions();


As you're getting the array by reference any changes you make to it (and the conditions within) will be reflected back on the query object before it's executed.

If you want to replace all of the conditions in the query you can simply overwrite that array with a new one (filled with conditions obviously).

It might be safer, though, to loop through the conditions array and remove/alter only the conditions that you need to change. This will make sure that conditions added by other modules will still get their chance to be included in the query.

Editing an existing condition is tricky (I haven't managed to get it to work yet though I haven't tried very hard!). I think your best bet is to rebuild the conditions you need to change from scratch and replace them rather than try to edit them directly.