Re: Is there a way to avoid name collisions?

2007-05-23 Thread Chris Hartjes

On 5/23/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> I think this is something that should be mentioned in the Cake manual.
> How do I propose such a change in the manual?
>
> Jos
>

Well, I don't think it's the responsibility of the framework to
prevent namespace collisions.  It's good coding practice, which is
beyond the scope of CakePHP.

-- 
Chris Hartjes

My motto for 2007:  "Just build it, damnit!"

@TheBallpark - http://www.littlehart.net/attheballpark
@TheKeyboard - http://www.littlehart.net/atthekeyboard

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
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
-~--~~~~--~~--~--~---



Re: Is there a way to avoid name collisions?

2007-05-22 Thread [EMAIL PROTECTED]

I think this is something that should be mentioned in the Cake manual.
How do I propose such a change in the manual?

Jos


On May 22, 3:15 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
> > - Could it be the case that there was a name collision?
>
> Yes, there is a class called File in the cake core.
>
> > - Is there a way to avoid these collisions? If so, how?
>
> Yes there is. Print out the list of declared classes, and avoid those
> names. Put this code in one of your views:
> 
>
> That list show both cake and php classes, but it is not exhaustive, as
> it only show the classes that have been declared in that request. To
> see all cake classes simply look at the 
> api:http://api.cakephp.org/1.2/classes.htmlhttp://api.cakephp.org/classes.html
>
> Of course cakePHP is still evolving, so you may encounter collisions
> in future releases. To be completely safe, use Chris' suggestion and
> add a prefix to your class names.  I almost always use prefixes in
> components, helpers and... pretty much everything except models.
>
> Since most models are specific to a project, collisions should not be
> very common.  If you give your models specific names, then you are not
> likely to have a collision; File and Folder are the exceptions!
>
> cook
>
> On May 21, 8:18 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
> wrote:
>
>
>
>
>
> > I want to share my experience and I have a two questions.
>
> > But first my experience:
> > It took me a couple of days to find a bug I myself introduced in my
> > code.
>
> > I tried to make the 'log'-function work but what ever I did it raised
> > the following error:
> > Query: append
> > Warning: SQL Error: 1064: You have an error in your SQL syntax; check
> > the manual that corresponds to your MySQL server version for the right
> > syntax to use near 'append' at line 1 in C:\Program Files\xampplite
> > \htdocs\cake\cake\libs\model\datasources\dbo_source.php on line 476
>
> > At first I thought there was a bug in the Cake framework. So I filed a
> > bug,https://trac.cakephp.org/ticket/2593. He, don't blame
> > yourself  ;-)  Well it wasn't a bug, obviously.
>
> > I used a model called 'File' in my application. And that's where the
> > problem was, at least I think so.
> > File is a class used in the Cake framework. And I think this caused
> > some sort of namecollision with my own File-model. After changing my
> > File-model to another name the trouble disappeared. :-) :-) :-)
>
> > Now my questions:
> > - Could it be the case that there was a name collision?
> > - Is there a way to avoid these collisions? If so, how?
>
> > Back to coding,
> > Jos


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
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
-~--~~~~--~~--~--~---



Re: Is there a way to avoid name collisions?

2007-05-22 Thread [EMAIL PROTECTED]

> - Could it be the case that there was a name collision?
Yes, there is a class called File in the cake core.

> - Is there a way to avoid these collisions? If so, how?
Yes there is. Print out the list of declared classes, and avoid those
names. Put this code in one of your views:


That list show both cake and php classes, but it is not exhaustive, as
it only show the classes that have been declared in that request. To
see all cake classes simply look at the api:
http://api.cakephp.org/1.2/classes.html
http://api.cakephp.org/classes.html

Of course cakePHP is still evolving, so you may encounter collisions
in future releases. To be completely safe, use Chris' suggestion and
add a prefix to your class names.  I almost always use prefixes in
components, helpers and... pretty much everything except models.

Since most models are specific to a project, collisions should not be
very common.  If you give your models specific names, then you are not
likely to have a collision; File and Folder are the exceptions!

