Problem with underscores

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|

Problem with underscores

Christian-64

Hi ev.

I am relatively new to cakePhp.

I am having some issue with models with underscores. Basically my whole
application was running fine under PHP 5 and I had to move it to PHP4
(4.3.10) 'cause of the hosting.

And now I was having all kind of errors with 2 models having underscore
in their names. After half a day I decided to remove the underscore.
And now it works.

So it's all right for the moment but I am quite unhappy about that.
Maybe it's my fault but I was wondering if anyone was aware of a
problem like that one.

I am using cakePhp 1.1.8.3544.

Thanks,

c.


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

Reply | Threaded
Open this post in threaded view
|

Re: Problem with underscores

John David Anderson (_psychic_)


On Nov 2, 2006, at 10:10 AM, Christian wrote:

>
> Hi ev.
>
> I am relatively new to cakePhp.
>
> I am having some issue with models with underscores. Basically my  
> whole
> application was running fine under PHP 5 and I had to move it to PHP4
> (4.3.10) 'cause of the hosting.

PHP isn't as good at dealing with classnames sometimes. The best way  
to make sure things will always work is to remember to add the $name  
var to your models and controllers.

(apple_jack.php)
class AppleJack extends AppModel
{
        var $name = 'AppleJack';
}

You might try that to see if it clears up any problems. If it  
doesn't, posting one of the error messages you're getting might be  
helpful.

-- John

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

Reply | Threaded
Open this post in threaded view
|

Re: Problem with underscores

Dieter@be

also iirc , findAllBy calls should look something like this in php4:
findAllByapple_jack()


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

Reply | Threaded
Open this post in threaded view
|

Re: Re: Problem with underscores

Samuel DeVore

findAllByApple_jack

On 11/2/06, Dieter@be <[hidden email]> wrote:
>
> also iirc , findAllBy calls should look something like this in php4:
> findAllByapple_jack()
>
>
> >
>


--
==
S. DeVore
(the old fart) the advice is free, the lack of crankiness will cost you

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

Reply | Threaded
Open this post in threaded view
|

Re: Problem with underscores

Christian-64

So when calling:
/my_controller/function.

And then if in my function I would try to do something like that:
$this->MyController->DoSomething()

I would then get his error message:
cakephp Call to a member function on a non-object

If I try to print_r on $this I would see that the object MyController
object was not created.

Then I changed the model and renamed the controller name to
Mycontroller and everything is fine. I.e. the object is created.

So for the moment I conclude that CakePhP is working better under PhP5.

c.


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

Reply | Threaded
Open this post in threaded view
|

Re: Problem with underscores

AD7six

On Nov 3, 9:59 am, "Christian" <[hidden email]> wrote:
> So for the moment I conclude that CakePhP is working better under PhP5.
>
> c.

That or .... that it works perfectly fine on Php4 (which is case
insensetive for class & function names) SO LONG AS you put var $name =
'CamelCase';  in your controllers/models/components etc. as _psychic_
put in the first thread of this reply ;).

HTH,

AD7six
 Please note:
The manual/bakery is a good place to start any quest for info.
The cake search (at the time of writing) erroneously reports less/no
results for the google group.
The wiki may contain incorrect info - read at your own risk (it's
mainly user submitted) :)
You may get your answer quicker by asking on the IRC Channel (you can
access it with just a browser here: http://irc.cakephp.org).

On Oct 31, 10:21 am, "georgeL" <[hidden email]> wrote:


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

Reply | Threaded
Open this post in threaded view
|

Re: Problem with underscores

Dieter@be

i don't have php4 so i can't check, but are you saying that putting var
$name = 'CamelCase' thing in your controllers/models/components etc
will suffice?
so you can call $this->Zebra->findByCamelCase in php4 as long as you do
the $name thing?

(better to make this sure, once and for all ;)

and if your ZebraController has var $uses = array('CamelCase','Zebra');
you only need to put the 'Zebra' in the $name var, right? not the other
models that the controller uses?


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

Reply | Threaded
Open this post in threaded view
|

Re: Re: Problem with underscores

Samuel DeVore

findBy I think you still have to findByCamel_case  if your model name
is CamelCase  in php4  (at least I do in my version)

see last comment in this thread
<http://groups.google.com/group/cake-php/browse_thread/thread/30aaee6b59a3a32f/2831ec4eeedb2a23?lnk=st&q=findby+nate&rnum=1#2831ec4eeedb2a23>


On 11/3/06, Dieter@be <[hidden email]> wrote:

>
> i don't have php4 so i can't check, but are you saying that putting var
> $name = 'CamelCase' thing in your controllers/models/components etc
> will suffice?
> so you can call $this->Zebra->findByCamelCase in php4 as long as you do
> the $name thing?
>
> (better to make this sure, once and for all ;)
>
> and if your ZebraController has var $uses = array('CamelCase','Zebra');
> you only need to put the 'Zebra' in the $name var, right? not the other
> models that the controller uses?
>
>
> >
>


--
==
S. DeVore
(the old fart) the advice is free, the lack of crankiness will cost you

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