Ok, I found the problem:

For some reason when I use the beforeFind function, the first letter
of the sitename gets inserted into the read(); query. That's where the
'm' came from.

So the code works when there are no other conditions, but when there
are, it causes a problem.

My current code is:

        function beforeFind($queryData) {

        if ($this->hasField('sitename') && !in_array('sitename',
array_keys($queryData)) && !in_array($this->name . '.sitename',
array_keys($queryData)) {
                $queryData['conditions'][$this->name . '.sitename'] =
Configure::read('site');
        }

        return $queryData;

        }

Any idea what could cause this problem?

Sorry for the amount of posts in a row, b.t.w...

On 30 apr, 01:07, gerbenzomp <[EMAIL PROTECTED]> wrote:
> Your example works great, I only get errors when I go to /sitename/
> posts/view/
>
> For some reason the $this->Post->read(); query is executed like this:
> ... WHERE mPost`.`id` = '134' LIMIT 1
>
> No idea where the 'm' comes from, but it's gone when I remove the
> beforeFind(); function.
>
> Any ideas?
>
> On 29 apr, 22:29, gerbenzomp <[EMAIL PROTECTED]> wrote:
>
> > I still get the errors, even with your updated example.
>
> > To fix it, I changed:
> > array_keys($queryData['conditions'])
> > to:
> > array_keys($queryData)
>
> > Does that make sense?
>
> > A related question:
>
> > Is there a way to use the same method for changing the links sitewide
> > from:
>
> > /controller/action/
>
> > to:
>
> > /sitename/controller/action/
>
> > So the sitename is automatically used in each $html->link(); ?
>
> > That would be great!
>
> > On 29 apr, 19:28, "Mariano Iglesias" <[EMAIL PROTECTED]>
> > wrote:
>
> > > Oh yeah sorry, that's because I pasted an example from a behavior, change 
> > > it
> > > to:
>
> > > function beforeFind($queryData) {
> > >         if ($this->hasField('sitename') && !in_array('sitename',
> > > array_keys($queryData['conditions'])) && !in_array($this->name .
> > > '.sitename', array_keys($queryData['conditions']))) {
> > >                 $queryData['conditions'][$this->name . '.sitename'] =
> > > Configure::read('site');
> > >         }
>
> > >         return $queryData;
>
> > > }
>
> > > -MI
>
> > > ---------------------------------------------------------------------------
>
> > > Remember, smart coders answer ten questions for every question they ask.
> > > So be smart, be cool, and share your knowledge.
>
> > > BAKE ON!
>
> > > blog:http://www.MarianoIglesias.com.ar
>
> > > -----Mensaje original-----
> > > De: [email protected] [mailto:[EMAIL PROTECTED] En nombre
> > > de gerbenzomp
> > > Enviado el: Domingo, 29 de Abril de 2007 11:18 a.m.
> > > Para: Cake PHP
> > > Asunto: Re: Routing and FindAll();
>
> > > I added a field called "sitename" to the posts table and to some posts
> > > added the sitename value "mysite".


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to