cook


On May 21, 8:18 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> I want to share my experience and I have a two questions.
>
> But first my experience:
> It took me a couple of days to find a bug I myself introduced in my
> code.
>
> I tried to make the 'log'-function work but what ever I did it raised
> the following error:
> Query: append
> Warning: SQL Error: 1064: You have an error in your SQL syntax; check
> the manual that corresponds to your MySQL server version for the right
> syntax to use near 'append' at line 1 in C:\Program Files\xampplite
> \htdocs\cake\cake\libs\model\datasources\dbo_source.php on line 476
>
> At first I thought there was a bug in the Cake framework. So I filed a
> bug,https://trac.cakephp.org/ticket/2593. He, don't blame
> yourself  ;-)  Well it wasn't a bug, obviously.
>
> I used a model called 'File' in my application. And that's where the
> problem was, at least I think so.
> File is a class used in the Cake framework. And I think this caused
> some sort of namecollision with my own File-model. After changing my
> File-model to another name the trouble disappeared. :-) :-) :-)
>
> Now my questions:
> - Could it be the case that there was a name collision?
> - Is there a way to avoid these collisions? If so, how?
>
> Back to coding,
> Jos


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
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
-~--~~~~--~~--~--~---



Re: Is there a way to avoid name collisions?

2007-05-22 Thread [EMAIL PROTECTED]

Thanks,
It helps!

On May 22, 3:20 am, "Chris Hartjes" <[EMAIL PROTECTED]> wrote:
> On 5/21/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> > Now my questions:
> > - Could it be the case that there was a name collision?
>
> Yes.
>
> > - Is there a way to avoid these collisions? If so, how?
>
> Until PHP has namespace support, avoid these collisions by prepending
> your classes and functions with a unique identifier.  In my case, it
> would be Grumpy_File instead of File.
>
> Hope that helps.
>
> --
> Chris Hartjes
>
> My motto for 2007:  "Just build it, damnit!"
>
> @TheBallpark -http://www.littlehart.net/attheballpark
> @TheKeyboard -http://www.littlehart.net/atthekeyboard


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
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
-~--~~~~--~~--~--~---



Re: Is there a way to avoid name collisions?

2007-05-21 Thread Chris Hartjes

On 5/21/07, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> Now my questions:
> - Could it be the case that there was a name collision?

Yes.

> - Is there a way to avoid these collisions? If so, how?
>

Until PHP has namespace support, avoid these collisions by prepending
your classes and functions with a unique identifier.  In my case, it
would be Grumpy_File instead of File.

Hope that helps.

-- 
Chris Hartjes

My motto for 2007:  "Just build it, damnit!"

@TheBallpark - http://www.littlehart.net/attheballpark
@TheKeyboard - http://www.littlehart.net/atthekeyboard

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
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
-~--~~~~--~~--~--~---



Is there a way to avoid name collisions?

2007-05-21 Thread [EMAIL PROTECTED]

I want to share my experience and I have a two questions.

But first my experience:
It took me a couple of days to find a bug I myself introduced in my
code.

I tried to make the 'log'-function work but what ever I did it raised
the following error:
Query: append
Warning: SQL Error: 1064: You have an error in your SQL syntax; check
the manual that corresponds to your MySQL server version for the right
syntax to use near 'append' at line 1 in C:\Program Files\xampplite
\htdocs\cake\cake\libs\model\datasources\dbo_source.php on line 476

At first I thought there was a bug in the Cake framework. So I filed a
bug, https://trac.cakephp.org/ticket/2593. He, don't blame
yourself  ;-)  Well it wasn't a bug, obviously.

I used a model called 'File' in my application. And that's where the
problem was, at least I think so.
File is a class used in the Cake framework. And I think this caused
some sort of namecollision with my own File-model. After changing my
File-model to another name the trouble disappeared. :-) :-) :-)

Now my questions:
- Could it be the case that there was a name collision?
- Is there a way to avoid these collisions? If so, how?

Back to coding,
Jos


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
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
-~--~~~~--~~--~--~---