Validation message from second model not being passed

2012-10-09 Thread Joel Howard
Hi all,

Long time CodeIgniter user coming to CakePHP...

I have been following the cake naming scheme and everything works 
awesome... except one thing.

I have a RequestRecord model/table and a RequestHistoryStatus model/table.

>From in my RequestRecords controller I am trying to validate/save a form 
that write to both tables.  I have setup the RequestRecord model as a 
"hasMany" relationship with the RequestHistoryStatus.

When I do:
$this->RequestRecord->saveAll($this->request->data, array('validate' => 
'only')) it does indeed validate both tables... however the error message 
from my RequestHistoryStatus model is not being passed.

How the validation is setup in the RequestHistoryStatus model:
public $validate = array(
'notes' => array(
'rule' => 'notEmpty',
'required' => true,
'allowEmpty' => false,
'on' => array('update', 'create'),
'message' => 'Please enter any notes for this request.'
));

Resulting array that is produced when the field fails validation:

Array
(
[link] => Array
(
[0] => Please enter a link.
)

[description] => Array
(
[0] => Please enter a description of the request.
)

[total_cost] => Array
(
[0] => Please enter the cost of the request.
)

[initial_support] => Array
(
[0] => Please indicate if initial support is provided or not.
)

[future_support] => Array
(
[0] => Please indicate if future support is required or not.
)

[delivery_location] => Array
(
[0] => Please select a delivery locatoin.
)

[delivery_person] => Array
(
[0] => Please enter a delivery person.
)

[tech_fee] => Array
(
[0] => Please select a tech fee.
)

[marketsite_non_vendor] => Array
(
[0] => Please select a Non Marketsite Vendor or "Not listed".
)

[vendor_address] => Array
(
[0] => Please enter the vendor's address.
)

[vendor_city] => Array
(
[0] => Please enterthe vendor's city.
)

[vendor_state] => Array
(
[0] => Please select the vendor's state.
)

[vendor_zip] => Array
(
[0] => Please enter the vendor's zip code.
)

[vendor_email] => Array
(
[0] => Please enter the vendor's e-mail address.
)

[vendor_phone] => Array
(
[0] => Please enter the vendor's phone number.
)

[RequestHistoryStatus] => Array
(
[notes] => Array
(
)

)

)



Any ideas? suggestions? or any more information needed?


Thanks!

-Joel

-- 
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

--- 
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.




Re: IDE

2010-12-21 Thread Joel Oliveira
Hey,

You can also use CodeLobster with the CakePHP plugin. Although the
CodeLobster is free, the CakePHP plugin is not; still you have a trial
period for the latter :)

Best regards,
Joel

2010/12/21 Felipe Roman 

> Hi Kristofer,
>
> I've been using NetBeans PHP[1] IDE, there are all IDE common features like
> code auto-complete, support SVN integration and also other Control Version
> tools.
>
> 1. php.netbeans.org
>
>
> On Tue, Dec 21, 2010 at 12:57 PM, Kristofer  wrote:
>
>> What IDE do people typically use with CakePHP?  I've been doing stuff
>> from the Linux command line using vim for so long.  I'd like something
>> more graphical that (hopefully) supports SVN.  Looking for more point-
>> and-click.  :)
>>
>> Check out the new CakePHP Questions site http://cakeqs.org and help
>> others with their CakePHP related questions.
>>
>> You received this message because you are subscribed to the Google Groups
>> "CakePHP" group.
>> To post to this group, send email to cake-php@googlegroups.com
>> To unsubscribe from this group, send email to
>> cake-php+unsubscr...@googlegroups.comFor
>>  more options, visit this group at
>> http://groups.google.com/group/cake-php?hl=en
>>
>
>
>
> --
> Best Regards,
> Felipe Roman
> Phone 55 51 8454 8110
> LinkedIn http://au.linkedin.com/in/feliperoman
>
>  Check out the new CakePHP Questions site http://cakeqs.org and help
> others with their CakePHP related questions.
>
> You received this message because you are subscribed to the Google Groups
> "CakePHP" group.
> To post to this group, send email to cake-php@googlegroups.com
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.comFor
>  more options, visit this group at
> http://groups.google.com/group/cake-php?hl=en
>

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Pagination Issue

2010-09-01 Thread Joel
Hello,

I have a website which was created for me using cake.php. There is a
pagination issue that I cannot figure out. When I click the second
page of the search results it links to the default page.

If you think you can help let me know and I will specify the issue
online.

Any help or advise would be much appreciated.

Thank you,

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: cake.icon.png missing from cake/console/templates/skel/webroot/img

2010-04-27 Thread Joel
I had a brain lapse and was unable to find the create ticket button in
cakephp.lighthouseapp.com

I have now created the ticket:

http://cakephp.lighthouseapp.com/projects/42648-cakephp-1x/tickets/637-cakeiconpng-missing-from-cakeconsoletemplatesskelwebrootimg

On Apr 28, 12:19 pm, Joel  wrote:
> Hi,
>
> I tried to create this ticket directly athttp://cakephp.lighthouseapp.com
> but it seems that only cakephp developers can create tickets these
> days.  I created a ticket a few weeks ago, but now the create ticket
> button has disappeared.
>
> When you create an app using cake bake, the cake.icon.png file is
> missing.  There is another cake icon as a gif, which I assume is an
> old file:
> cake/console/templates/skel/webroot/img/cake.icon.gif
>
> If you do a search for cake.icon.* you can see it is in 3 places.
>
> find . -name cake.icon.\*
> ./app/webroot/img/cake.icon.png
> ./cake/console/templates/skel/webroot/img/cake.icon.gif
> ./cake/tests/test_app/plugins/test_plugin/webroot/img/cake.icon.gif
>
> I'm guessing that the gif needs to be deleted and replaced the with
> png in the other 2 places?
>
> I am using CakePHP 1.3.0
>
> Cheers,
>
> -Joel
>
> Check out the new CakePHP Questions sitehttp://cakeqs.organd help others with 
> their CakePHP related questions.
>
> You received this message because you are subscribed to the Google Groups 
> "CakePHP" group.
> To post to this group, send email to cake-php@googlegroups.com
> To unsubscribe from this group, send email to
> cake-php+unsubscr...@googlegroups.com For more options, visit this group 
> athttp://groups.google.com/group/cake-php?hl=en

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


cake.icon.png missing from cake/console/templates/skel/webroot/img

2010-04-27 Thread Joel
Hi,

I tried to create this ticket directly at http://cakephp.lighthouseapp.com
but it seems that only cakephp developers can create tickets these
days.  I created a ticket a few weeks ago, but now the create ticket
button has disappeared.

When you create an app using cake bake, the cake.icon.png file is
missing.  There is another cake icon as a gif, which I assume is an
old file:
cake/console/templates/skel/webroot/img/cake.icon.gif

If you do a search for cake.icon.* you can see it is in 3 places.

find . -name cake.icon.\*
./app/webroot/img/cake.icon.png
./cake/console/templates/skel/webroot/img/cake.icon.gif
./cake/tests/test_app/plugins/test_plugin/webroot/img/cake.icon.gif

I'm guessing that the gif needs to be deleted and replaced the with
png in the other 2 places?

I am using CakePHP 1.3.0

Cheers,

-Joel

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Recommended application layout for application with multiple portals/interfaces?

2010-01-20 Thread Joel
Hi Greg,

How have setup your sub apps so they cake can find the config and the
models?  Are you using symbolic links or something?

I'm guessing you're not using the prefix routing to handle this?

Thanks,

-Joel

On Jan 21, 3:46 am, "Greg S."  wrote:
> Hi Joel,
>
> I'm experiencing the exact same problem right now.
>
> I've decided to split my app into several sub apps, sharing the same
> core, the same config files, and the same models.
>
> My directory structure looks like :
>
> -subapps
> --admin  <-- each of those is a CakePHP app folder
> --mobile
> --web
> --webservices
>
> -shared
> --cakephp <--cake core and vendors goes here
> --myapp  <-- shared config and models for all the sub apps
> ---config
> ---models
>
> -www
> --admin  <-- each of those is accessible as a subdomain,
> --mobile <-- example : mobile.myapp.com
> --web
> --webservices
> --shared <-- shared resources, like images, etc...
>
> So far, this works quite well, but it has some drawbacks. It breaks
> the cake bake console, for example, as it can't find the config files.
>
> If anyone has suggestions on this topic, I'll be glad to take them.
>
> Best,
>
> Greg
>
> On Jan 20, 5:06 am, Joel  wrote:
>
>
>
> > Hi,
>
> > I've used CakePHP for a few reasonably simple projects, but now I'm
> > about to start work on a project which is a bit more complicated.
> > This project is going to have 4 different interfaces depending on the
> > type of user. Ie Agent, Participant, Trainer and Admin.
>
> > Previously I have used the admin feature of CakePHP, which worked
> > great when there was the public site and the admin site.  But now with
> > 4 separate sites, but with significant amounts of shared code, I'm not
> > sure what the best way to layout the project is?
>
> > For example all of the portals will share the same model, but each
> > portal will have varying degrees of access to the data.
>
> > At work we use Java a lot, and if I was doing it in Java I'd probably
> > use a Session Bean to handle all the shared business logic, but such
> > concepts don't appear to directly exist in CakePHP.
>
> > I see that cakephp has vendors and plugins, but I'm not sure if that
> > is what they are meant for.  Plugins don't really seem to be the right
> > thing, because they appear to be quite independent.
> > But vendors also seem to be for encapsulated pieces of functionality.
>
> > Has anyone had any experience with multiple portals sharing the same
> > models and views (to some extent, maybe using Elements or something)?
>
> > Thanks,
>
> > -Joel
Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Recommended application layout for application with multiple portals/interfaces?

2010-01-19 Thread Joel
Hi,

I've used CakePHP for a few reasonably simple projects, but now I'm
about to start work on a project which is a bit more complicated.
This project is going to have 4 different interfaces depending on the
type of user. Ie Agent, Participant, Trainer and Admin.

Previously I have used the admin feature of CakePHP, which worked
great when there was the public site and the admin site.  But now with
4 separate sites, but with significant amounts of shared code, I'm not
sure what the best way to layout the project is?

For example all of the portals will share the same model, but each
portal will have varying degrees of access to the data.

At work we use Java a lot, and if I was doing it in Java I'd probably
use a Session Bean to handle all the shared business logic, but such
concepts don't appear to directly exist in CakePHP.

I see that cakephp has vendors and plugins, but I'm not sure if that
is what they are meant for.  Plugins don't really seem to be the right
thing, because they appear to be quite independent.
But vendors also seem to be for encapsulated pieces of functionality.

Has anyone had any experience with multiple portals sharing the same
models and views (to some extent, maybe using Elements or something)?

Thanks,

-Joel
Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscr...@googlegroups.com For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en


Re: Installation Problem: CakePHP 1.2.3.8166 on CENTOS and database.php

2009-05-19 Thread Joel Hughes

Using PHP 5.1.6 and mod_rewrite is enabled.

Everything works perfectly (htaccess, error reporting etc...) until
the database.php file is added - as if that's the problem - really
strange.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Validate HABTM

2009-03-02 Thread Joel

I have the same problem.

It saves automatically but validation won't run.  To me it seems like
the logical place to put these validation rules is on the join table
in the HABTM relationship.  Ie PostsTag model, but unfortunately it
doesn't run.

It's weird that it will happily save the data, but it won't validate
by default.

On Mar 2, 6:01 pm, Günther Theilen  wrote:
> Hi,
>
> thank for the answer.
>
> I read the blog entry before but it didn't seem to be the most elegant
> way because in teknoid's example the Post model is only validated if 
> thevalidationof the Tag model was ok.
>
> With the other model associations I got thevalidationof both models
> working by calling saveAll().
> Isn't that possible withHABTM?
>
> Regards
> Guenther
>
> brian schrieb:
>
> > Have a look here
>
> >http://teknoid.wordpress.com/?s=validate+habtm
>
> > On Fri, Feb 27, 2009 at 9:30 AM, Günther Theilen  wrote:
> >> Hi,
>
> >> maybe I'm a bit dull but I can't figure out what I'm doing wrong here.
> >> Maybe someone can help:
>
> >> I've got two models: FooHABTMBar.
>
> >> In foo_controller, add method I do this:
>
> >> $bar = $this->Foo->Bar->find('list');
> >> $this->set(compact('bar));
>
> >> In the foo/add view I have:
> >> $form->input('Bar', array('multiple' => 'checkbox'))
>
> >> Which works as I expected.
>
> >> Now I want to validate the checkboxes.
>
> >> In models/bar.php I added
> >> var $validate = array('Bar' => array('rule' => 'testRule'));
>
> >> function testRule() {
> >>   debug ("test");
> >>   die();
> >> }
>
> >> In foo_controller, add method I tried this:
> >> $this->Foo->save($this->data)
> >> and this:
> >> $this->Foo->saveAll($this->data)
> >> and this:
> >> $this->Foo->saveAll($this->data, array('validate' => 'first'))
>
> >> All my othervalidationrules in the Foo-model work perfectly but the
> >> rule in Bar doesn't seem to be triggered.
>
> >> Where is my mistake?
> >> Any hints?
>
> >> Regards
> >> Guenther
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~--~~~~--~~--~--~---



Re: Sanity Check: Many-to-Many Relationship Not Saving

2008-12-10 Thread Joel Perras

Create a model for your join table.

-J.

On Dec 10, 1:20 pm, Rob Wilkerson <[EMAIL PROTECTED]> wrote:
> On Dec 9, 9:13 pm, Rob Wilkerson <[EMAIL PROTECTED]> wrote:
>
> > Well...I don't know what the hell I did or how the hell I did it, but
> > it just started working.
>
> I just realized (while doing something else) what the problem was and
> I'm hoping someone can now help me understand why.
>
> The problem is that my linking table had a separate id field (DDL: id,
> nav_menu_id, nav_menu_item_id). I was using scaffolding to populate
> the linking table by accessing /nav_menus/edit/[some_menu_id] and
> selecting the menu items that I wanted to associate with the menu. My
> question is this: SHOULD the scaffolding recognize the additional
> primary key field and populate it with a GUID (it's a char(36) field)
> or is Cake's scaffolding not "smart" enough to do that?
>
> Just trying to get my head around what's possible and what's not to
> know whether I'm still doing something wrong.
>
> Thanks again.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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: Complex pagination (deep model assoc. & grouping)

2008-12-08 Thread Joel Perras
http://debuggable.com/posts/how-to-paginate-a-search-using-the-cakephp-framework:48fc5f77-38d0-41e0-b711-77c64834cda3

-J.

On Dec 8, 3:45 pm, martinp <[EMAIL PROTECTED]> wrote:
> Hello
>
> I'd be grateful for any advice on the best way to do this. (Cake 1.2
> RC3)
>
> I have a model Course, which BelongsTo School, which hasMany
> Accommodation.
> I want to be able to filter by courses, types of school and types of
> accommodation.
>
> The results also need to be paginated.
>
> I've set up my model binding like this:
>                 $this->Course->bindModel(
>                         array(
>                                 'belongsTo' => array(
>                                         'School' => array(
>                                                 'className' => 
> 'Schools.School',
>                                                 'foreignKey' => 'school_id'
>                                         )
>                                 ),
>                                 'hasOne' => array(
>                                         'Accommodation' => array(
>                                                 'className' => 
> 'Schools.Accommodation',
>                                                 'foreignKey' => false,
>                                                 'conditions' => 
> array('Accommodation.school_id =
> Course.school_id')
>                                         )
>                                 )
>                         ), false
>                 );
>
> The Course hasOne Accommodation rather than the School hasMany
> Accommodation to ensure that my accommodation results are returned and
> can be searched on.
>
> When I paginate I get a row for each accommodation as well as each
> course, i.e.:
>
>          [rows] => Array
>                 (
>                     [0] => Array
>                         (
>                             [Course] => Array
>                                 (
>                                     [id] => 44
>                                     [name] => Test course
>                                     [school_id] => 4
>                                 )
>
>                             [School] => Array
>                                 (
>                                     [id] => 4
>                                     [name] => Test School
>                                 )
>
>                             [Accommodation] => Array
>                                 (
>                                     [id] => 6
>                                     [school_id] => 4
>                                     [name] => Test Accommodation
>                                 )
>
>                         )
>
>                     [1] => Array
>                         (
>                             [Course] => Array
>                                 (
>                                     [id] => 44
>                                     [name] => Test course
>                                     [school_id] => 4
>
>                                 )
>
>                             [School] => Array
>                                 (
>                                     [id] => 4
>                                     [name] => Test School
>                                 )
>
>                             [Accommodation] => Array
>                                 (
>                                     [id] => 7
>                                     [school_id] => 4
>                                     [name] => Test Accommodation 2
>                                 )
>
>                         )
>                                 )
>
> What I'm looking to get is results 'grouped' by course, while still
> being able to filter by Accommodation field, e.g.:
>
>                 [rows] => Array
>                         (
>                                 [0] => Array
>                                         (
>                                                 [Course] => Array(...)
>                                                 [School] => Array(...)
>                                                 [Accommodation] => Array
>                                                         (
>                                                                 [0] => 
> Array(...)
>                                                                 [1] => 
> Array(...)
>                                                         )
>                                         )
>                         )
>
> What's the best way to achieve this? Create a custom pagination query
> and then somehow manipulate the resulting results array?
>
> This is what I've added to my Course model so far:
>
> function paginate($conditions, $fields, $order, $limit, $page = 1,
> $recursive = null, $extra = array()) {
>         $results = $this->find('all', array('conditions' => $conditions,
> 'fields' => $fields, 'order' => $order, 'limit' => $limit, 'page' =>
> $page, 'recursive' => $r

Re: Recursive decrypt

2008-12-03 Thread Joel Perras

If you mean on the behaviors of associated models, then no.
https://trac.cakephp.org/ticket/2056

-J.

On Dec 3, 9:00 am, Andraž <[EMAIL PROTECTED]> wrote:
> Does cake trigger callbacks on associated models?
>
> On 3 dec., 10:56, Andraž <[EMAIL PROTECTED]> wrote:
>
> > Any hint?
>
> > On 2 dec., 23:31, Andraž <[EMAIL PROTECTED]> wrote:
>
> > > Hello!
>
> > > I'm playing with Cipher behavior (http://bakery.cakephp.org/articles/
> > > view/cipher-behavior), but I have problems with recursive decrypt.
>
> > > What I must change in this function, that will work with recursive
> > > also?
>
> > > /** Model hook to decrypt model data if auto decipher is turned on in
> > > the
> > >     * model behavior configuration. Only primary model data are
> > > decrypted. */
> > >   function afterFind(&$model, $result, $primary = false) {
> > >     if (!$result || !isset($this->config[$model->name]['cipher']))
> > >       return $result;
>
> > >     if ($primary && $this->config[$model->name]['autoDecrypt']) {
> > >       // check for single of multiple model
> > >       $keys = array_keys($result);
> > >       if (!is_numeric($keys[0])) {
> > >         $this->decrypt(&$model, &$result);
> > >       } else {
> > >         foreach($keys as $index) {
> > >           $this->decrypt(&$model, &$result[$index]);
> > >         }
> > >       }
> > >     }
> > >     return $result;
> > >   }
>
> > > Regards Andraz - Open source specialist
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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: ORM, fetching related rows of corresponding model: undefined index..

2008-12-03 Thread Joel Perras

It's a typo, and a pretty obvious one.
change $question['Answer'] to $question['Question']['Answer'] and it
should be fine, assuming there are no other typos/errors (haven't
checked).

-J.

On Dec 3, 1:27 pm, Tanay <[EMAIL PROTECTED]> wrote:
> i have two dbs questions , and answers..
>
> corresponding models
>
> questions has many answers
> answers belogns to questions
>
> in questions_controller, i have this home function
>  function home() {
>           $this->Question->recursive = 1;
>           $this->set('questions', $this->Question->find('all'));
>        }
>
> in my home.ctp, i tried to show the corresponding answers using the
> code below
> i took a question from an array of questions using foreach
> foreach question, $question['Answer'] is expected to give array of
> answers, but it says  Undefined index:  Answer
> THAT LIne is marked in code below
>
> home.ctp:
>
>     
>        No Questions yet. Be the first one to
>                  post a Question!
>     
>        
>        
>                       ?>
>                      
>              link($question['Question']['question']
>     .'?', array('action' => 'show', $question['Question']['id']))); ?>
>                               $answer_count = count($question
> ['Answer']);   //  <<-ERROR HERE
>                 if(!$answer_count)
>                    e("(no answers yet)");
>                 else if($answer_count == 1)
>                    e("(1 answer)");
>                 else
>                    e("(".$answer_count." answers)");
>               ?>
>           
>        
>        
>     
>
> the above code is a part of project in book CakePHP application
> Development,
> the code is same as in book
> is it due to some different version of cakephp that author used?
> i use latest 1.2 version
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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: Load Helper in Console

2008-11-21 Thread Joel

No cigar:

PHP Fatal error:  Class 'Helper' not found in C:\html\cmhr\cake\libs
\view\helpers\app_helper.php on line 38

Fatal error: Class 'Helper' not found in C:\html\cmhr\cake\libs\view
\helpers\app_helper.php on line 38

On Nov 21, 12:00 pm, thatsgreat2345 <[EMAIL PROTECTED]> wrote:
> App::import('Helper','Time')? not a clue though
>
> On Nov 20, 2:26 pm, Joel <[EMAIL PROTECTED]> wrote:
>
> > $time = ClassRegistry::init('Helper', 'Time'); produces:
>
> > Warning: (ClassRegistry::init() could not create instance of Helper
> > class Time  in /home/jpearson/ZDE/workspace/cmhr/cake/libs/
> > class_registry.php on line 150
>
> >  App::import('TimeHelper','Helper');
> >  $time = new TimeHelper();
>
> > produces:
>
> > Fatal error: Class 'TimeHelper' not found in /home/jpearson/ZDE/
> > workspace/cmhr/app/vendors/shells/feedbackemail.php on line 12
>
> > Any other ideas?
>
> > On Nov 21, 2:06 am, "Renan Gonçalves" <[EMAIL PROTECTED]> wrote:
>
> > > ClassRegistry actually does not work with classes that have name 
> > > differente
> > > from the filename.
> > > Like TimeHelper the filename is time.php (should be time_helper.php to
> > > work).
>
> > > Use App::import to import the helper and then make a instance by yourself.
>
> > > Regards,
>
> > > On Thu, Nov 20, 2008 at 11:57 AM, Predominant <[EMAIL PROTECTED]> wrote:
>
> > > > I can't help you with your lunch issue...
> > > > But try:
>
> > > > $time = ClassRegistry::init('Helper', 'Time');
>
> > > > Cheers,
> > > > Graham Weldon
>
> > > > On Nov 20, 5:48 pm, Joel <[EMAIL PROTECTED]> wrote:
> > > > > Hi,
>
> > > > > I'm trying to load the TimeHelper from a console, but I'm not having
> > > > > much lunch.
>
> > > > > Can someone give me a pointer how to do this?
>
> > > > > I've tried:
> > > > > App::import('Helper','TimeHelper');
> > > > > App::import('TimeHelper');
>
> > > > > ClassRegistry::init('TimeHelper');
> > > > > ClassRegistry::init('Time', 'Helper');
> > > > > ClassRegistry::init('TimeHelper', 'Helper');
>
> > > > > $time = ClassRegistry::init('TimeHelper', 'Helper'); gives the error:
> > > > > Fatal error: Class 'Helper' not found in /home/jpearson/ZDE/workspace/
> > > > > cmhr/cake/libs/view/helpers/app_helper.php on line 40
>
> > > > > Thanks,
>
> > > > > -Joel
>
> > > --
> > > Renan Gonçalves aka renan.saddam
> > > Software Engineer - CakePHP Core Developer
> > > Cell Phone: +55 11 8633 6018
> > > MSN: [EMAIL PROTECTED]
> > > São Paulo - SP/Brazil
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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
-~--~~~~--~~--~--~---



Auth.redirect session value lost when linking from external site.

2008-11-20 Thread Joel

Hi,

I have a rather annoying problem in the last few days, after lots of
debugging I found it was a problem with the way php handles sessions
and how cakephp handles links coming in from external websites.

I created a bug in Trac here: https://trac.cakephp.org/ticket/5782

Here is the issue:

On http://locahost/test.html
I have a link to: http://127.0.0.1/cmhr/websites/browse/11/Drug_and_alcohol
cmhr is where cakephp is installed.

The websites controller is using the Auth component so then user is
redirected to an authentication page, but during the process the
session is lost again and cakephp no longer knows where it's supposed
to redirect to because Auth.redirect is gone so it redirects to the
HTTP_REFERER which is http://locahost/test.html after the user logs
in.

I did extensive debugging both using a PHP debugger, wireshark and
reading the php source code for sessions and I found out some
interesting things.

1. Go to http://locahost/test.html

2. Click on http://127.0.0.1/cmhr/websites/browse/11/Drug_and_alcohol
(with session cookie CAKEPHP=750c5ad36000dc5c773b3419e922aff1)
Referer: http://localhost/test.html

3. Cake php saves /websites/browse/11/Drug_and_alcohol into
Auth.redirect and sends a HTTP redirect (HTTP 1/1 302 Found, with
Location header) to http://127.0.0.1/cmhr/users/login (Server sets
Session cookie CAKEPHP=1f537fb5f5a1cdb3065920f05b128314)

4. Browser requests http://127.0.0.1/cmhr/users/login (with session
cookie CAKEPHP=1f537fb5f5a1cdb3065920f05b128314) Referer: 
http://localhost/test.html

5. Server sends back login page amd saves http://localhost/test.html
into Auth.redirect (Server sets Session cookie
CAKEPHP=5ee7d212148b93f5ca6c343808b9690d)

6. Browser posts response to http://127.0.0.1/cmhr/users/login (with
session cookie CAKEPHP=5ee7d212148b93f5ca6c343808b9690d) Referer:
http://127.0.0.1/cmhr/users/login

7. Server (CakePHP) sends back HTTP redirect to http://locahost/test.html

And the user is back where they started.

If you look above you'll notice that on step 5 php has changed the
session key and because it did that the original Auth.redirect was
lost, so when cakephp realises that it decides to use the http referer
instead which happens to be the external website.

I also verified this bug on book.cakephp.org, if you create a link
from an external site eg http://localhost/test.html to
http://book.cakephp.org/edit/526/How-it-Works you should be presented
with a login box, and then after you login you will be redirected
where you came from.  I confirmed this with my delicious account too.
Eg I bookmarked http://book.cakephp.org/edit/526/How-it-Works and then
click on the link, logged in and was redirected back to delicious.

I tried all sorts of things, but couldn't get around it, and in the
end I went as far as read php source code.
In ext/session/session.c I found the following comment:

 /* check whether the current request was referred to by
   an external site which invalidates the previously found id */

Which explains why the session changes on steps 3 and 5.

So to retain the Auth.redirect we have to work around php killing the
sessions.

I had 3 ideas off the top of my head:

1. We set an auth_redirect cookie when we detect that the referer
hostname is different to currrent hostname.  But the problem with this
is that we then loose the session flash message that says "You are not
authorized to access that location." or whatever is in $this-
>authError.  But we could probably get around it easily enough by
adding the authError message back in when we see the auth_redirect
cookie.

2. We append the auth redirect to the login url, ie: users/login?
authRedirect=/edit/526/How-it-Works.  This would probably be more
reliable especially if cookies are disabled, but it doesn't look as
good.  I don't think you would need the ?authRedirect in the form
action because the auth component could just add authRedirect back
into the session when the browser requests the login page after it
sends the 302 redirect.

3. Remove the http_referer, unfortunately I tried this and it didn't
seem to work for me.  It seems that php can still get access to the
http_referer even if we unset it from $_SERVER.


Cheers,

-Joel
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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: Load Helper in Console

2008-11-20 Thread Joel

$time = ClassRegistry::init('Helper', 'Time'); produces:

Warning: (ClassRegistry::init() could not create instance of Helper
class Time  in /home/jpearson/ZDE/workspace/cmhr/cake/libs/
class_registry.php on line 150

 App::import('TimeHelper','Helper');
 $time = new TimeHelper();

produces:

Fatal error: Class 'TimeHelper' not found in /home/jpearson/ZDE/
workspace/cmhr/app/vendors/shells/feedbackemail.php on line 12

Any other ideas?

On Nov 21, 2:06 am, "Renan Gonçalves" <[EMAIL PROTECTED]> wrote:
> ClassRegistry actually does not work with classes that have name differente
> from the filename.
> Like TimeHelper the filename is time.php (should be time_helper.php to
> work).
>
> Use App::import to import the helper and then make a instance by yourself.
>
> Regards,
>
>
>
> On Thu, Nov 20, 2008 at 11:57 AM, Predominant <[EMAIL PROTECTED]> wrote:
>
> > I can't help you with your lunch issue...
> > But try:
>
> > $time = ClassRegistry::init('Helper', 'Time');
>
> > Cheers,
> > Graham Weldon
>
> > On Nov 20, 5:48 pm, Joel <[EMAIL PROTECTED]> wrote:
> > > Hi,
>
> > > I'm trying to load the TimeHelper from a console, but I'm not having
> > > much lunch.
>
> > > Can someone give me a pointer how to do this?
>
> > > I've tried:
> > > App::import('Helper','TimeHelper');
> > > App::import('TimeHelper');
>
> > > ClassRegistry::init('TimeHelper');
> > > ClassRegistry::init('Time', 'Helper');
> > > ClassRegistry::init('TimeHelper', 'Helper');
>
> > > $time = ClassRegistry::init('TimeHelper', 'Helper'); gives the error:
> > > Fatal error: Class 'Helper' not found in /home/jpearson/ZDE/workspace/
> > > cmhr/cake/libs/view/helpers/app_helper.php on line 40
>
> > > Thanks,
>
> > > -Joel
>
> --
> Renan Gonçalves aka renan.saddam
> Software Engineer - CakePHP Core Developer
> Cell Phone: +55 11 8633 6018
> MSN: [EMAIL PROTECTED]
> São Paulo - SP/Brazil
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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: Load Helper in Console

2008-11-20 Thread Joel

And my lunch I mean luck ;-)

On Nov 20, 5:48 pm, Joel <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I'm trying to load the TimeHelper from a console, but I'm not having
> much lunch.
>
> Can someone give me a pointer how to do this?
>
> I've tried:
> App::import('Helper','TimeHelper');
> App::import('TimeHelper');
>
> ClassRegistry::init('TimeHelper');
> ClassRegistry::init('Time', 'Helper');
> ClassRegistry::init('TimeHelper', 'Helper');
>
> $time = ClassRegistry::init('TimeHelper', 'Helper'); gives the error:
> Fatal error: Class 'Helper' not found in /home/jpearson/ZDE/workspace/
> cmhr/cake/libs/view/helpers/app_helper.php on line 40
>
> Thanks,
>
> -Joel
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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
-~--~~~~--~~--~--~---



Load Helper in Console

2008-11-19 Thread Joel

Hi,

I'm trying to load the TimeHelper from a console, but I'm not having
much lunch.

Can someone give me a pointer how to do this?

I've tried:
App::import('Helper','TimeHelper');
App::import('TimeHelper');

ClassRegistry::init('TimeHelper');
ClassRegistry::init('Time', 'Helper');
ClassRegistry::init('TimeHelper', 'Helper');

$time = ClassRegistry::init('TimeHelper', 'Helper'); gives the error:
Fatal error: Class 'Helper' not found in /home/jpearson/ZDE/workspace/
cmhr/cake/libs/view/helpers/app_helper.php on line 40

Thanks,

-Joel
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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: regarding Auth Component..

2008-11-17 Thread Joel Perras

Seems like you might be mixing authorization and authentication to me.
Are you using ACL ?


On 17 Nov, 06:17, "Liebermann, Anja Carolin"
<[EMAIL PROTECTED]> wrote:
> And  would the group id be
> $this->Auth->group('id');
> ?
>
> Anja
>
> -Ursprüngliche Nachricht-
> Von: cake-php@googlegroups.com [mailto:[EMAIL PROTECTED] Im Auftrag von 
> thatsgreat2345
> Gesendet: Donnerstag, 13. November 2008 17:35
> An: CakePHP
> Betreff: Re: regarding Auth Component..
>
> For just id $this->Auth->user('id');
>
> On Nov 13, 6:32 am, "dr. Hannibal Lecter" <[EMAIL PROTECTED]> wrote:
>
> > See the value of $this->Auth->user()
>
> > Hope that helps!
>
> > On Nov 13, 9:45 am, Abhishek <[EMAIL PROTECTED]> wrote:
>
> > > Hi,
> > > Am using auth component for user authentication ...
>
> > > How do i fetch the value of the id of the user who has been
> > > validated by the Auth Component for use in any of the controller
> > > functions ..
>
> > > Regards
> > > Abhishek
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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: How to add colour to product? [Models associations/relations, habtm?]

2008-11-17 Thread Joel Perras

http://teknoid.wordpress.com/2008/07/11/notes-on-cakephp-habtm-part-2-saving-data/

-J.

On 17 Nov, 07:00, Hipnotik <[EMAIL PROTECTED]> wrote:
> Hi Anja,
> thanks for your reply.
>
> My first idea how to do that was same as your... but I started to
> think of it and there should be "a more clever" way, I think.
>
> On 17 Lis, 12:04, "Liebermann, Anja Carolin"
>
> <[EMAIL PROTECTED]> wrote:
> > Hi Hipnotik,
>
> > You would need a controller and model for the realtion also.
>
> > I have the same situation with some of my models and work woth a third 
> > model which gives me the connection between then like Conncolourproduct.php 
> > and conncolourproducts_controller.php
>
> > Maybe someone has a more clever solution?
>
> > Anja
>
> > -Ursprüngliche Nachricht-
> > Von: cake-php@googlegroups.com [mailto:[EMAIL PROTECTED] Im Auftrag von 
> > Hipnotik
> > Gesendet: Montag, 17. November 2008 11:13
> > An: CakePHP
> > Betreff: How to add colour to product? [Models associations/relations, 
> > habtm?]
>
> > I have problem.
> > I have 3 tables:
> > 1. products
> > 2. colours
> > 3. colours_products
>
> > There are also 2 models:
> > 1. Product
> > 2. Colour
> > with set up associations
> > Product model: var $hasAndBelongsToMany = array("Colour"); Colour model: 
> > var $hasAndBelongsToMany = array("Product");
>
> > I created a view with form with 2 select boxes where the first one contain 
> > products list and second available colours. I would like to select a 
> > product then select a colour and click on Save button to save
> > product->colour relation. I have a controller to display data but I
> > don't know how to create proper add action.
>
> > How to save data from form like this?
> > How form initialization line should be looking (I mean echo $form-
>
> > >create("Colour", array("action"=>"add"));)?
>
> > Thanks for help
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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: Inconsistency between displaying validation errors and validating with model.saveAll()

2008-11-07 Thread Joel

Oh it does work.  I didn't realise that saveAll expected $this-
>data['ModelName']

Sorry my bad.

Maybe I should contribute some documentation!

On Nov 8, 3:05 pm, Joel <[EMAIL PROTECTED]> wrote:
> Hmm I already tried Model.id.field,  but it doesn't work for me.
>
> I changed my view to so that it is generating html like so:
>
>  id="UserAnswer1Value">
>
> But instead of showing validation errors I get this error up the top
> of the page:
>
> Warning (2): preg_match() expects parameter 2 to be string, array
> given [CORE\cake\libs\validation.php, line 876]
>
> Maybe I need to try the latest SVN instead of RC3?
>
> Also my UserAnswer model doesn't have any belongs to relations, if
> that helps.  Because the fix forhttps://trac.cakephp.org/ticket/4981
> only seems to apply to belongs to relations.
>
> On Nov 8, 1:49 am, mark_story <[EMAIL PROTECTED]> wrote:
>
> > I closed your ticket, as I didn't have any troubles with using form
> > helper and saveAll(). Like teknoid said Model.1.field is the correct
> > format for multi record forms.  I closed the ticket with additional
> > information.  Perhaps this should be documented better?
>
> > -Mark
>
> > On Nov 6, 8:04 pm, Joel <[EMAIL PROTECTED]> wrote:
>
> > > For reference I have created a ticket in trac 
> > > here:https://trac.cakephp.org/ticket/5715
>
> > > On Nov 6, 5:23 pm, Joel <[EMAIL PROTECTED]> wrote:
>
> > > > Hi,
>
> > > > I've run into a frustrating problem, I'm trying to validate an array
> > > > of the same type of model, but the
>
> > > > I have used the name convention as suggested 
> > > > here:http://manual.cakephp.org/complete/181/Core-Helpers#Field-naming-conv...
>
> > > > eg:
>
> > > >  > > >    echo $form->input('fieldname.1');
> > > >    echo $form->input('fieldname.2');
> > > > ?>
> > > > 
> > > > 
>
> > > > The problem is when I do model.saveAll() it screws up because it
> > > > expects the data in this format:
> > > > data[1][Modelname][fieldname]
> > > > data[2][Modelname][fieldname]
>
> > > > I know that is the expected model because of the comment above the
> > > > saveAll function:
> > > > @param array $data Record data to save.  This can be either a
> > > > numerically-indexed array (for saving multiple records of the same
> > > > type), or an array indexed by association name.
>
> > > > But validation errors won't display in the saveAll format.
>
> > > > Because validationErrors array ends up looking like:
> > > > [ModelName][1][field] = "error message"
> > > > [ModelName][2][field] = "error message"
>
> > > > But for the FormHelper to display the errors it needs to look like
> > > > this:
> > > > [ModelName][field][1] = "error message"
> > > > [ModelName][field][2] = "error message"
>
> > > > So I have managed to work around it by using this in the view:
> > > >    echo $form->input('Model.fieldname.1');
> > > >    echo $form->input('Model.fieldname.2');
>
> > > > And then I have a function that converts the $this->data for saveAll:
>
> > > >    function _prepareDataForValidation($data) {
> > > >       $fixedData = array();
>
> > > >       foreach ($data as $model => $fields) {
> > > >          foreach ($fields as $field => $values) {
> > > >             foreach ($values as $id => $value) {
> > > >                $fixedData[$id][$model][$field] = $value;
> > > >             }
> > > >          }
> > > >       }
>
> > > >       return $fixedData;
> > > >    }
>
> > > > And another function that puts the validationErrors in the right
> > > > format:
>
> > > >    function _fixValidationErrorsArray($validationErrors) {
> > > >       $newValidationErrors = array();
>
> > > >       foreach($validationErrors as $key => $fields) {
> > > >          foreach ($fields as $field => $value) {
> > > >                 $newValidationErrors[$field][$key] = $value;
> > > >          }
> > > >       }
>
> > > >       return $newValidationErrors;
> > > >    }
>
> > > > Should I log this as a bug in trac?
>
> > > > I really think FormHelper should be changed to be in this format:
>
> > > >  > > >    echo $form->input('Model.1.fieldname');
> > > >    echo $form->input('Model.2.fieldname');
> > > > ?>
>
> > > > instead of
>
> > > >  > > >    echo $form->input('Model.fieldname.1');
> > > >    echo $form->input('Model.fieldname.2');
> > > > ?>
>
> > > >https://trac.cakephp.org/ticket/4981issimilartothis, except I
> > > > don't have the belongs to association.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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: Inconsistency between displaying validation errors and validating with model.saveAll()

2008-11-07 Thread Joel

Hmm I already tried Model.id.field,  but it doesn't work for me.

I changed my view to so that it is generating html like so:



But instead of showing validation errors I get this error up the top
of the page:

Warning (2): preg_match() expects parameter 2 to be string, array
given [CORE\cake\libs\validation.php, line 876]

Maybe I need to try the latest SVN instead of RC3?

Also my UserAnswer model doesn't have any belongs to relations, if
that helps.  Because the fix for https://trac.cakephp.org/ticket/4981
only seems to apply to belongs to relations.

On Nov 8, 1:49 am, mark_story <[EMAIL PROTECTED]> wrote:
> I closed your ticket, as I didn't have any troubles with using form
> helper and saveAll(). Like teknoid said Model.1.field is the correct
> format for multi record forms.  I closed the ticket with additional
> information.  Perhaps this should be documented better?
>
> -Mark
>
> On Nov 6, 8:04 pm, Joel <[EMAIL PROTECTED]> wrote:
>
> > For reference I have created a ticket in trac 
> > here:https://trac.cakephp.org/ticket/5715
>
> > On Nov 6, 5:23 pm, Joel <[EMAIL PROTECTED]> wrote:
>
> > > Hi,
>
> > > I've run into a frustrating problem, I'm trying to validate an array
> > > of the same type of model, but the
>
> > > I have used the name convention as suggested 
> > > here:http://manual.cakephp.org/complete/181/Core-Helpers#Field-naming-conv...
>
> > > eg:
>
> > >  > >    echo $form->input('fieldname.1');
> > >    echo $form->input('fieldname.2');
> > > ?>
> > > 
> > > 
>
> > > The problem is when I do model.saveAll() it screws up because it
> > > expects the data in this format:
> > > data[1][Modelname][fieldname]
> > > data[2][Modelname][fieldname]
>
> > > I know that is the expected model because of the comment above the
> > > saveAll function:
> > > @param array $data Record data to save.  This can be either a
> > > numerically-indexed array (for saving multiple records of the same
> > > type), or an array indexed by association name.
>
> > > But validation errors won't display in the saveAll format.
>
> > > Because validationErrors array ends up looking like:
> > > [ModelName][1][field] = "error message"
> > > [ModelName][2][field] = "error message"
>
> > > But for the FormHelper to display the errors it needs to look like
> > > this:
> > > [ModelName][field][1] = "error message"
> > > [ModelName][field][2] = "error message"
>
> > > So I have managed to work around it by using this in the view:
> > >    echo $form->input('Model.fieldname.1');
> > >    echo $form->input('Model.fieldname.2');
>
> > > And then I have a function that converts the $this->data for saveAll:
>
> > >    function _prepareDataForValidation($data) {
> > >       $fixedData = array();
>
> > >       foreach ($data as $model => $fields) {
> > >          foreach ($fields as $field => $values) {
> > >             foreach ($values as $id => $value) {
> > >                $fixedData[$id][$model][$field] = $value;
> > >             }
> > >          }
> > >       }
>
> > >       return $fixedData;
> > >    }
>
> > > And another function that puts the validationErrors in the right
> > > format:
>
> > >    function _fixValidationErrorsArray($validationErrors) {
> > >       $newValidationErrors = array();
>
> > >       foreach($validationErrors as $key => $fields) {
> > >          foreach ($fields as $field => $value) {
> > >                 $newValidationErrors[$field][$key] = $value;
> > >          }
> > >       }
>
> > >       return $newValidationErrors;
> > >    }
>
> > > Should I log this as a bug in trac?
>
> > > I really think FormHelper should be changed to be in this format:
>
> > >  > >    echo $form->input('Model.1.fieldname');
> > >    echo $form->input('Model.2.fieldname');
> > > ?>
>
> > > instead of
>
> > >  > >    echo $form->input('Model.fieldname.1');
> > >    echo $form->input('Model.fieldname.2');
> > > ?>
>
> > >https://trac.cakephp.org/ticket/4981issimilarto this, except I
> > > don't have the belongs to association.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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: Inconsistency between displaying validation errors and validating with model.saveAll()

2008-11-06 Thread Joel

For reference I have created a ticket in trac here:
https://trac.cakephp.org/ticket/5715

On Nov 6, 5:23 pm, Joel <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I've run into a frustrating problem, I'm trying to validate an array
> of the same type of model, but the
>
> I have used the name convention as suggested 
> here:http://manual.cakephp.org/complete/181/Core-Helpers#Field-naming-conv...
>
> eg:
>
> echo $form->input('fieldname.1');
>echo $form->input('fieldname.2');
> ?>
> 
> 
>
> The problem is when I do model.saveAll() it screws up because it
> expects the data in this format:
> data[1][Modelname][fieldname]
> data[2][Modelname][fieldname]
>
> I know that is the expected model because of the comment above the
> saveAll function:
> @param array $data Record data to save.  This can be either a
> numerically-indexed array (for saving multiple records of the same
> type), or an array indexed by association name.
>
> But validation errors won't display in the saveAll format.
>
> Because validationErrors array ends up looking like:
> [ModelName][1][field] = "error message"
> [ModelName][2][field] = "error message"
>
> But for the FormHelper to display the errors it needs to look like
> this:
> [ModelName][field][1] = "error message"
> [ModelName][field][2] = "error message"
>
> So I have managed to work around it by using this in the view:
>echo $form->input('Model.fieldname.1');
>echo $form->input('Model.fieldname.2');
>
> And then I have a function that converts the $this->data for saveAll:
>
>function _prepareDataForValidation($data) {
>   $fixedData = array();
>
>   foreach ($data as $model => $fields) {
>  foreach ($fields as $field => $values) {
> foreach ($values as $id => $value) {
>$fixedData[$id][$model][$field] = $value;
> }
>  }
>   }
>
>   return $fixedData;
>}
>
> And another function that puts the validationErrors in the right
> format:
>
>function _fixValidationErrorsArray($validationErrors) {
>   $newValidationErrors = array();
>
>   foreach($validationErrors as $key => $fields) {
>  foreach ($fields as $field => $value) {
> $newValidationErrors[$field][$key] = $value;
>  }
>   }
>
>   return $newValidationErrors;
>}
>
> Should I log this as a bug in trac?
>
> I really think FormHelper should be changed to be in this format:
>
> echo $form->input('Model.1.fieldname');
>echo $form->input('Model.2.fieldname');
> ?>
>
> instead of
>
> echo $form->input('Model.fieldname.1');
>echo $form->input('Model.fieldname.2');
> ?>
>
> https://trac.cakephp.org/ticket/4981is similar to this, except I
> don't have the belongs to association.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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
-~--~~~~--~~--~--~---



Inconsistency between displaying validation errors and validating with model.saveAll()

2008-11-05 Thread Joel

Hi,

I've run into a frustrating problem, I'm trying to validate an array
of the same type of model, but the

I have used the name convention as suggested here:
http://manual.cakephp.org/complete/181/Core-Helpers#Field-naming-convention-547

eg:

input('fieldname.1');
   echo $form->input('fieldname.2');
?>



The problem is when I do model.saveAll() it screws up because it
expects the data in this format:
data[1][Modelname][fieldname]
data[2][Modelname][fieldname]

I know that is the expected model because of the comment above the
saveAll function:
@param array $data Record data to save.  This can be either a
numerically-indexed array (for saving multiple records of the same
type), or an array indexed by association name.

But validation errors won't display in the saveAll format.

Because validationErrors array ends up looking like:
[ModelName][1][field] = "error message"
[ModelName][2][field] = "error message"

But for the FormHelper to display the errors it needs to look like
this:
[ModelName][field][1] = "error message"
[ModelName][field][2] = "error message"

So I have managed to work around it by using this in the view:
   echo $form->input('Model.fieldname.1');
   echo $form->input('Model.fieldname.2');

And then I have a function that converts the $this->data for saveAll:

   function _prepareDataForValidation($data) {
  $fixedData = array();

  foreach ($data as $model => $fields) {
 foreach ($fields as $field => $values) {
foreach ($values as $id => $value) {
   $fixedData[$id][$model][$field] = $value;
}
 }
  }

  return $fixedData;
   }

And another function that puts the validationErrors in the right
format:

   function _fixValidationErrorsArray($validationErrors) {
  $newValidationErrors = array();

  foreach($validationErrors as $key => $fields) {
 foreach ($fields as $field => $value) {
$newValidationErrors[$field][$key] = $value;
 }
  }

  return $newValidationErrors;
   }

Should I log this as a bug in trac?

I really think FormHelper should be changed to be in this format:

input('Model.1.fieldname');
   echo $form->input('Model.2.fieldname');
?>

instead of

input('Model.fieldname.1');
   echo $form->input('Model.fieldname.2');
?>

https://trac.cakephp.org/ticket/4981 is similar to this, except I
don't have the belongs to association.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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: Naming a Model "Model"

2008-11-04 Thread Joel Perras

The API has a list of all the classes found in CakePHP:
http://api.cakephp.org/classes.html . Steer away from any of those
names.

-J.


On Nov 4, 7:30 pm, Pyrite <[EMAIL PROTECTED]> wrote:
> Is there a list of reserved table names and/or model names?
>
> On Nov 4, 4:48 pm, Sam DeVore <[EMAIL PROTECTED]> wrote:
>
> > Bust out the thesaurus it's reserved
>
> > ===
> > Sent from my AT&T Rotary Phonehttp://blog.samdevore.com
>
> > On Nov 4, 2008, at 2:54 PM, Pyrite <[EMAIL PROTECTED]> wrote:
>
> > > I am developing an application for a business, they have categories,
> > > products, and models. Is it a problem for CakePHP to name the database
> > > table "models" and the actual model "Model", or do I need to think of
> > > a different term?- Hide quoted text -
>
> > - Show quoted text -
>
>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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: Whats the best idea to keep DB under version control or under sync with server?

2008-10-30 Thread Joel Perras

Take a look at the built-in Cake schema shell.

$ cake schema help

-J.

On Oct 30, 8:21 am, Abhimanyu Grover <[EMAIL PROTECTED]> wrote:
> I'm sorry this is not Cake related, but I feel its something which
> most of developers are missing. I found info about Cake migrations and
> think it would be too difficult to implement it in my team in short
> time. What tools or techniques are you using to overcome this problem?
>
> I'm aware of a tool called SqlYog or something, which is capable of
> keeping database structured sync'ed from dev. machine to server, but
> its paid, and I'm looking for some open source alternative, maybe a
> simple PHP script or something. Please let me know what do you guys
> use and recommend for a small team?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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: Problems with international (i18n) character set

2008-10-23 Thread Joel Perras

Have you tried to set the application encoding?

// app/config/core.php
Configure::write('App.encoding', 'Latin-1');

-J.

On Oct 23, 3:00 pm, bluepuma <[EMAIL PROTECTED]> wrote:
> Just upgraded to CakePHP 1.2.0.7692 RC3 but still have an issue with
> text fields containing i18n characters.
>
> In MySQL the field is set to TEXT and filled with Umlaute
> (CHARSET=latin1 COLLATE latin1_german1_ci) via $model->save($entry),
> the CakePHP view and edit action render the field, but without the
> i18n content from the database, the textfield is just empty.
>
> I can copy the text from phpMyAdmin and enter and save it in the
> textfield in Cake, the new data will overwrite the existing one, but
> strange characters appear instead of the original i18n ones.
>
> Any idea how to deal correctly with international character sets in
> CakePHP?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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: Controller Action Testing

2008-10-22 Thread Joel Perras

Two things:

1) I would suggest using the more fully qualified format of
testAction: testAction(array('controller'=>'galleries', 'action' =>
'show', 'xyz')); For simple requests both formats should be identical,
but the latter will be more useful when you start applying more
complex routing schemes.

2) If your controller method being tested calls Controller::redirect()
at any time, the test exit without any warning. This is because the
redirect method was refactored some time ago to call Object::_stop()
upon completion (a smart thing, IMHO), which is actually just a
wrapper for exit(). You can get around this by overriding the _stop
method in your app_controller, but only for test execution:

/**
* Override of Object::_stop.
*
* For unit testing of controllers.
*
* @param integer $status
* @return mixed Null if testing, execution of Object::_stop otherwise.
*/
function _stop($status = 0) {

  if (defined('CAKEPHP_UNIT_TEST_EXECUTION') &&
CAKEPHP_UNIT_TEST_EXECUTION == 1) {
  return;
  }
  else return parent::_stop();
}


hth.

-J.


On Oct 22, 8:11 pm, "[EMAIL PROTECTED]"
<[EMAIL PROTECTED]> wrote:
> Hi,
>
> today i tried to implement some testing classes in my project. But i
> can't ge t them run the right way.
>
> For example this simple test method:
> The first test calls the show action with a string that should fail
> and redirect. The second test with an integer as parameter should run
> correctly.
>
> function testShowAction() {
>         $this->testAction('/galleries/show/xyz');
>         $this->assertResponse(REDIRECT);
>         $this->testAction('/galleries/show/2');
>         $this->assertResponse(SUCCESS);
>
> }
>
> When i call this method in the "myproject/test.php" it redirects me to
> the gallery and exit the test.
> Whats the right way to test an controller action ?
>
> Best Regards
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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: Recursive HBTM relationship - Problem

2008-10-18 Thread Joel Perras

You're overwriting array keys. Name the association something
different (but keep the className pointing to the proper model), and
you'll be on your way.

-J.


On Oct 18, 12:05 am, imu <[EMAIL PROTECTED]> wrote:
> Hi,
> I have problem with ORM (m-n) to relationship.
>
> http://farm4.static.flickr.com/3171/2950137747_b098638c67.jpg?v=0 ERD
> image
>
> The table categories is  related to itself using m-n relationship. To
> make this possible I created a new mapping table called as
> categories_categories.
>
> This is the HBTM I came up with
> ---
> var $hasAndBelongsToMany = array(
>         'Category' => array(
>                                         'className' => 'Category',
>                                         'joinTable' => 
> 'categories_categories',
>                                         'foreignKey' => 'parent_category_id',
>                                         'associationForeignKey' => 
> 'child_category_id',
>                                         'conditions' => '',
>                                         'order' => '',
>                                         'limit' => '',
>                                         'unique' => true,
>                                         'finderQuery' => '',
>                                         'deleteQuery' => '',
>                                         'insertQuery' => ''
>                                         ),
>         'Category' => array(
>                                         'className' => 'Category',
>                                         'joinTable' => 
> 'categories_categories',
>                                         'foreignKey' => 'child_category_id',
>                                         'associationForeignKey' =>
> 'parent_category_id',
>                                         'conditions' => '',
>                                         'order' => '',
>                                         'limit' => '',
>                                         'unique' => true,
>                                         'finderQuery' => '',
>                                         'deleteQuery' => '',
>                                         'insertQuery' => ''
>                                         )
>         );
> --
>
> I think I didnt get the relationshp right. And ended up with this
> error (below).
>
> --
>
> Warning (512): SQL Error: 1048: Column 'parent_category_id' cannot be
> null [CORE/cake/libs/model/datasources/dbo_source.php, line 521]
>
> Code | Context
>
> $sql    =       "INSERT INTO `categories_categories`
> (`parent_category_id`,`child_category_id`) VALUES (NULL,'1')"
> $error  =       "1048: Column 'parent_category_id' cannot be null"
> $out    =       null
>
>             $out = null;
>             if ($error) {
>                 trigger_error(" align:left\">SQL Error: {$this->error}",
> E_USER_WARNING);
>
> DboSource::showQuery() - CORE/cake/libs/model/datasources/
> dbo_source.php, line 521
> DboSource::execute() - CORE/cake/libs/model/datasources/
> dbo_source.php, line 208
> DboSource::fetchAll() - CORE/cake/libs/model/datasources/
> dbo_source.php, line 344
> DboSource::query() - CORE/cake/libs/model/datasources/dbo_source.php,
> line 228
> DboMysql::insertMulti() - CORE/cake/libs/model/datasources/dbo/
> dbo_mysql.php, line 502
> Model::__saveMulti() - CORE/cake/libs/model/model.php, line 1254
> Model::save() - CORE/cake/libs/model/model.php, line 1180
> Scaffold::__scaffoldSave() - CORE/cake/libs/controller/scaffold.php,
> line 298
> Scaffold::__scaffold() - CORE/cake/libs/controller/scaffold.php, line
> 424
> Scaffold::__construct() - CORE/cake/libs/controller/scaffold.php, line
> 193
> Dispatcher::_invoke() - CORE/cake/dispatcher.php, line 248
> Dispatcher::dispatch() - CORE/cake/dispatcher.php, line 213
> [main] - APP/webroot/index.php, line 90
>
> Query: INSERT INTO `categories_categories`
> (`parent_category_id`,`child_category_id`) VALUES (NULL,'1')
>
> --
>
> My ERD is like this, I have two tables one is categories table and
> other is the mapping table to make the m-n relationship possible
> called as categories_categories.
>
> --
> CREATE TABLE IF NOT EXISTS `categories_categories` (
>   `id` int(11) NOT NULL auto_increment,
>   `parent_category_id` int(11) NOT NULL,
>   `child_category_id` int(11) NOT NULL,
>   `created` datetime default NULL,
>   `modified` datetime default NULL,
>   PRIMARY KEY  (`id`)
> ) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;
> 

Re: Model callback question

2008-10-18 Thread Joel Perras

> I am able to modify the data in the model whose find method has been
> called however any associated models do no have their afterFind
> called.

This is actually a known limitation. See https://trac.cakephp.org/ticket/2056

-J.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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: Newbie questions about model relations

2008-10-18 Thread Joel Perras

> Yeah cake its strict on everything  so you can't name your id "design_id"
> stupid? Yes I know.

Thank you for indicating that you have no idea what you're talking
about. Go back to selling $70 websites and leave the rest of the
internet in peace.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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: bake script doesn't save my relations

2008-10-16 Thread Joel Perras

Cake does not support foreign key constraints at the dbo level.

-J.

On Oct 16, 9:42 pm, djXternal <[EMAIL PROTECTED]> wrote:
> Hey guys, I am just getting started using the bake script on windows,
> everything seems to be going great except after baking when I view my
> project.  None of my tables display any relations that they should
> have.
>
> I bake in this order: Models of all tables, Controllers of all Models,
> Views of all controllers
>
> When creating views I tell it to not use scaffolding, but to create
> basic actions (index, edit, add, delete)
>
> I added all the relations when I was baking the models, why would they
> not show up after baking
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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: complex query : HABTM Association between multiple model

2008-10-16 Thread Joel Perras

Try:

$this->User->find('all', array(
  'contain' => array('Brand' => array('Product'))
));


1) Read the Book. Chances are it'll have the information you're
looking for. http://book.cakephp.org/view/474/Containable

2) Look at the test cases for the behavior in question.
http://api.cakephp.org/tests/class_containable_test.html

3) Google is always available. 'cakephp containable' returns 20k
results; I'm sure some of them are useful.

> Is CakePHP very complex for writing function for such query..because I
> am trying it from last two days also no body is replaying me.

People on this list answer questions in their own free time; you pay
nothing to ask the questions and get an answer, and the risk is that
you might not get one. Complaining is not going to help. If that's a
problem, paid consultants are no scarce.

-J.


On Oct 16, 5:31 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
wrote:
> Hi,
>
> I know what query can return my answer..it's here:
>
> SELECT `Product`.`id`, `Product`.`product_name`, `Brand`.`brand_name`,
> `Brand`.`id`, `ProductsUser`.`user_id`, `ProductsUser`.`product_id`
> FROM `products` AS `Product` JOIN `products_users` AS `ProductsUser`
> ON (`ProductsUser`.`user_id` = 2 AND `ProductsUser`.`product_id` =
> `Product`.`id`) JOIN `brands_products` AS `BrandsProduct` ON
> (`BrandsProduct`.`product_id` = `Product`.`id`) JOIN `brands` AS
> `Brand` ON (`Brand`.`id` = `BrandsProduct`.`brand_id`) WHERE 1 = 1
>
> This query is working fine but I don't know how to write it in
> CakePHP...
>
> I found all products accordingly users by using Containable behavior
> but can not find complete solution.
>
> code is:
> $this->User->contain(array('Product'));
> debug($this->User->find('all', array('conditions' => array('User.id'
> => $this->Auth->user('id');
>
> But now don't know how to find all brands accordingly a users product?
>
> Is CakePHP very complex for writing function for such query..because I
> am trying it from last two days also no body is replaying me.
>
> Please tell me how should I go ahead with this?
>
> Thanks
>
> On Oct 16, 12:18 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
> wrote:
>
> > Sorry, I forget that I used this solution but could not succeed
>
> > $brands = $this->User->Product->Brand->find('all',array(
> >                                                       'fields' =>
> > array('Brand.id','Brand.brand_name'),
> >                                                'conditions' =>
> > array('User.id' => $this->Auth->user('id')),
> >                                                       'recersive' => 0)
> >                                            );
>
> > Please help me
>
> > On Oct 16, 12:15 am, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
> > wrote:
>
> > > Hi,
>
> > > I have three Model with following association
> > > 1 User
> > > 2 Product
> > > 3 Brand
>
> > > User HABTM (brands_users)--Brand
> > > Brand---HABTM (brands_products)--Product
> > > User---HABTM (products_users)--Product
>
> > > I want to find a list of all brands which product had been selected by
> > > a user.
>
> > > Means first user select some products then he will be select brands.
>
> > > So I am unable to display all brands accordingly user's products
>
> > > Thanks a lot you for my help
>
>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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: Bug or API change in Model in RC3: 'dependent' can delete ALL records for associated model

2008-10-14 Thread Joel Perras

$ svn blame 
https://svn.cakephp.org/repo/branches/1.2.x.x/cake/libs/model/model.php

-J.

On Oct 14, 12:29 pm, Mathew <[EMAIL PROTECTED]> wrote:
> Is it possible to see all the changesets for RC3 on a specific file?
>
> For example; How can I browse the history of changes to the model.php
> file?
>
> I've been looking around the Cake website, I can see the SVN urls, the
> source code browser, but I'm looking for something like WebSVN.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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: Encryption/Decryption of data

2008-10-08 Thread Joel Perras
hy
>  - secret sharing (Algorithm: Shamir, ...)
>    
> read:http://en.wikipedia.org/wiki/Secret_sharing,http://en.wikipedia.org/wiki/Shamir's_Secret_Sharing
>
> Idea:
> Just save your data more than once for every user but with its own (public)
> key.
>
> This mail is short because I am short in time at the moment. Anyway I hope
> this helps.
>
> -- Bernhard J. M. Grün
>
> 2008/10/8 David C. Zentgraf <[EMAIL PROTECTED]>
>
>
>
> > I'm very interested in this topic.
>
> > I have an application that by it's nature shares "objects" between
> > multiple participants, each object having different participants.
> > Since those objects contain sensitive data, I was looking into ways to
> > encrypt those, so that not even the database admin could see the
> > content.
>
> > With "traditional" encryption schemes this is very difficult to
> > realize though, as there's always only one key that can decrypt the
> > data (would be pointless otherwise). That means for every object a
> > user is participating in you'd need to store an additional key with
> > the user's data, which is pointless.
>
> > I haven't yet, in my limited research, found a meaningful way to
> > encrypt data in a way that allows it to be decrypted with any one of
> > multiple keys (i.e. the user's password). But I'm no cryptographer by
> > any means. Are public/private keys a way to do this?
>
> > Chrs,
> > Dav
>
> > On 8 Oct 2008, at 12:37, titang wrote:
>
> > > It sounds good, but what about if the data must be accessible by many
> > > users.
> > > For example I want to let 2 users to access the same datas with their
> > > own passphrase...
>
> > > Is there a simple way to do that ?
>
> > > Titang
>
> > > On Oct 8, 11:03 am, Joel Perras <[EMAIL PROTECTED]> wrote:
> > >> Simple solution: Generate a pseudo-random string of characters (or
> > >> let
> > >> him choose his own passphrase), and use this as a salt to encrypt
> > >> your
> > >> data before saving to your database. The passphrase must then be used
> > >> to retrieve any information from the database.
>
> > >> Of course, all of this is completely useless if you don't use SSL for
> > >> the entire request/response process.
>
> > >> -J.
>
> > >> On Oct 7, 3:50 am, titang <[EMAIL PROTECTED]> wrote:
>
> > >>> Hi,
> > >>> I would like to encrypt/decrypt data in my application regarding the
> > >>> following requirements:
> > >>> - The data will be decrypted by many users.
> > >>> - I dont want to keep the secret password for decrypting the data of
> > >>> each users in my application.
>
> > >>> Does someone have any idea about how can I do this ? And if there is
> > >>> something already implemented for the cakephp framework?
>
> > >>> There is something pretty good, it is the gnupg project.
> >http://www.gnupg.org/
> > >>> I did my first test by command line on Linux, and it seems really
> > >>> good.
> > >>> 1. First i have to generate one public key per users (from an uid
> > >>> and
> > >>> a passphrase).
> > >>> 2. Then i encrypt  the data and specify which users can access the
> > >>> data (by specifying the uid).
> > >>> 3. And the authorized users can decrypt the data with their own
> > >>> passphrase
>
> > >>> An extension gnupg is available for php.
> > >>> What about a cakephp behavior using this extension? I think it could
> > >>> be very useful.
>
> > >>> Any suggestions or helps are welcome !
>
> > >>> Thanks
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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: more problems with RC3 and tests

2008-10-07 Thread Joel Perras

err, change that to ClassRegistry::init('Phone'), assuming "Phone" is
the model you are attempting to test.

-J.

On Oct 7, 11:11 pm, Joel Perras <[EMAIL PROTECTED]> wrote:
> On Oct 7, 6:10 am, "[EMAIL PROTECTED]"
>
>
>
> <[EMAIL PROTECTED]> wrote:
> > I am sure the docs do not contain the recent changes yet.
>
> > My Model-tests work with fixtures. Here is a mini-example. Maybe you
> > can see some detail that you have done differently.
>
> > in phone.test.php
>
> > App::import('Model', 'Phone');
>
> > class PhoneTest extends Phone {
> >     var $name = 'PhoneTest';
> >     var $useDbConfig = 'test_suite';
>
> > }
>
> > class PhoneTestCase extends CakeTestCase {
> >     var $fixtures = array( 'app.phone_test' );
>
> >     function testStorage() {
> >         $this->PhoneTest =& new PhoneTest();
>
> >         $all = $this->PhoneTest->findAll();
>
> >         $this->assertEqual(4, count($all));
> >     }
>
> > }
>
> Actually, you can now instantiate your test models using
> ClassRegistry::init('NameOfModel'); no need to riddle your tests with
> fake Model classes, whose only purpose is to link model associations
> and use a different database configuration. Your complete code snippet
> above can be reduced to:
>
> class PhoneTestCase extends CakeTestCase {
>      var $fixtures = array( 'app.phone_test' );
>
>     function testStorage() {
>          $this->PhoneTest =& ClassRegistry::init('PhoneTest');
>          $all = $this->PhoneTest->findAll();
>          $this->assertEqual(4, count($all));
>     }
>
> }
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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: more problems with RC3 and tests

2008-10-07 Thread Joel Perras



On Oct 7, 6:10 am, "[EMAIL PROTECTED]"
<[EMAIL PROTECTED]> wrote:
> I am sure the docs do not contain the recent changes yet.
>
> My Model-tests work with fixtures. Here is a mini-example. Maybe you
> can see some detail that you have done differently.
>
> in phone.test.php
>
> App::import('Model', 'Phone');
>
> class PhoneTest extends Phone {
>     var $name = 'PhoneTest';
>     var $useDbConfig = 'test_suite';
>
> }
>
> class PhoneTestCase extends CakeTestCase {
>     var $fixtures = array( 'app.phone_test' );
>
>     function testStorage() {
>         $this->PhoneTest =& new PhoneTest();
>
>         $all = $this->PhoneTest->findAll();
>
>         $this->assertEqual(4, count($all));
>     }
>
> }

Actually, you can now instantiate your test models using
ClassRegistry::init('NameOfModel'); no need to riddle your tests with
fake Model classes, whose only purpose is to link model associations
and use a different database configuration. Your complete code snippet
above can be reduced to:

class PhoneTestCase extends CakeTestCase {
 var $fixtures = array( 'app.phone_test' );

function testStorage() {
 $this->PhoneTest =& ClassRegistry::init('PhoneTest');
 $all = $this->PhoneTest->findAll();
 $this->assertEqual(4, count($all));
}
}

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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: Encryption/Decryption of data

2008-10-07 Thread Joel Perras

Simple solution: Generate a pseudo-random string of characters (or let
him choose his own passphrase), and use this as a salt to encrypt your
data before saving to your database. The passphrase must then be used
to retrieve any information from the database.

Of course, all of this is completely useless if you don't use SSL for
the entire request/response process.

-J.

On Oct 7, 3:50 am, titang <[EMAIL PROTECTED]> wrote:
> Hi,
> I would like to encrypt/decrypt data in my application regarding the
> following requirements:
> - The data will be decrypted by many users.
> - I dont want to keep the secret password for decrypting the data of
> each users in my application.
>
> Does someone have any idea about how can I do this ? And if there is
> something already implemented for the cakephp framework?
>
> There is something pretty good, it is the gnupg project.http://www.gnupg.org/
> I did my first test by command line on Linux, and it seems really
> good.
> 1. First i have to generate one public key per users (from an uid and
> a passphrase).
> 2. Then i encrypt  the data and specify which users can access the
> data (by specifying the uid).
> 3. And the authorized users can decrypt the data with their own
> passphrase
>
> An extension gnupg is available for php.
> What about a cakephp behavior using this extension? I think it could
> be very useful.
>
> Any suggestions or helps are welcome !
>
> Thanks
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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: Bi-directional HABTM edits getting deleted.

2008-10-07 Thread Joel Perras

What''s the problem with 'really high id' values? Do you not have
enough of 4 294 967 294 integers? If so, you can always use UUIDs,
which are, in most respects, inexhaustible, since you'll run into far
greater problems before you start worrying about UUID collisions (like
the entropic death of the universe).

-J.

On Oct 7, 4:28 pm, Brenton B <[EMAIL PROTECTED]> wrote:
> Setup: Categories HABTM Tags ... and consequently Tags HABTM
> Categories .. join table: categories_tags.
>
> I've got the forms setup working for both ways: Categories has a list
> of Tags; and Tags has a list of Categories.
>
> Unfortunately, since the way to update one or the other is to do a
> complete DELETE on the corresponding foreign key, then add anything
> that's new. So if I go and create a Category and select a bunch of
> Tags ... then I go into one of the Tags and edit something in there,
> it wipes 'em all and adds 'em (as expected), but information is lost.
>
> Now, if I add an `id` on the `categories_tags` table, then everything
> that needs to be is retained; however, since it's still doing a DELETE
> then INSERT, my `id` goes up every time I do save an edit ... thus
> possibly resulting in a really high `id`.
>
> So I guess there's no way around it. doh!!
>
> (This is mostly an info blurb for any other newbies who are confused).
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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: Email Validation after registration

2008-10-07 Thread Joel Perras

Store a timestamp with the token that you send to have your user
validate their email address. If the user validates their email
address after the expiry indicated by the timestamp... well do
whatever you want with that, and delete the associated token from the
database. Routinely remove expired tokens from database through some
functionality, most likely a cron job or a manual task that an
administrator can run once in a while.

-J.


On Oct 7, 9:04 pm, phpcurious <[EMAIL PROTECTED]> wrote:
> okay, I already did the user registration, but now, I want the user to
> validate the email address the user is registered with. The user will
> be sent an email for the validation link. now my concern here is that
> link to my cakephp web app will be accessible for a limited time only.
> because of that, the registered user pending email validation has to
> resend that email validation link. I have some ideas, but I just want
> to know from the community what is best to do this.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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: Outgoing requests for tests?

2008-10-02 Thread Joel Perras

curl is a tricky one, since SimpleTest does not have any support for
mock functions. As a result, you generally have to do exactly what you
are suggesting, the benefits being that you are somewhat separating
your interface from your implementation.

-J.

On Oct 2, 3:50 am, "[EMAIL PROTECTED]"
<[EMAIL PROTECTED]> wrote:
> The obvious dirty fix for a lot of this dawned on me. I guess I did
> not think of it earlier since I consider it bad style.
>
> I will have to re-factor my controllers and components so that the 2-4
> lines of code that uses curl (for example) get their own method. The
> poor style IMHO being to re-factor simply to make testing easier and
> not because it improved functionality or readability or anything else.
> And of-course I could never write a test for those lines that I would
> then need to capture in my test subclass. (They aren't many lines but
> I'd still like to include them just to be complete)
>
> I am going to give this approach a try. I would like a more complete
> but this would take me a good way.
>
> Funny how all tests depend on a single point. If I was to test a valve
> I would put air or liquid into one end and see what happened at the
> other end to determine how the valve worked. In code I find it
> extremely difficult to "look at both ends".
>
> Tanks for kick-starting my brain, Daniel.
> :)
>
> On Oct 2, 9:26 am, "[EMAIL PROTECTED]"
>
> <[EMAIL PROTECTED]> wrote:
> > Hi Daniel,
> > I'm not sure that would get me very far. For SOAP it would be possible
> > if I created a big mockup of nusoap, even though it looks pretty time-
> > consuming. I don't know of a way to do the same with curl.
>
> > Looking at the tests for EmailComponent I see that they are set up to
> > listen on port 25. Problem is this does not at all work on my system
> > (Mac) possibly because the os is using the same port. This is why I
> > stopped looking at ways to capture outgoing requests and instead have
> > tried to find a way to pretend to be the receiving end.
>
> > For http the trouble begins at the stage of trying to setup a
> > "fake" (or mock) recieving webserver inside my test case.
> > If I just point the request to localhost (or projectname.site) any
> > data sent wil be received by the "normal" app and database and not the
> > test.
>
> > It really would be enough for my needs to be able to
> > assertEqual($expected_url, $actual_url_called) or
> > assertTrue($fake_webserver->was_called)
> > or something of that sort.
>
> > On Oct 1, 4:02 pm, Daniel Hofstetter <[EMAIL PROTECTED]> wrote:
>
> > > Hi Martin,
>
> > > > I was wondering if anyone had some tips for a good way to write a test
> > > > for a Controller or Component that performs an outgoing request?
> > > > Ordinary models and things are so much more self-contained and
> > > > therefore usually not a big problem writing tests for.
>
> > > > In my case I a talking about a Component that performs SOAP calls to
> > > > an "outside" server, a Controller that works like a router/gateway
> > > > (incoming requests trigger calls to different sub-servers determined
> > > > by the content of the request and a stored list of available sub-
> > > > servers). It does this using simple curl.
>
> > > > I would like to be able to write a test for these to determine of the
> > > > correct SOAP-endpoint or http-address is contacted... without actually
> > > > contacting them. I can configure the endpoints to be somewhere o
> > > > localhost for the tests but I don't know how I would then make the
> > > > testcase capture that request and compare it to my expected result.
>
> > > > Another more common example would be an email-component where you
> > > > might want to test if the correct SMTP is contacted without sending a
> > > > bunch of emails.
>
> > > Maybe you can solve it with mock 
> > > objects:http://www.simpletest.org/en/mock_objects_documentation.html
>
> > > Hope that helps!
>
> > > --
> > > Daniel Hofstetterhttp://cakebaker.42dh.com
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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: Using model without a database for form

2008-10-01 Thread Joel Perras

My mistake. You shouldn't be overriding the Model::schema() function,
only the $_schema protected variable.

-J.

On Oct 1, 10:07 pm, sniper <[EMAIL PROTECTED]> wrote:
> the prblem is not saving, its in my cheer.ctp when i call echo 
> $form->create('Cheer');
>
> its throwing fatal error. i am expecting
> //Output:
> 
> but instead its
> Fatal error: Call to a member function schema() on a non-object in C:
> \xampp\htdocs\cake_1.2.0.7296-rc2\cake\libs\view\helpers\form.php on
> line 127
> how do i fix this?
>
> On Oct 1, 8:31 pm, Joel Perras <[EMAIL PROTECTED]> wrote:
>
> > You're already half way there by overriding the model schema function.
> > Which other model function do you think you should override so that
> > you can *save* the data to an external webservice?
>
> > -J.
>
> > On Oct 1, 4:38 pm, sniper <[EMAIL PROTECTED]> wrote:
>
> > > thanks for the reply, i tried that too, but it still doesn't work and
> > > looks like html, form helpers are built in , at least html works, you
> > > dont have to include for CakePhp1.2
> > > my saving and retrieving of data is done through webservice/soap. i am
> > > going to impl the save and find in my cheer model.
>
> > > But i am not sure how to do data structure?
>
> > > On Oct 1, 9:03 am, techiguy <[EMAIL PROTECTED]> wrote:
>
> > > > sniper,
>
> > > > you are saying u dont want 2 use database/tables and ur using a method
> > > > to save the data.
>
> > > > then where it will save?
>
> > > > any how i am thinking that u have missed one parameter in...
>
> > > > $helpers = array('Form','Html');
>
> > > > Html is missing?
>
> > > > hope it works.
>
> > > > On Sep 30, 7:15 pm, sniper <[EMAIL PROTECTED]> wrote:
>
> > > > >  Hi
> > > > > I am not sure if this has already been asked, but i couldnt find the
> > > > > answer anywhere sad.gif
>
> > > > > Anyway my question is
> > > > > i have a controller,model and view
> > > > > i dont want to use database/tables since persistance will be
> > > > > webservice(soap) based.
> > > > > and i am using cake_1.2.0.7296-rc2.
> > > > > PHP Code
> > > > > 
> > > > > /**
> > > > > * cheers_controller.php
> > > > > */
> > > > > class CheersController extends AppController {
>
> > > > > //it seems to work without defining this, but nevertheless:-/
> > > > > $helpers = array('Form');
> > > > > function add(){
>
> > > > >         if (!empty($this->data)) {
>
> > > > >             if ($this->Cheer->save($this->data)) {
> > > > >                 $this->flash('Your post has been saved.', '/cheers');
> > > > >             }else
> > > > >             {
> > > > >                 $this->flash('Your post has NOT been saved.', '/
> > > > > cheers');
> > > > >             }
> > > > >         }
> > > > >     }
>
> > > > > }
>
> > > > > /**
> > > > > * cheer.php
> > > > > */
> > > > > class Cheer extends AppModel
> > > > > {
> > > > >     var $name = "Cheer";
> > > > >     var $useTable = false;
>
> > > > > }
>
> > > > > /**
> > > > > * add.ctp
> > > > > */
> > > > > echo $form->create('Cheer');
>
> > > > > ?>
>
> > > > > throws this error
> > > > > CODE
>
> > > > > Fatal error: Call to a member function schema() on a non-object in C:
> > > > > \xampp\htdocs\cake_1.2.0.7296-rc2\cake\libs\view\helpers\form.php on
> > > > > line 127
>
> > > > > what more do i need to do? after much googling it looks like i have to
> > > > > override schema() function in my model.
> > > > > but i cant seem to figure out how? i tried to return a array but still
> > > > > doesnt work
> > > > > PHP Code
> > > > > 
> > > > > /**
> > > > > * cheer.php
> > > > > */
> > > > > class Cheer extends AppModel
> > > > > {
> > > > >     var $name = "Cheer";
> > > > >     var $useTable = false;
> > > > >     var $_schema = array(
> > > > >          'uid' => array('type' => 'string','null' => 1, 'default' =>
> > > > > '','length' => 30),
> > > > >          'msg' => array('type' => 'string','null' => 1, 'default' =>
> > > > > '','length' => 30),
> > > > >            'senderId' => array('type' => 'string','null' => 1,
> > > > > 'default' => '','length' => 30)
> > > > >         );
> > > > >     function schema($field = false)
> > > > >     {
> > > > >         return $this->_schema;
> > > > >     }
>
> > > > > }
>
> > > > > ?>
>
> > > > > Any help, direction would be a greatly appreciated.
> > > > > Thanks
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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: Model arrays

2008-10-01 Thread Joel Perras


> Just need to get the Manufacturers array in the first into a form like
> the second or some
> standard common ground between the two.
>
> Thanks again

Take a look at the Set::extract() and set::combine() methods of the
Set core class.

http://book.cakephp.org/view/640/Set
http://book.cakephp.org/view/662/combine
http://book.cakephp.org/view/671/extract

-J.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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: Best way to localize URL

2008-10-01 Thread Joel Perras

The best way is to localize the *content* on all your pages, and leave
the URLs alone. Provide your users with a method of switching locales
(i.e. a link), which calls an AppController function / Component /
Whatever which then sets the proper locale using Configure::write().
Your static content on your pages will then be properly translated,
and without any additional URL manipulations.

You might have already read this, but regardless:
http://book.cakephp.org/view/163/Internationalization-in-CakePHP

There are also several very good threads on issues similar to this one
elsewhere in the google group.

-J.

On Oct 1, 4:16 pm, lemp <[EMAIL PROTECTED]> wrote:
> What would be the best way to localize URL?
>
> I know I can use gettext function on URL, like in:
> $html->link(__('Logout', true), __('/users/logout', true));
>
> But it seems a bit cumbersome.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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: Major Pain - retrieved data

2008-10-01 Thread Joel Perras

Have you checked that magic_quotes_gpc in your php.ini file is turned
off?

-J.

On Oct 1, 5:15 pm, seanislegend <[EMAIL PROTECTED]> wrote:
> Hi,
>
> in the data I'm retrieving from my DB I'm still getting slashes in
> front of quotes. I've been told before that Cake should strip these
> automagically, but apparently not.
>
> I'm still none-the-wiser as to what I can do for this problem. At the
> moment I'm using a custom function on each part of the array I need
> 'cleaned'. Obviously this is not the best way to do this, and I'd
> rather not.
>
> Can anyone offer any suggestions?
>
> Thanks!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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: Using model without a database for form

2008-10-01 Thread Joel Perras

You're already half way there by overriding the model schema function.
Which other model function do you think you should override so that
you can *save* the data to an external webservice?

-J.

On Oct 1, 4:38 pm, sniper <[EMAIL PROTECTED]> wrote:
> thanks for the reply, i tried that too, but it still doesn't work and
> looks like html, form helpers are built in , at least html works, you
> dont have to include for CakePhp1.2
> my saving and retrieving of data is done through webservice/soap. i am
> going to impl the save and find in my cheer model.
>
> But i am not sure how to do data structure?
>
> On Oct 1, 9:03 am, techiguy <[EMAIL PROTECTED]> wrote:
>
> > sniper,
>
> > you are saying u dont want 2 use database/tables and ur using a method
> > to save the data.
>
> > then where it will save?
>
> > any how i am thinking that u have missed one parameter in...
>
> > $helpers = array('Form','Html');
>
> > Html is missing?
>
> > hope it works.
>
> > On Sep 30, 7:15 pm, sniper <[EMAIL PROTECTED]> wrote:
>
> > >  Hi
> > > I am not sure if this has already been asked, but i couldnt find the
> > > answer anywhere sad.gif
>
> > > Anyway my question is
> > > i have a controller,model and view
> > > i dont want to use database/tables since persistance will be
> > > webservice(soap) based.
> > > and i am using cake_1.2.0.7296-rc2.
> > > PHP Code
> > > 
> > > /**
> > > * cheers_controller.php
> > > */
> > > class CheersController extends AppController {
>
> > > //it seems to work without defining this, but nevertheless:-/
> > > $helpers = array('Form');
> > > function add(){
>
> > >         if (!empty($this->data)) {
>
> > >             if ($this->Cheer->save($this->data)) {
> > >                 $this->flash('Your post has been saved.', '/cheers');
> > >             }else
> > >             {
> > >                 $this->flash('Your post has NOT been saved.', '/
> > > cheers');
> > >             }
> > >         }
> > >     }
>
> > > }
>
> > > /**
> > > * cheer.php
> > > */
> > > class Cheer extends AppModel
> > > {
> > >     var $name = "Cheer";
> > >     var $useTable = false;
>
> > > }
>
> > > /**
> > > * add.ctp
> > > */
> > > echo $form->create('Cheer');
>
> > > ?>
>
> > > throws this error
> > > CODE
>
> > > Fatal error: Call to a member function schema() on a non-object in C:
> > > \xampp\htdocs\cake_1.2.0.7296-rc2\cake\libs\view\helpers\form.php on
> > > line 127
>
> > > what more do i need to do? after much googling it looks like i have to
> > > override schema() function in my model.
> > > but i cant seem to figure out how? i tried to return a array but still
> > > doesnt work
> > > PHP Code
> > > 
> > > /**
> > > * cheer.php
> > > */
> > > class Cheer extends AppModel
> > > {
> > >     var $name = "Cheer";
> > >     var $useTable = false;
> > >     var $_schema = array(
> > >          'uid' => array('type' => 'string','null' => 1, 'default' =>
> > > '','length' => 30),
> > >          'msg' => array('type' => 'string','null' => 1, 'default' =>
> > > '','length' => 30),
> > >            'senderId' => array('type' => 'string','null' => 1,
> > > 'default' => '','length' => 30)
> > >         );
> > >     function schema($field = false)
> > >     {
> > >         return $this->_schema;
> > >     }
>
> > > }
>
> > > ?>
>
> > > Any help, direction would be a greatly appreciated.
> > > Thanks
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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: question about sha1 usage?

2008-09-23 Thread Joel Perras

All the things I mentioned were for Cake 1.2.  Auth is not present in
Cake 1.1.
Forgive me for not being clear.

-J.


On Sep 23, 11:04 pm, rocket <[EMAIL PROTECTED]> wrote:
> Are these valid for 1.2?
> Is auth in 1.1?
> I"ll look into it further but just posting this incase someone can
> answer me qucikly.
>
> thanks
>
> On Sep 23, 7:53 pm, Joel Perras <[EMAIL PROTECTED]> wrote:
>
> > Oh, and I forgot to mention that you can actually integrate the Auth
> > component into a pre-existing users table which used a custom hashing/
> > salting scheme:http://book.cakephp.org/view/566/Changing-Encryption-Type
>
> > -J.
>
> > On Sep 23, 7:42 pm, Joel Perras <[EMAIL PROTECTED]> wrote:
>
> > > I'm guessing you're not using the Auth component 
> > > (http://book.cakephp.org/view/172/Authentication) due to a legacy DB.
> > > In that case:
>
> > >http://book.cakephp.org/view/76/Callback-Methods#beforeSave-683
>
> > > Also take a look at the core Security 
> > > class:http://api.cakephp.org/class_security.html
> > > for your password-hashing needs.
>
> > > -J.
>
> > > On Sep 23, 7:05 pm, rocket <[EMAIL PROTECTED]> wrote:
>
> > > > So I have validation code for my user password ($password) in my model
> > > > to be 6-20 characters, but I am doing sha1($password) on my password
> > > > before it gets passed into the $this->User->save() operation, so it
> > > > always bypasses the validation requirement (since sha1 creates a
> > > > really big string).
>
> > > > How do I sha1 my stuff right before it gets saved in the model?
>
> > > > Ideally I'd like to pass my unencrypted password strings, then sha1
> > > > them right before the save, instead of sha1'ing them in my controller
> > > > first.
>
> > > > Where does this kind of code belong?
>
> > > > danke
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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: question about sha1 usage?

2008-09-23 Thread Joel Perras

Oh, and I forgot to mention that you can actually integrate the Auth
component into a pre-existing users table which used a custom hashing/
salting scheme: http://book.cakephp.org/view/566/Changing-Encryption-Type

-J.

On Sep 23, 7:42 pm, Joel Perras <[EMAIL PROTECTED]> wrote:
> I'm guessing you're not using the Auth component 
> (http://book.cakephp.org/view/172/Authentication) due to a legacy DB.
> In that case:
>
> http://book.cakephp.org/view/76/Callback-Methods#beforeSave-683
>
> Also take a look at the core Security 
> class:http://api.cakephp.org/class_security.html
> for your password-hashing needs.
>
> -J.
>
> On Sep 23, 7:05 pm, rocket <[EMAIL PROTECTED]> wrote:
>
> > So I have validation code for my user password ($password) in my model
> > to be 6-20 characters, but I am doing sha1($password) on my password
> > before it gets passed into the $this->User->save() operation, so it
> > always bypasses the validation requirement (since sha1 creates a
> > really big string).
>
> > How do I sha1 my stuff right before it gets saved in the model?
>
> > Ideally I'd like to pass my unencrypted password strings, then sha1
> > them right before the save, instead of sha1'ing them in my controller
> > first.
>
> > Where does this kind of code belong?
>
> > danke
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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: question about sha1 usage?

2008-09-23 Thread Joel Perras

I'm guessing you're not using the Auth component (
http://book.cakephp.org/view/172/Authentication ) due to a legacy DB.
In that case:

http://book.cakephp.org/view/76/Callback-Methods#beforeSave-683

Also take a look at the core Security class: 
http://api.cakephp.org/class_security.html
for your password-hashing needs.

-J.

On Sep 23, 7:05 pm, rocket <[EMAIL PROTECTED]> wrote:
> So I have validation code for my user password ($password) in my model
> to be 6-20 characters, but I am doing sha1($password) on my password
> before it gets passed into the $this->User->save() operation, so it
> always bypasses the validation requirement (since sha1 creates a
> really big string).
>
> How do I sha1 my stuff right before it gets saved in the model?
>
> Ideally I'd like to pass my unencrypted password strings, then sha1
> them right before the save, instead of sha1'ing them in my controller
> first.
>
> Where does this kind of code belong?
>
> danke
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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: View-specific element (aka: why use an element?)

2008-09-22 Thread Joel Perras

No problem.  The more Rails converts, the better :-P

The equivalent of App_controller.php and app_model.php in terms of
views is slightly different than what you'd expect; in actuality, the
implementation of view sub-classing allows you to define multiple
custom View classes and attach different ones to different
controllers.

Example:
You can create a custom view class such as app/views/app.php :

 class AppView extends View {

 // Define your View::partial() function here, using
View::render() as a fallback.

 }

To tell your application that you want to use this view class instead
of the default one, define it in your app_controller.php :

class AppController extends Controller {
var $view = 'App';

// Other AppController things..
}

Now you can use $this->partial() in your layouts & elements.

As you can see, I've told my application to automagically load the
'App' view class that I've created.  However, there's nothing stopping
me from creating yet another view class and attaching it to a specific
controller instead of the app_controller.  The caveat here is that you
need to be aware of what goes in a View and what should go in a
Helper, but that's basic MVC design.  In your case though, I believe a
custom view to be the right implementation.

Check out this article (esp. the comments) for an interesting use of
View subclassing: 
http://cakebaker.42dh.com/2008/08/22/an-idea-for-loading-helpers-in-the-view/

hth,
-J.

On Sep 22, 6:22 pm, Brenton B <[EMAIL PROTECTED]> wrote:
> Yeah, I've prefixed the element with an underscore.
> Hmmm ... excellent (and obvious) idea with just using the relative
> path from `elements` ...
> Makes me think it'd be nice to write a `partial ()` function which
> would take in the name and prepend the path + current controller; but
> I can't seem to find out how to override the View similar to
> app_controller for Controller, any thoughts??
>
> I took a look at the Mini-controller but it's not quite fitting my
> purposes and seems like extra work for something that should be
> trivial (not to mention reading the page was hurting my eyes).
>
> Thanks Joel!!
>
> On Sep 22, 3:32 pm, Joel Perras <[EMAIL PROTECTED]> wrote:
>
> > I usually put these Controller-specific elements inside the same
> > folder as the controller they are associated to.
> > Example: create an 'emphasis.ctp' file, and place it in your views/
> > photographers/ folder.  You can then render this element inside a
> > photographer view template by calling element('../
> > photographers/emphasis'); ?>. Remember that to pass in data to your
> > element you need to pass in a data array as your second argument to
> > $this::element (data given to the view is not automatically available
> > to the element).
>
> > You can, of course, place an underscore infront of the element name to
> > adhere to a standard convention; since these elements are never
> > directly associated to a controller action, then there shouldn't be a
> > problem.
> > This ensures that your application separates the global elements (e.g.
> > header, footer) from the controller/view-specific elements.
>
> > Alternatively, you could use a technique pioneered by AD7six known as
> > mini-controllers:http://www.ad7six.com/MiBlog/Blogs/view/MiniControllers
> > While I have not used it, there is a not-so-small legion of Bakers who
> > swear it's the best thing since sliced bread.
>
> > hth,
>
> > -J.
>
> > On Sep 22, 3:17 pm, Brenton B <[EMAIL PROTECTED]> wrote:
>
> > > Here's the scenario:
>
> > > I've got a list of Photographers; each Photographer has a list of
> > > Emphases that they specialize in; each Emphasis has additional info
> > > (like 'experience').
> > > In the Edit view, I'm looping through the Emphases and creating the
> > > form. However, I also have an "Add new" ajax functionality to
> > > dynamically add a new Emphasis.
>
> > > Now, obviously these 2 forms are identical, and would much rather
> > > modularize these in to a single piece.
>
> > > So far, from what I've found, my options are:
>
> > > 1.) requestAction - which would retrieve the list of Emphases.
> > > However: I already have that list when I retrieved the Photographer's
> > > info, so that seems kind of redundant (plus processing overhead - yes,
> > > I know it wouldn't be a lot)
>
> > > 2.) renderElement. And here's my beef with 'elements': I will only
> > > ever need this 'Emphasis' requirement from within &

Re: View-specific element (aka: why use an element?)

2008-09-22 Thread Joel Perras

I usually put these Controller-specific elements inside the same
folder as the controller they are associated to.
Example: create an 'emphasis.ctp' file, and place it in your views/
photographers/ folder.  You can then render this element inside a
photographer view template by calling element('../
photographers/emphasis'); ?>. Remember that to pass in data to your
element you need to pass in a data array as your second argument to
$this::element (data given to the view is not automatically available
to the element).

You can, of course, place an underscore infront of the element name to
adhere to a standard convention; since these elements are never
directly associated to a controller action, then there shouldn't be a
problem.
This ensures that your application separates the global elements (e.g.
header, footer) from the controller/view-specific elements.

Alternatively, you could use a technique pioneered by AD7six known as
mini-controllers: http://www.ad7six.com/MiBlog/Blogs/view/MiniControllers
While I have not used it, there is a not-so-small legion of Bakers who
swear it's the best thing since sliced bread.

hth,

-J.

On Sep 22, 3:17 pm, Brenton B <[EMAIL PROTECTED]> wrote:
> Here's the scenario:
>
> I've got a list of Photographers; each Photographer has a list of
> Emphases that they specialize in; each Emphasis has additional info
> (like 'experience').
> In the Edit view, I'm looping through the Emphases and creating the
> form. However, I also have an "Add new" ajax functionality to
> dynamically add a new Emphasis.
>
> Now, obviously these 2 forms are identical, and would much rather
> modularize these in to a single piece.
>
> So far, from what I've found, my options are:
>
> 1.) requestAction - which would retrieve the list of Emphases.
> However: I already have that list when I retrieved the Photographer's
> info, so that seems kind of redundant (plus processing overhead - yes,
> I know it wouldn't be a lot)
>
> 2.) renderElement. And here's my beef with 'elements': I will only
> ever need this 'Emphasis' requirement from within 'Photographer', so
> why should it go in 'elements' which are intended to be "small blocks
> of presentation code that needs to be repeated from page to page...".
> Strictly speaking, this is a small block that is repeated; however,
> it's only specific to a Photographer. It just doesn't make much sense
> to have it in a "global"-type folder.
>
> I'm coming from a RoR background where such things would simply be
> prefixed with an underscore ... so in this case, rather than have
> `elements/emphasis.ctp` it would be in `photographers/
> _emphasis.ctp` ... it's just more modular...
>
> Thoughts??
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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: asking about Vertical database on CakePHP

2008-09-22 Thread Joel Perras

I believe what you are referring to is the entity-attribute-value data
model (sometimes referred to as the object-attribute-value model):
http://en.wikipedia.org/wiki/Entity-Attribute-Value_model
This database model is actually used in Magento, an open-source
eCommerce PHP framework.

This is a highly specialized DB model that aims to solve problems
caused by data-sparseness that is common to eCommerce, whereby you
have many products (entities), each with different subsets of
attributes and corresponding values.

Cake was never designed to solve this problem, and is thus not well
suited for this type of implementation; however, Cake does not enforce
a specific DB design principle on you.  You will lose many of the
features that make Cake an attractive choice for development (ie. Auth
component, ACL, etc.), but implementing an EAV DB design is
nonetheless possible.

Just don't ask me to do it.

-J.

On Sep 22, 3:42 pm, "Yodi Aditya" <[EMAIL PROTECTED]> wrote:
> Can you give some reason why vertical database is bad and horrible?
> This is one of many ebook i have read before (in attachment)
> the title is "Storage and querying of E-commerce data" - IBM Almaden
> Research Center.
>
> Google Big Table using vertical database too..(reading from some article...)
> In my opinion, for big e-commerce, vertical database is right choices.
>
> But, i just wanna know if anybody using vertical database on CakePHP.
> thanks for sharing ...
>
> On 9/22/08, leberle <[EMAIL PROTECTED]> wrote:
>
>
>
> > Sounds like a horrible ideaand bad DB design.
> > If you have your DB in Boyce-Codd normal form, you will never have the
> > need for such a DB layout...
>
> > But let me know about your experience :)
>
> > On Sep 21, 7:23 pm, "Yodi Aditya" <[EMAIL PROTECTED]> wrote:
> > > I have reading about vertical database (column-store) on google last
> > night.
> > > it seem interesting method.
>
> > > Is anybody using vertical database with CakePHP?
> > > Is vertical database good for designing some application using cakePHP?
>
> > > if someone has vertical database using cakePHP, please let me know..
>
> > > Thanks
>
>
>
>  P149.pdf
> 211KViewDownload
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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: Plural name: Emphases <-> Emphasis

2008-09-20 Thread Joel Perras

FTCB (From the CookBook): "[...] join table’s name needs to include
the names of both models involved, in alphabetical order".

So it should be emphases_photographers.

http://book.cakephp.org/view/83/hasAndBelongsToMany-HABTM

-J.

On Sep 20, 9:10 pm, Brenton B <[EMAIL PROTECTED]> wrote:
> Hmmm ... I sort of have this working ... however, now that I have a
> join table for HABTM it's fubarred again.
> The table is photographers_emphases, so class is
> PhotographersEmphasis ... does the inflector take into account join
> tables like that properly?
>
> On Sep 17, 11:06 pm, Brenton B <[EMAIL PROTECTED]> wrote:
>
> > Ha! harsh
>
> > Thanks Joel, I figured it had to be straight forward (feel kinda silly
> > now, meh), was just going in circles looking for it.
>
> > On Sep 17, 8:03 pm, "David C. Zentgraf" <[EMAIL PROTECTED]> wrote:
>
> > > OT:
> > > Inflector recently thought the singular form of Pasta is Pastum.
> > > That class can be really good for a laugh sometimes. :-D
>
> > > On 18 Sep 2008, at 09:54, Joel Perras wrote:
>
> > > > If Cake doesn't inflect the word 'emphasis' properly, you can add a
> > > > custom inflection:
>
> > > >http://book.cakephp.org/view/47/Custom-Inflections
>
> > > > -J.
>
> > > > On Sep 17, 8:27 pm, Brenton B <[EMAIL PROTECTED]> wrote:
> > > >> Model is 'emphasis', plural is 'emphases'.
> > > >> Yet Cake doesn't seem to like it.
> > > >> libs/controller/inflector.php ... line 89 seems to have what it
> > > >> takes,
> > > >> but no love ...
>
> > > >> Thoughts?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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: Sorting without Paginator

2008-09-17 Thread Joel Perras

FYI, the MySQL docs actually recommend that to "retrieve all rows from
a certain offset up to the end of the result set, you can use some
large number for the second parameter".  You can always wrap this up
in a custom pagination function, which should achieve your desired
result.  If you want to get fancy, you could figure out an efficient
method for obtaining the total number of records (through count
caching, I suppose), and then use that as your upper limit.

MySQL quote cited above: http://dev.mysql.com/doc/refman/5.0/en/select.html

-Joel.


On Sep 17, 6:15 pm, Brenton B <[EMAIL PROTECTED]> wrote:
> Hello.
> I would like to make use of the sort functionality in the Paginator
> class; however, don't want to actually paginate.
> My options are to either strip out the Sort stuff and create a new
> helper, or set the 'limit' in the options to something crazy high -
> which I think is a bit of a hack.
> I was hoping that the 'limit' option would take a value like 'all' and
> just return all (obviously), but no such luck.
> Anyone else have any other ideas?
> Naturally, I could go with just passing args in the `find` function,
> but just thought I'd check.
>
> Cheers
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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: Plural name: Emphases <-> Emphasis

2008-09-17 Thread Joel Perras

If Cake doesn't inflect the word 'emphasis' properly, you can add a
custom inflection:

http://book.cakephp.org/view/47/Custom-Inflections

-J.

On Sep 17, 8:27 pm, Brenton B <[EMAIL PROTECTED]> wrote:
> Model is 'emphasis', plural is 'emphases'.
> Yet Cake doesn't seem to like it.
> libs/controller/inflector.php ... line 89 seems to have what it takes,
> but no love ...
>
> Thoughts?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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: Sluggable behavior and the performance

2008-09-14 Thread Joel Perras

Cake doesn't define indexes, you do.
Indexing your slug field will assuage your performance concerns.

-J.

On Sep 14, 2:15 pm, "Novice Programmer" <[EMAIL PROTECTED]>
wrote:
> Hello all,
>
> i have a query about using slugging with an application. initially i were
> accessing an item likehttp://sitename.com/users/view/18where 18 is the
> user_id now i am accessing it likehttp://sitename.com/users/
> where user_name is 'slug'. So Query here is that wont be the second url be
> slow because while executing find query in the url 1, I use the id which is
> a primary key. but for url 2 the slug is not a primary key.
> So how does one get around this performance huddle. Do you make it as index?
> Does cake have any issues in defining indices?
>
> --
> Thanks & Regards,
> Novice.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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: method find using regex

2008-08-30 Thread Joel Perras

In the context of a model find operation, REGEX is an SQL function.
You need to take a look at the manual for your database to determine
the correct usage.  If you're using MySQL, you can check out:
http://tinyurl.com/chqcu

-jperras.

On Aug 30, 3:35 pm, Luigi Castro Cardeles <[EMAIL PROTECTED]>
wrote:
> Hi list,
>
> athttp://book.cakephp.org/view/73/retrieving-your-data, is some info
> about usind find with regex (at conditions param). I can't find one
> example of usage and there is nothing at the docs. Someone can give a
> example of usage?
> Thanks
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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 validate that a habtm has at least one association?

2008-08-27 Thread Joel Perras

>From your controller: debug($this->ModelName->hasOne) .
(You can substitute hasOne for whichever association that you're
looking for.)

>From here you can use count()/in_array()/array_values() to perform
whatever checks you might want on $this->ModelName-
>whateverAssociationYouWant.  Or you can get fancy and use the Cake
Set class.

Remember that when you are defining a model, you are creating a PHP
class with methods and member variables, so you can access them like
you would any other vanilla PHP class definition.

CakePHP is still PHP.

-Joel/jperras.

On Aug 27, 12:54 pm, MarcS <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I have 2 models, Model1 and Model2.
> Is there a way that each Model1 is always associated with at least one
> Model2?
>
> I think I remember seeing this somewhere but I can't find it any more.
>
> thanks for your help
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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: something like Joomla modules

2008-08-23 Thread Joel Perras

Take a look at CakePHP plugins: http://book.cakephp.org/view/114/plugins

-Joel.

On Aug 22, 2:23 pm, luigi7up <[EMAIL PROTECTED]> wrote:
> Hello everyone.
>
> I just started to explore Cake PHP and already love it.
>
> I'm trying to create a simple CMS. I have few questions about how to
> solve some problems that came along development. I was using Joomla
> for a few years so I'm used to refer some elements like "pools",
> "latest comments", "tags cloud", "menus" etc. as MODULES.
>
> My question is what would be a good approach to build them in Cake
> PHP.
>
> For example: should I define a new helper/component that would check
> installed and active modules and then call that helper from a view or
> template file?
>
> Some guidelines how to approach would be just fine
>
> Hope you understand my question :)
>
> Thank you very much...
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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: Nested Sets/Hiearchical Categories

2008-08-21 Thread Joel Perras

I think you'd be interested in the Tree Behavior:
http://api.cakephp.org/class_tree_behavior.html
This particular behavior implements arbitrarily deep tree structures
stored in a database using a modified pre-order tree traversal graph
algorithm, which essentially reduces the number of queries to get your
tree (or a subset thereof) to one.  The trade-off is that there is a
slight performance cost to node insertions and deletions.

hth.
-Joel.

On Aug 21, 4:38 pm, LarryTX <[EMAIL PROTECTED]> wrote:
> I've been using Ruby on Rails for quire a while, having been forced
> into it primarily because of its excellent support for nested sets.
> However, I'm increasingly disenchanted with it because it seems to
> break everything every time a mine release occurs -- a sign of a
> product that is far from mature. In addition, its hosting requirements
> are excessive. I'm looking at going back to PHP as my primary server-
> side language and the possibility of CakePHP as my framework.
>
> Before I can do that, I need to know, what kind of support is there
> for nested sets? I'm using nested sets for hierarchical categories of
> n-depth, so I'm not very interested in the ability to produce nicely
> indented HTML listings or breadcrumb menus. I need easy maintenance of
> the categories table with the selection of arbitrary parents and easy
> assignment of categories with a display constructed of the category
> plus its ancestry, such as "Computera > Programming Languages > PHP >
> Forms"
>
> Hope all that makes sense. This information as well as any other
> impressions you might have about migrating from RoR to Cake would be
> most appreciated.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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: HABTM cascading delete

2008-08-20 Thread Joel Perras

You could simply delete the records manually, i.e. store the foreign
key of the record, delete the record, then use the foreign key to
delete the join entry and/or the associated record on the other end of
the HABTM relation.

I don't think there exists a cleaner way, but if anyone else knows,
I'd be interested in hearing.

-Joel.

On Aug 20, 7:44 pm, Marcello <[EMAIL PROTECTED]> wrote:
> Im using innoDB already
> and i've also explained my need to use HABTM in this case, i didnt
> find any better solution because i needed to shared the tables.
>
> i think i will open a ticket
> but still i need a solution, even if its provisory
>
> On 20 ago, 18:24, Joel Perras <[EMAIL PROTECTED]> wrote:
>
> > That will only work if your database engine supports foreign key
> > constraints, such as MySQL InnoDB.  The default MySQL MyISAM engine
> > does not support any type of referential integrity; you can set the
> > FOREIGN KEY/REFERENCES attributes, but they will be ignored.
>
> > Other database implementations may also be lacking foreign key
> > constraints, but my experience is localized to PostgreSQL and MySQL.
>
> > It's probably worth opening up a ticket concerning your issue, since
> > one would expect that the default behaviour for 'dependent' would
> > allow the deletion of the associated entry in the join table,
> > effectively unlinking the two model records in question.  I agree with
> > Dave, however, in that in most cases you would not want to delete the
> > associated records in a HABTM relationship (as opposed to the entry in
> > the join table) for obvious reasons.
>
> > -Joel.
>
> > On Aug 20, 5:12 pm, Marcello <[EMAIL PROTECTED]> wrote:
>
> > > im a little new to referential integrity in the database directly,
> > > could you enligthen me?
>
> > > i got 5 tables
>
> > > Clients AddressClient Addresses
> > > Sellers AddressSeller
>
> > > what i need is, when i delete a client or a seller, it should also
> > > delete his addresses, BUT when i delete a address the client or seller
> > > must remain untouched
>
> > > On 20 ago, 12:45, nachopitt <[EMAIL PROTECTED]> wrote:
>
> > > > Why don't you just do it the way its suppossed to be? By adding
> > > > referential integrity to the database. For example:
>
> > > > CREATE TABLE / ALTER TABLE ...
> > > > ...
> > > > FOREIGN KEY (foreignTableName_id) REFERENCES foreignTableName ON
> > > > DELETE CASCADE;
>
> > > > On Aug 20, 9:21 am, Marcello <[EMAIL PROTECTED]> wrote:
>
> > > > > the main reason for using habtm is because address table is shared
> > > > > among the whole system
>
> > > > > clients use them, sellers, and so on
> > > > > and a client can have ANY NUMBER of addresses
> > > > > the same for seller
> > > > > so i cant put a foreign key in any of the two tables
>
> > > > > thats why i must use HABTM
>
> > > > > On 20 ago, 10:50, Dave J <[EMAIL PROTECTED]> wrote:
>
> > > > > > Not sure if I made sense in my previous post, but basically this is 
> > > > > > a
> > > > > > case in which, if you're in a situation where you need todelete
> > > > > > dependent records in an HABTM relationship. you might need to
> > > > > > think if the relationship should be an HABTM one at all... or if a
> > > > > > simpler hasMany would do the job just as well.
>
> > > > > > On Aug 20, 2:44 pm, Dave J <[EMAIL PROTECTED]> wrote:
>
> > > > > > > I dont think it works for HABTM relations  also for the reason
> > > > > > > that it might be unsafe to do so. By deleting all related 
> > > > > > > records, you
> > > > > > > might also be deleting records which are referenced to by other
> > > > > > > entries in the join table.
>
> > > > > > > On Aug 20, 4:03 am, Marcello <[EMAIL PROTECTED]> wrote:
>
> > > > > > > > it does not work (gives no error, but does not remove the 
> > > > > > > > dependent
> > > > > > > > side)
>
> > > > > > > > On 19 ago, 22:26, Marcello <[EMAIL PROTECTED]> wrote:
>
> > > > > > > > > dependent is exactly what i was looking for
>
> > > > > > > > > thanks!
>
> > > > > &g

Re: HABTM cascading delete

2008-08-20 Thread Joel Perras

That will only work if your database engine supports foreign key
constraints, such as MySQL InnoDB.  The default MySQL MyISAM engine
does not support any type of referential integrity; you can set the
FOREIGN KEY/REFERENCES attributes, but they will be ignored.

Other database implementations may also be lacking foreign key
constraints, but my experience is localized to PostgreSQL and MySQL.

It's probably worth opening up a ticket concerning your issue, since
one would expect that the default behaviour for 'dependent' would
allow the deletion of the associated entry in the join table,
effectively unlinking the two model records in question.  I agree with
Dave, however, in that in most cases you would not want to delete the
associated records in a HABTM relationship (as opposed to the entry in
the join table) for obvious reasons.

-Joel.


On Aug 20, 5:12 pm, Marcello <[EMAIL PROTECTED]> wrote:
> im a little new to referential integrity in the database directly,
> could you enligthen me?
>
> i got 5 tables
>
> Clients AddressClient Addresses
> Sellers AddressSeller
>
> what i need is, when i delete a client or a seller, it should also
> delete his addresses, BUT when i delete a address the client or seller
> must remain untouched
>
> On 20 ago, 12:45, nachopitt <[EMAIL PROTECTED]> wrote:
>
> > Why don't you just do it the way its suppossed to be? By adding
> > referential integrity to the database. For example:
>
> > CREATE TABLE / ALTER TABLE ...
> > ...
> > FOREIGN KEY (foreignTableName_id) REFERENCES foreignTableName ON
> > DELETE CASCADE;
>
> > On Aug 20, 9:21 am, Marcello <[EMAIL PROTECTED]> wrote:
>
> > > the main reason for using habtm is because address table is shared
> > > among the whole system
>
> > > clients use them, sellers, and so on
> > > and a client can have ANY NUMBER of addresses
> > > the same for seller
> > > so i cant put a foreign key in any of the two tables
>
> > > thats why i must use HABTM
>
> > > On 20 ago, 10:50, Dave J <[EMAIL PROTECTED]> wrote:
>
> > > > Not sure if I made sense in my previous post, but basically this is a
> > > > case in which, if you're in a situation where you need todelete
> > > > dependent records in an HABTM relationship. you might need to
> > > > think if the relationship should be an HABTM one at all... or if a
> > > > simpler hasMany would do the job just as well.
>
> > > > On Aug 20, 2:44 pm, Dave J <[EMAIL PROTECTED]> wrote:
>
> > > > > I dont think it works for HABTM relations  also for the reason
> > > > > that it might be unsafe to do so. By deleting all related records, you
> > > > > might also be deleting records which are referenced to by other
> > > > > entries in the join table.
>
> > > > > On Aug 20, 4:03 am, Marcello <[EMAIL PROTECTED]> wrote:
>
> > > > > > it does not work (gives no error, but does not remove the dependent
> > > > > > side)
>
> > > > > > On 19 ago, 22:26, Marcello <[EMAIL PROTECTED]> wrote:
>
> > > > > > > dependent is exactly what i was looking for
>
> > > > > > > thanks!
>
> > > > > > > On 19 ago, 22:11, Joel Perras <[EMAIL PROTECTED]> wrote:
>
> > > > > > > > Take a look 
> > > > > > > > athttp://book.cakephp.org/view/66/models#deleting-data-516
> > > > > > > > .  The 'dependent' parameter can also be set in the model 
> > > > > > > > association
> > > > > > > > definition.
>
> > > > > > > > Hope that's what you were looking for.
> > > > > > > > -J.
>
> > > > > > > > On Aug 19, 8:52 pm, Marcello <[EMAIL PROTECTED]> wrote:
>
> > > > > > > > > i got 2 tables linked by a HABTM relationship
>
> > > > > > > > > when ideletetable record 1 i want todeletethe relationship 
> > > > > > > > > with
> > > > > > > > > table and the table 2 record as well
> > > > > > > > > but when ideletefrom table 2 i want to keep table 1 record
>
> > > > > > > > > is there any feature in cakephp forcascadingin habtm?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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: HABTM cascading delete

2008-08-19 Thread Joel Perras

Take a look at http://book.cakephp.org/view/66/models#deleting-data-516
.  The 'dependent' parameter can also be set in the model association
definition.

Hope that's what you were looking for.
-J.

On Aug 19, 8:52 pm, Marcello <[EMAIL PROTECTED]> wrote:
> i got 2 tables linked by a HABTM relationship
>
> when i delete table record 1 i want to delete the relationship with
> table and the table 2 record as well
> but when i delete from table 2 i want to keep table 1 record
>
> is there any feature in cakephp for cascading in habtm?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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: Onkeypress event

2008-07-15 Thread Joel Perras

Problem with using onkeydown for this is that the # of DB requests is
directly proportional to the length of the name being input; setting a
freq. of 1 sec seems like a good solution.  However, I can usually
input my name in less than a second.  Try performing the action on an
onblur instead of onkeydown; that'll retain the same functionality,
but reduce the # of requests to the DB.

-J.

On Jul 15, 9:27 am, RJ <[EMAIL PROTECTED]> wrote:
> hey got it when i put frequency of 1 sec , it gives the desired
> result.
> But as Mr Decot mentioned, it could be a lot on server...
>
> Thanks all
>
> On Jul 15, 6:15 pm, "Siegfried Hirsch" <[EMAIL PROTECTED]>
> wrote:
>
> > I use frequecy for 1 seconds updates with the ajax call. Thats the way to 
> > handle
> > it without putting a burden on the server with every key stroke ;)
>
> > On Tue, Jul 15, 2008 at 3:11 PM, RJ <[EMAIL PROTECTED]> wrote:
>
> > > it doesn't work i guess ... i want to make ajax calls on 'onkeyup'
> > > event
> > > how to use $ajax->observeField for the same??
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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: inverting self-referencing HABTM associations

2008-07-02 Thread Joel Perras

I would add an extra field that denotes the implication direction,
e.g.

Assuming 'A "enables" B' translates to "if A then B" in propositional
logic, with the material implication going from the antecendent to the
consequent (as it should be):

Add an extra field to your schema, something along the lines of
'direction' (implication direction), that indicates the proper
commutation of the expression (say 'left' and 'right'... assuming you
only have boolean logic); I'm guessing that if A enables B, then it is
not necessarily true that B enables A (in your logical system).  You
can then specify in the 'conditions' paramter of your HABTM model
which direction to filter on, or directly to the Model::find() call.

Watch out though.  Propositional logic can be quite fickle if you
don't adhere to the axioms of boolean logic, causing inconsistencies
that can make your head hurt.  If you're allowing your users to create
their own relationships between entities, I would strongly suggest
picking up a book/article/mathematician-friend (hi!) to evaluate the
nature of your relationships and logical connectives.  However, this
might be overkill... it all depends on what you are attempting to
accomplish.

Hope that was somewhat useful.

-Joel.

On Jun 30, 6:10 pm, Bart van Wissen <[EMAIL PROTECTED]> wrote:
> I'm building an application which deals with "alternatives". I won't
> go into the details of the application, but what's important here is
> that these alternatives have relationships between them. These include
> "enables", "excludes", "forbids", etc. For example, "alternative A
> forbids alternative B" means that after choosing alternative A,
> alternative B cannot be chosen.
>
> Now I was wondering what would be the best way to model this in
> CakePHP (and MySQL). For a given alternative, I want to get all
> related alternatives. The way I do it now is by using a table called
> "alternative_relationships", which has two foreign keys,
> "alternative_1" and "alternative_2", and a relationship name.
> In my Alternative model, I put this:
>
> var $hasAndBelongsToMany = Array(
>                 'RelatedAlternative' => Array(
>                         'className' => 'Alternative',
>                         'joinTable' => 'alternative_relationships',
>                         'foreignKey' => 'alternative_1',
>                         'associationForeignKey' => 'alternative_2'
>                         )
> );
>
> This way, I only get the relationships that have this alternative at
> the 'left' side of the relation.
> So for example, if there is a relationship "A forbids B", then for
> alternative A I would get alternative B as a related alternative, but
> for alternative B, I won't get A.
>
> So I added the inverse version to get those too:
>
> var $hasAndBelongsToMany = Array(
>                 'RelatedAlternative' => Array(
>                         'className' => 'Alternative',
>                         'joinTable' => 'alternative_relationships',
>                         'foreignKey' => 'alternative_1',
>                         'associationForeignKey' => 'alternative_2'
>                         ),
>                  'InverseRelatedAlternative' => Array(
>                         'className' => 'Alternative',
>                         'joinTable' => 'alternative_relationships',
>                         'foreignKey' => 'alternative_2',
>                         'associationForeignKey' => 'alternative_1'
>                         )
>         );
>
> This way, I get all relationships which have this alternative on
> either side of the relation (so either alternative_1 or
> alternative_2). I can't help but feel that this is not a very pretty
> solution though, because now they end up in separate arrays.
>
> It would be much nicer if I could get all related alternatives
> together, and distinguish the 'direction' of the relationships by
> using separate names for the inverse relations (like "forbids" and "is
> forbidden by").
> An easy solution would be to insert additional records in the
> relationships table for the inverse relationships, but I don't like
> having redundant data in my database, because it's hard to manage and
> easy to mess up.
>
> I would love to read your ideas about this. How would you store this
> kind of information, and how would you model it in CakePHP?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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: Any Support for "ON DUPLICATE KEY UPDATE" in Models?

2008-07-02 Thread Joel Perras

I believe the best starting point would be to extend the datasource
for your specific database.

Alternatively, I believe this problem could be solved in terms of a
trigger, but I'd have to think a bit more about that.

-Joel.

On Jul 2, 10:17 am, "[EMAIL PROTECTED]"
<[EMAIL PROTECTED]> wrote:
> I found myself in an new situation. A table of aggregateable data
> (StarSchema type of setup so this will be the source of the
> aggregations) should ideally be updatable. Since it is a fact table
> there will be a lot of data and I would love it if I could avoid some
> queries.
>
> Being able to tack on a "...ON DUPLICATE KEY UPDATE..." to the end of
> my save would save me looking for existing rows before saving. New
> ones would be created and existing ones would be updated. When just
> the saves will be a few thousands per "day" aggregated data
>
> I have resorted to writing the query manually for now but it would be
> nice to be able to stay in the warm comfort of Cake methods. Has
> anybody extended a model's save() in this way or anything similar I
> can look at as a starting-point?
>
> /Martin
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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: Question about locales and their correct way of using

2008-06-30 Thread Joel Perras

How is this different from what the CakePHP book ( http://tinyurl.com/67za2h
) describes?  You can set whatever you want for a msgid.

-Joel.

On Jun 28, 4:03 pm, "Mark (germany)" <[EMAIL PROTECTED]>
wrote:
> I started to translate some of the
> "hello, nice to have you back" oder "This is the Page about Mosquitos"
> into GERMAN, etc.
>
> now..
> first of all, some of the translations can get pretty long - and have
> to be in the source code
> wouldn't it be more logic, to set short names like MESSAGE_HELLO etc
> (like its done with constants in some cms oder oscommerce etc) and
> referring to the .po file - where the complete message is?
>
> __(Configure::load() - %s.php not found)
> and
> msgid "Configure::load() - %s.php not found"
>
> would be
> __(CONFIG_NOTFOUND)
> and
> msgid "Configure::load() - %s.php not found"
>
> this way the content of the transcription can slidly change in the
> original language (eng), without having to adapt it to the other
> languages
> the pages and templates should become smaller - and the .po file stays
> the same.
>
> so if you change
> __(Configure::load() - %s.php not found) to __(Configure::load() -
> %s.php cannot be found)
> you usually have to change ALL other language files
>
> with my idea you probably stick to this one change in one language
>
> what i want to say is that it might be useful to stick to short and
> clear placeholder, so to speak.
> what do you say about that?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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: List views/action of all controllers

2008-06-23 Thread Joel Perras

There are a couple ways you could go about it.  However, to put things
into context, _what_ are you attempting to accomplish?  And _why_?
There might be an easier way to get all the information you need
without having to resort to fancy coding.

-Joel.

On Jun 23, 9:43 am, Pravalitera <[EMAIL PROTECTED]> wrote:
> Hello there,
>
> i'm looking for a way to list all my controllers/actions.
>
> To list controllers, i found this :
>
> $Configure = &Configure::getInstance();
> $controllers_list = $Configure->listObjects('controller');
>
> Pretty cool, but i don't manage to list all my views/functions of
> each...
>
> If anyone could help me, that could make my day.
>
> Thx.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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: Containable with recursivity

2008-06-23 Thread Joel Perras

First make sure that the User model has $actsAs = array('Containable')
set.
This might do the trick:

// app/controllers/users_controller.php
$this->User->find('first', array( // --> Use 'first' if you're only
looking for one user, and 'all' if you want all users who match
specified conditions.
'conditions' => array('User.id' => $user['User']['id'])   // -->
or whatever other condition you use to find a specific user..
'contain' => array(
'Book' => array('Author')
)
));

I'm still playing around with all the new goodies that the Containable
behavior has to offer, so I'm not quite certain how the behavior will
react to a second-level embedding of two HABTM relationships.

Take a look at the Containable behavior test cases; since there is no
official documentation on this, it's the best source of information
and examples.

On Jun 23, 6:26 am, "gbk *" <[EMAIL PROTECTED]> wrote:
> hi guys
>
> i have the following model structure:
>
> User HABTM Book
> Book HABTM Author
>
> i would like to find all the books of the user, but with the Authors.
>
> how can i implement it with the Containable behavour?
>
> thanks,
>
> gbk
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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: Missing database table

2008-06-20 Thread Joel Perras

On Jun 20, 11:52 am, "Siebren Bakker" <[EMAIL PROTECTED]>
wrote:

> I'm not selecting more information than I need. findAll > find in most
> situations, especially because of the recursive option.

Really?  That's odd, because findAll() is nothing more than a
(deprecated) wrapper for find('all').  Actually, there are things that
you can do with Model::find('all', ..) that are impossible with
Model::findAll(), such as providing options to the new Containable
behavior.

Read the API if you have some free time.  It's often quite
enlightening.

-Joel.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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: complex findAll()

2008-06-19 Thread Joel Perras

A similar question had been posed on the mailing list a week or so
ago:  http://tinyurl.com/467kx7
The short answer is that if you are using MySQL, you can use ORDER BY
FIELD(id, 2,3,4,5,1).

-Joel.

On Jun 19, 5:17 pm, Fahad <[EMAIL PROTECTED]> wrote:
> i wil make it easy by showing an example.
> lets say, i have only 5 records in my database table. and they all
> have an ID field of 1, 2, 3, 4, and 5.
>
> i want the findAll() to work in such a way so that i can start the
> number of records at a given ID.
> for example, i want the records returned by findAll to start from 2.
> like this: 2, 3, 4, 5, 1 (1 will be added at the end)
>
> when i want to start its ordering from 3, it will be like this:
> 3, 4, 5, 1, 2 (1 and 2 will be added at the end)
>
> can anyone help me with it?
>
> thanks
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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: FormHelper select range

2008-06-19 Thread Joel Perras

http://ca.php.net/range

$form->input('name', array('type'=>'select',
'options'=>range(1,99,1)));

Remember that CakePHP is still PHP, just nicer ;-)

-Joel.

On Jun 19, 1:59 pm, nnj <[EMAIL PROTECTED]> wrote:
> Hi Guys,
>
> I have several form elements of the type: select from 1 to 99.  Is
> there a way to generate a select element without having to list 99
> integers? i.e. start: 1, end: 99, increment: 1
>
> Thanks!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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: Can Cake save extra fields in HABTM join tables?

2008-06-17 Thread Joel Perras

Read:  tinyurl.com/4kbe9q

-Joel.

On Jun 17, 10:26 am, Jaime <[EMAIL PROTECTED]> wrote:
> Buah, sorry to bother the Group with YAHABTMQ (Yet Another HABTM
> Question), but I'm really stuck with this.
>
> I guess Cake can not save extra fields in HABTM join tables. I haven't
> seen nothing related to this in the nice book. To stick on the "Post
> HABTM Tag" example, this is not working:
>
> $this->data = array(
>   'Post' => array(
>     'id' => 1,
>   ),
>   'Tag' => array(
>     'Tag' => array(
>       '0' => array(
>         'tag_id' => 1,
>         'extrafield' => 'somethinghere',
>       ),
>       '1' => array(
>         'tag_id' => 2,
>         'extrafield' => 'somethinghere',
>       ),
>     ),
>   ),
> );
>
> $this->Post->save($this->data);
>
> Am I missing something?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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: 1.2 testing

2008-06-16 Thread Joel Perras

Might be an obvious question, but have you downloaded and installed
SimpleTest into app/vendors ?

-Joel.

On Jun 16, 2:42 pm, Stupergenius <[EMAIL PROTECTED]> wrote:
> Hello,
>
> I am running a production environment setup, ie I have my webroot in
> one folder, libs in another, and my project in another. I am having
> trouble running tests through the localhost/test.php method. Browsing
> to this page brings me to the default "congratulations, you've setup
> cakephp correctly" page. I am using the default htaccess that came
> with 1.2 and am wondering if this URL rewriting is the cause.
>
> Is there any more magic that I need to get things working?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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: How strong is Security::cipher() ?

2008-06-15 Thread Joel Perras

Pardon the previous cryptic reply (!).
The Blowfish algorithm is more secure than the Security::cipher()
method.  In most cases, if you or your client are overly concerned
with data security, then Blowfish (or its successor, Twofish) are both
viable options for encryption/decryption schemes.  There are dozens of
other algorithms as well, but people tend to cling to their preferred
cipher algorithms religiously; I'm more of an agnostic ;-)

In general, if data security is extremely important for you, I would
recommend hiring a specialized consultant to analyze your workflow and
security measures.  There are far more important things to consider
than the strength of the encryption algorithm used.

Just my Mg== cents.

-Joel.

On Jun 15, 3:37 am, seedifferently <[EMAIL PROTECTED]> wrote:
> > From cold hard facts, no.
>
> Joel, please forgive me but I'm a little confused by your answer.
>
> Quite simply, is Security::cipher() a viable alternative to
> mcrypt_encrypt or would it be more advisable to go the route of
> mcrypt_encrypt for sensitive data in CakePHP? I have seen a helper/
> component for mcrypt in the bakery. Would you recommend that over
> Security::cipher() or are they both going to be about the same
> considering that no encryption method is absolutely bulletproof?
>
> Thanks,
> Seth
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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: How strong is Security::cipher() ?

2008-06-14 Thread Joel Perras

> In CakePHP I noticed the cipher() function as part of the Security
> class. At first glance however, I wasn't able to discern what type of
> encryption scheme is being used.

It's a simple symmetric key bitmask cipher.

> My question is this: How does CakePHP's cipher() function stack up
> against something like mcrypt()? Is it of a similar level of security?
> Can I sleep safely at night knowing that cipher() is going to be as
> strong as, say, MCRYPT_BLOWFISH?

>From cold hard facts, no.  However, as with any symmetric key
algorithm (Blowfish is also a SKA), you're going to have to store the
key somewhere (PHP file, Apache config, DB, etc.).  If I was going to
attempt to steal your encrypted information, my first act would be to
take the path of least resistance and obtain your key string, because
a full-blown cryptanalysis takes time and effort, and is an extremely
difficult undertaking in general.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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: Installing CakePHP -> Missing PrivatController

2008-06-13 Thread Joel Perras

Pardon my previous inarticulate and unhelpful message; I should have
learned by now that answering any question past 2am never leads to any
good.

I agree with Grant in that the most probable reason why you are not
seeing the applied CSS on your second machine is a mod_rewrite issue.
This question pops up on this mailing list almost every week.  A quick
google search of this group will give you several threads that point
you in the right direction.

-Joel.

On Jun 13, 2:46 am, "Jonathan Snook" <[EMAIL PROTECTED]> wrote:
> Joel, I suspect he's running cake fine.
>
> Benny, I think you need to just continue to learn more about CakePHP
> using the cookbook <http://manual.cakephp.org> and move forward in
> trying to build your application.
>
> On Fri, Jun 13, 2008 at 2:24 AM, Joel Perras <[EMAIL PROTECTED]> wrote:
>
> > Sounds to me like you're not getting Cake from cakephp.org; there is
> > no 'PrivatController' in the default Cake installation, and nothing
> > that could possible cause this error.
>
> > Read the installation chaper inhttp://book.cakephp.org, and make sure
> > you get the CakePHP sources from the, err, source.
>
> > -Joel.
>
> > On Jun 13, 12:43 am, "[EMAIL PROTECTED]"
> > <[EMAIL PROTECTED]> wrote:
> >> Good morning developers.
>
> >> While i'm installing cakephp on my pc there comes a little problem. I
> >> did it before once on another pc without any problems.
>
> >> What did i do:
> >> I downloaded cakephp 1.2 rc1 and unzip it to my webroot folder. I run
> >> Apache 2.2.6 with PHP 5.2.5 and MySQL 5.0.51. Then i setup the
> >> default.php for the database connection and create a database named
> >> blog. All this seems to be good. But then...
>
> >> On my first px i installed it i can now see a fresh designed cakephp
> >> layout with some informations hover on yellow or green background
> >> which tells me that my database connection is good an all these stuff.
> >> BUT on my other pc der comes just black on white text.
>
> >> So here ist the errormessege:
> >> "CakePHP: the rapid development php framework
> >> Missing Controller
>
> >> Error: PrivatController could not be found.
>
> >> Error: Create the class PrivatController below in file: app\controllers
> >> \privat_controller.php
>
> >>  >> class PrivatController extends AppController {
>
> >>         var $name = 'Privat';}
>
> >> ?>
>
> >> Notice: If you want to customize this error message, create app\views
> >> \errors\missing_controller.ctp
> >> CakePHP: the rapid development php framework"
>
> >> Ok i guess, let's create this class. After that text error changes to:
> >> "CakePHP: the rapid development php framework
> >> Missing Database Table
>
> >> Error: Database table privats for model Privat was not found.
>
> >> Notice: If you want to customize this error message, create app\views
> >> \errors\missing_table.ctp
> >> CakePHP: the rapid development php framework"
>
> >> Ok again. I created the table in my database but nothing changes.
> >> What can i do to get it run correctly? Or shoud i ignore it and just
> >> begin to develop my project?
>
> >> Greetz Ben
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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: Installing CakePHP -> Missing PrivatController

2008-06-12 Thread Joel Perras

Sounds to me like you're not getting Cake from cakephp.org; there is
no 'PrivatController' in the default Cake installation, and nothing
that could possible cause this error.

Read the installation chaper in http://book.cakephp.org, and make sure
you get the CakePHP sources from the, err, source.

-Joel.

On Jun 13, 12:43 am, "[EMAIL PROTECTED]"
<[EMAIL PROTECTED]> wrote:
> Good morning developers.
>
> While i'm installing cakephp on my pc there comes a little problem. I
> did it before once on another pc without any problems.
>
> What did i do:
> I downloaded cakephp 1.2 rc1 and unzip it to my webroot folder. I run
> Apache 2.2.6 with PHP 5.2.5 and MySQL 5.0.51. Then i setup the
> default.php for the database connection and create a database named
> blog. All this seems to be good. But then...
>
> On my first px i installed it i can now see a fresh designed cakephp
> layout with some informations hover on yellow or green background
> which tells me that my database connection is good an all these stuff.
> BUT on my other pc der comes just black on white text.
>
> So here ist the errormessege:
> "CakePHP: the rapid development php framework
> Missing Controller
>
> Error: PrivatController could not be found.
>
> Error: Create the class PrivatController below in file: app\controllers
> \privat_controller.php
>
>  class PrivatController extends AppController {
>
>         var $name = 'Privat';}
>
> ?>
>
> Notice: If you want to customize this error message, create app\views
> \errors\missing_controller.ctp
> CakePHP: the rapid development php framework"
>
> Ok i guess, let's create this class. After that text error changes to:
> "CakePHP: the rapid development php framework
> Missing Database Table
>
> Error: Database table privats for model Privat was not found.
>
> Notice: If you want to customize this error message, create app\views
> \errors\missing_table.ctp
> CakePHP: the rapid development php framework"
>
> Ok again. I created the table in my database but nothing changes.
> What can i do to get it run correctly? Or shoud i ignore it and just
> begin to develop my project?
>
> Greetz Ben
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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: Trash bin instead of immediate deletion -- where to put logic

2008-06-12 Thread Joel Perras


> P.S. Joel, I actually went and did php -r "echo round(pow(2,-5.643),
> 2);". I think you mean "round(pow(2,-5.643),2) DOLLARS". :)

D'oh!  What a noob-ish mistake.  Guess I'm going to have my nerd
membership card revoked ;-).

I like your idea of emptying the 'trash' based on timestamp every time
another item is soft-deleted; it's a creative solution for those
hosting plans which don't offer crontab access.

Happy to have co-pointed you in the right direction.

-Joel.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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: Trash bin instead of immediate deletion -- where to put logic

2008-06-12 Thread Joel Perras

On Jun 12, 1:19 pm, silverquick <[EMAIL PROTECTED]> wrote:
> Hi all. I just read a really excellent article by Aza 
> Raskin:http://www.alistapart.com/articles/neveruseawarningwhich recommends,
> instead of those defacto "Are you sure you want to delete this?"
> warnings, just performing an undo-able deletion—or even better, moving
> the item to a "trash". This way the work flow is not interrupted, and
> there's no more just clicking "yes" out of habit, only to realise you
> made a horrible mistake.
>

That's a wonderful article which brings to light many software design
principles & patterns that web application developers seem to omit.

For what you are proposing, there is already a behaviour in the bakery
which follows the spirit of what you are trying to accomplish:
http://bakery.cakephp.org/articles/view/soft-delete-behavior  (this
needs to be updated as of 1.2.0.7125 due to new query syntax, but is
nearly trivial; see the comments).

The Soft Delete allows a user to 'remove' a record, but the
information is still retained in the database; this way, an accidental
delete operation may be reversed quite easily.  Remember, however,
that there are several caveats to be considered when implementing this
type of functionality in web applications with a high level of
concurrency, whereby you can get yourself into several bizzare race
conditions and deletion/insertion anomalies when you are dealing with
1:N and N:1 relationships whereby many users have the ability to edit/
delete/restore the same records.

Just my round(pow(2,-5.643),2) cents.

-Joel.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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: Accessing posted variables from Ajax.Request

2008-06-12 Thread Joel Perras

Check $this->params['form'].

-Joel.

On Jun 12, 9:49 am, Crabby <[EMAIL PROTECTED]> wrote:
> Hi guys
>
> If I'm calling 'controller/action' from an Ajax.Request how do I
> access the parameters I send in the action? IE
>
>                 new Ajax.Request('modules/onUpdate/', {
>                                                 method: 'post',
>                                                 postBody: postBody,
>                                                 onComplete: 
> function(transport) {alert(transport.responseText)}
>                                                 });
>
> How would I access postBody in
>
> function onUpdate()
> {
>
> }
>
> Any help would be much appreciated
>
> Crbby
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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: Help Me Please

2008-06-10 Thread Joel Perras


On Jun 6, 1:14 pm, "b logica" <[EMAIL PROTECTED]> wrote:
> That's not going to work. In fact, if you figured out a way to get
> Cake to make it work, I'd file a ticket to say that it was a bug, not
> a feature.
>
> A "join table" should have only fields which are foreign keys to other
> tables. Its sole purpose is to join records between 2 or more tables,
> nothing else.

I beg to differ.  From Mariano's own blog:  http://tinyurl.com/4kbe9q
In Cake 1.2, extra fields in the join models are easy to integrate
into your application.

There are plenty of situations where additional information in the
join table is useful, the simplest being the date/time that the join
record was created, such as in the prototypical articles_tags example;
sometimes it is useful to know when a particular article was
associated with a particular tag, or vice versa.  Other examples could
include an online shopping system, where you would have products,
carts, and carts_products (taken from an old thread on this group).
The logical location to indicate the quantity of a product in a cart
would be in the carts_products join table.

-Joel.

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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: Any Montreal cakePHP developpers?

2008-06-10 Thread Joel Perras

Hey Ed, I live and breathe in this wonderful city.  Hit me up if ever
you feel like having a micro-cakefest one day ;-).  My email is
publicly available on my profile.

-Joel.

On Jun 10, 2:33 pm, Sake <[EMAIL PROTECTED]> wrote:
> Hi,
>
> Any cakePHP developpers living in montreal? I'd like to get some
> experience working with others in cakePHP and I have some ideas that
> I'd like to meet with someone to develop, I'm curious if anybody on
> this list is living in the city.
>
> Let me know!
>
> -Ed
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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: a bit confused (n00b warning)

2008-06-06 Thread Joel Perras

Ok, I'll attempt to re-iterate what you are attempting to do, because
it is not completely clear to me:

1) You want to be able to 'add items to an apartment', where items <-
HABTM-> apartments.
2) This should be accomplished through an HTML select drop-down, which
would be populated with all the items contained within your items
table.
** The above point seems odd to me, since I'm guessing you would like
to have the ability to input many different items (of various
quantities) for each apartment.  This can also be accomplished, but
it's a question of what your design/architecture requires.

If this is anywhere near what you are attempting to accomplish, let me
know.  I just don't want to help you solve a problem you don't have.


-Joel.

P.S.
Something I noticed from your first post:  the most likely reason that
CakePHP couldn't find the 'inventory' table was that it wasn't
following the CakePHP conventions (which can be overrided, of
course).  If your table name was 'inventories', then the Inflector
would have been able to singularize the name, and find the
InventoryController, and the 'inventories' views..


On Jun 6, 2:36 am, winter <[EMAIL PROTECTED]> wrote:
> Thanks Joel,
>
> That sounds nice. I guess maybe I'm not being so clear and perhaps I
> am missing something.
>
> I'm trying to make a form to fill the join table. You see, a
> unit(apartment) has many items. For example Apartment A has 5 glasses
> and Apartment B has 10 glasses.
>
> Using plain PHP, I'd query my item table and use that data in a select
> element on my html form. The form would not allow you to set unit_id.
> I'd use a hidden field which is the value passed when clicking on a
> "add items to this apartment" link. When the form is submitted,
> unit_id, item_id, and amount are inserted into my inventory table.
>
> Now I have this join table, which seems like it's what I want. Though,
> perhaps it really isn't. Because I'm not sure if I can make a view for
> it according to cakephp convention.
>
> Cakephp seems to have many fantastic features for rapid app
> development. So I'd like to understand it. Things are becoming clearer
> after reading many blogs and docs. If you think there is something I
> should read, please point me to it.
>
> Thanks again!
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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: a bit confused (n00b warning)

2008-06-05 Thread Joel Perras

Hi winter,

If you have a field called 'name' or 'title' in the Item table (which
I'm guessing is the case from the schema you gave above), try using:

$items = $this->Item->find('list');
$this->set(compact('items'));.

If your field isn't called 'name' or 'title', then you can set the
$displayField variable in the Item model for whatever field name you
use to identify the items.  This should be enough for cake to
automagically populate the form input on your view pages (if you are
using the form helper, of course).

-Joel.


On Jun 5, 11:41 pm, winter <[EMAIL PROTECTED]> wrote:
> Thanks Chris. I read your reply and went over it again this morning
> and managed to get that association to work. The bit that is still
> stumping me is the html select. I still can't do: $this->set('items',
> $this->Item->findAll()); in my add() function in units_controller.php.
> I want to pass all the items to the add view and have them populate an
> html select. Perhaps there is a built-in cake method for doing this.
> Am I going about it wrong? Thanks for your help. It's much appreciated.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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: Pure Cake Power in RC1

2008-06-04 Thread Joel Perras

Kudos to the whole team.  From the SVN logs, I can tell that the last
few weeks have been quite the furious rush of bugfixes and
enhancements to push out this RC.  Your efforts are greatly and
sincerely appreciated, and is the reason why CakePHP outperforms any
other PHP framework in existence.

-Joel.

--
"If I have seen farther it is by standing on the shoulders of Giants"
-I. Newton

On Jun 4, 6:49 pm, Gwoo <[EMAIL PROTECTED]> wrote:
> We are very happy to announce the latest release of the best and most
> popular framework for web development.  The release marks a great
> milestone for CakePHP, where we involved more developers, implemented
> better code coverage (with analysis!), received more contributions
> from more community members, and ended up with a stable and feature
> rich 1.2 release candidate [1].
>
> This release is not without it's major changes, but thankfully this
> should be the last of those. The two most significant changes come in
> the usage of conditions and the deprecation of several methods.
>
> Query conditions have always been a concern of ours, for the obvious
> reason of helping developers maintain secure applications. We found
> that in some cases, it was possible to work around what Cake expects
> to produce undesirable results.  To help ensure that applications are
> secure with no extra effort on the part of the developer, we have
> moved all operators used in conditions to the "key" side. For example,
> $conditions = array('Model.field >' => $value); is the new syntax. We
> have maintained backwards compatibility for the most common cases, you
> will need to update your affected application code.
>
> Deprecation is something we do our best to avoid, but sometimes in the
> interest of a simple, pure API we make the move to remove some of
> those old methods that have given way to simpler code.
> View::renderElement() is one such method that has given way to
> View::element(); You will not see a notice in this release, however,
> the next release will throw a notice and in the subsequent release the
> method will be removed completely. Speaking of removed methods, any
> deprecated code that existed prior to this release is now gone. There
> are a few other methods, mainly some more of those found in basics
> that have been deprecated. Check out the changelog[2] and have a look
> at the API[3] to see where these changes were made.
>
> We also have exciting new enhancements in this release of Cake 1.2. We
> already alluded to the code coverage analysis. Code coverage is
> helping to ensure that we test as many lines of code as possible. If
> you have XDebug installed, you can take advantage of this nice
> feature. Another highly desirable feature has been additional support
> for more advanced queries. To help in this area we added the
> ContainableBehavior. The behavior is a optimized combination of the
> code used by Felix (in his behavior by the same name) and Mariano (in
> the BindableBehavior). If you were using either of these two behaviors
> before you may notice some slight changes to syntax, but overall the
> functionality makes for very powerful find operations.  Several other
> more minor enhancements trickled their way into the core, and we will
> leave you to peruse the changelog[2] for those.
>
> With all of these improvements and updates, being a CakePHP developer
> and building new projects on CakePHP is better than ever. To help out
> the project and everyone in the community, we have partnered with
> EliteOpenSourceJobs.com. EliteOpenSourceJobs.com is a start-up that
> aims to help open source communities raise funds through hosting their
> own job boards. They make it simple and painless for communities like
> ours to provide a service for developers and employers to create new
> applications and technology together. Check out the CakePHP job board
> athttp://cakephp.org/jobs. Posting to the job board carries a fee,
> but we do that to ensure that the post is legitimate and to help the
> continued growth of CakePHP.
>
> We have also begun using Ohloh Journals to let the everyone know what
> is going on. You can see the feed of CakePHP team members on the
> CakePHP.org homepage and Planet. Ohloh is great resource that helps us
> keep track of the project. Check it out and follow us on the
> journals[4].
>
> Overall, more than 800 revisions have produced this release. We must
> thank everyone who contributed to the effort by writing tests,
> creating patches, and committing code. We hope you all enjoy the
> release and look forward to a quick release candidate cycle.
>
> Bake on.
>
> [1]http://cakeforge.org/projects/cakephp/
> [2]http://trac.cakephp.org/wiki/changelog/1.2.x.x
> [3]http:/

Re: Validation - some things are more alphanumeric than others

2008-06-02 Thread Joel Perras

Very true.  I'll file a ticket today.

-Joel.

On Jun 2, 10:54 am, "Chris Hartjes" <[EMAIL PROTECTED]> wrote:
> On Mon, Jun 2, 2008 at 10:40 AM, leo <[EMAIL PROTECTED]> wrote:
>
> > I only meant, but didn't explain very well (at all) that it is no
> > longer good enough to assume that the whole world speaks American
> > English. While there is a good case for English-based programming
> > languages, programming is about end-users. They don't know and don't
> > want to know about limitations of 8 bits or ASCII's definition of the
> > alphabet, nor do clients or project managers. They just want to be
> > able to read things in their own language. We're getting there slowly.
>
> Programming is also about the people who write it as well, and I'd be
> willing to bet that this thread will be ignored if there is no ticket
> filed.
>
> --
> Chris Hartjes
> Internet Loudmouth
> Motto for 2008: "Moving from herding elephants to handling snakes..."
> @TheKeyBoard:http://www.littlehart.net/atthekeyboard
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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: Validation - some things are more alphanumeric than others

2008-06-02 Thread Joel Perras

Ok, I'm a big enough man to admit when I'm wrong.
After reading the POSIX specification for alphanumeric characters and
realizing that it accomodates for different character set collations,
I concede that you are correct in stating that 'alphanumeric' should
apply to accented characters.

However, the fact that English is not the most spoken language in the
world is a vacuous argument; by your reasoning, programming languages
should be written and interpreted in Chinese and Spanish instead of
English.  I have yet to find a compiled or interpreted Chinese
programming language, and I don't think they exist AFAIK.
English is ubiquitous in the scientific (and software) community, and
there's not much we can do to change this (my first language is
French), nor would I want to.


Anyways, here's what I've found:

After doing a bit of research, I believe the solution to your problem
is this regular expression:  /[^[:alnum:]]/u

Ex:

//1st element will pass, 2nd ?, 3rd will fail
$data = array("asdf1", "çñasd45", "@#%asd23");

foreach ($data as $str):
if (!preg_match("/[^[:alnum:]]/u", $str)) echo $str . " is
valid alphanumeric. \n\n"';
else echo $str . " IS NOT VALID\n\n";
endforeach;

print_r($data);

//Output:

asdf1 is valid alphanumeric.

çñasd45 is valid alphanumeric.

@[EMAIL PROTECTED] IS NOT VALID

Array
(
[0] => asdf1
[1] => çñasd45
[2] => @#%asd23
)


On Jun 2, 4:56 am, leo <[EMAIL PROTECTED]> wrote:
> I did click the link and I followed the references. It would seem that
> a letter like ñ or ç is a letter embellished with a diacritic.
> Therefore the letter is valid and the diacritic should be ignored. Ñ
> is alpha.
>
> From the same source, Spanish is spoken as a first language by between
> 322 and 400 million people. English by 375 million. The English
> speaking population of the USA is 215 million. Furthermore, Spanish is
> a Latin language and the ASCII definition is based on the Latin
> alphabet.
>
> > >http://en.wikipedia.org/wiki/Alphanumeric
>
> Things have moved on from the World as defined by IBM et al
> (thankfully), but unfortunately the World has now become defined, in
> the eyes of many, by Wikipaedia. Wikipaedia is a useful tool used in
> conjunction with others, but dangerous on its own.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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: Difference between read() and find()?

2008-06-01 Thread Joel Perras

When you call Model::read(), the data returned is automatically set in
the Model::$data array.  When you call Model::find(), this does not
occur.

Also, with Model::read() you can only scan the model by the id; you
cannot perform complex operations that you can do with Model::find().

Note:  Model::read() actually calls Model::find() to obtain the
resultset desired.

-Joel.

On May 25, 10:29 am, Action <[EMAIL PROTECTED]> wrote:
> When is it preferable to useread() instead offind() to query data
> from the database?
>
> In the blog tutorial,read() is used:
>
> $this->Post->id = $id;
> $this->set('post', $this->Post->read());
>
> BUT, I've always just usedfind/ findBy:
>
> $this->set('post', $this->Post->findById($id));
>
> What's the difference?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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: Validation - some things are more alphanumeric than others

2008-05-30 Thread Joel Perras

I agree, and I do this myself in dual-language (English/French)
localised sites.

However, I was simply attempting to illustrate to the original poster
that the 'alphanumeric' rule does exactly what it is suppsed to do, as
per the definition of 'alphanumeric'.  The regex for multibyte
alphanumeric characters is (I believe) simple enough, but you need to
ensure that the characters are UTF-8 encoded.  If you don't know the
encoding, then I have no idea how you would be able to perform the
validation rule (and if this is something that someone has done
before, I will be forever grateful if you explain how to do it), and
hence my comment on the 'impossibility' of a universal alphanumeric
validation rule.  Cake is a wonderful tool, but sometimes you need to
get your hands dirty.

If my regex-fu is still up to par, I believe /[\w\pL]/u to be the
correct multibyte regex to match alphanumeric characters.  If this is
false, please correct me.

-Joel.

On May 30, 2:13 pm, Adriano Varoli Piazza <[EMAIL PROTECTED]> wrote:
> On May 30, 2:25 pm, Joel Perras <[EMAIL PROTECTED]> wrote:
>
> >http://en.wikipedia.org/wiki/Alphanumeric
>
> > In case you don't click the above link:
>
> > "Alphanumeric is a is portmanteau of alphabetic and numeric and is
> > used to describe the collection of Latin letters and Arabic digits
> > used by much of western society. There are either 36 (single case) or
> > 62 (case-sensitive) alphanumeric characters. The alphanumeric
> > character set consists of the numbers 0 to 9 and letters A to Z."
>
> > I'd love for Cake to have a built-in validation rule that would
> > validate all Latin/Cyrillic/Asian/Arabic alphanumeric characters, but
> > that's pretty much impossible.
>
> Validating them all at the same time might be, but localizing a
> website to cater to different alphabets or languages is doable. When I
> have to validate against Spanish rules, I don't cower in fear of kanji
> or arabic, I simply validate alphanumeric characters for my language,
> such as á, é, ñ, etc. After all, \w in Perl (or the equivalent regex
> entity for a word) is localized, IIRC.
>
> Saludos
> Adriano
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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: Validation - some things are more alphanumeric than others

2008-05-30 Thread Joel Perras

http://en.wikipedia.org/wiki/Alphanumeric

In case you don't click the above link:

"Alphanumeric is a is portmanteau of alphabetic and numeric and is
used to describe the collection of Latin letters and Arabic digits
used by much of western society. There are either 36 (single case) or
62 (case-sensitive) alphanumeric characters. The alphanumeric
character set consists of the numbers 0 to 9 and letters A to Z."

I'd love for Cake to have a built-in validation rule that would
validate all Latin/Cyrillic/Asian/Arabic alphanumeric characters, but
that's pretty much impossible.

-Joel.

On May 30, 12:56 pm, leo <[EMAIL PROTECTED]> wrote:
> I will on Monday - it's seven pm and time to go shout at the kids.
>
> On 30 Maig, 18:55, "Chris Hartjes" <[EMAIL PROTECTED]> wrote:
>
> > On Fri, May 30, 2008 at 12:53 PM, leo <[EMAIL PROTECTED]> wrote:
>
> > > Letters like ñ & ç fail the following validation:
>
> > > 'rule' => 'alphaNumeric'
>
> > > I would say that's a bug, but my head still hasn't grown back from the
> > > last time I said that, so I won't.
>
> > That is probably because the regex that checks for alphaNumeric might
> > not be UTF-8 friendly.  Don't panic, just file a ticket while your
> > head regrows.
>
> > --
> > Chris Hartjes
> > Internet Loudmouth
> > Motto for 2008: "Moving from herding elephants to handling snakes..."
> > @TheKeyBoard:http://www.littlehart.net/atthekeyboard
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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: OR operator in query

2008-05-29 Thread Joel Perras

I might be misunderstanding what you are expecting as a result set,
but you could simply do:

$this->Movement->find('count', array(
   'conditions' => array(
'Movement.status'=> array(11,12)
   ),
   'recursive' => -1
));

This would produce the query:

SELECT COUNT(*) AS `count` FROM `movements` AS `Movement` WHERE
`Movement`.`type` IN (11,12);

Which is equivalent (in a boolean logic sense) to the query that I
think you are attempting to construct.

-Joel.

On May 29, 12:40 pm, propellorcut <[EMAIL PROTECTED]> wrote:
> I'm trying to find the number of records returned based on a certain
> column having the value 11 or 12. I think I'm writing this correctly,
> but cake doesn't like the fact that I have an OR statement based on 1
> column.
>
> this statement:
>
> $outstanding = $this->Movement-
>
> >find('count',array('conditions'=>array('OR'=>array('Movement.status'=>11,'Movement.status'=>12)),'recursive'=>-1));
>
> produces this query:
>
> SELECT COUNT(*) AS `count` FROM `movements` AS `Movement` WHERE
> ((`Movement`.`status` = 12))
>
> I've tried changing this up a bit and have 2 different columns:
>
> $outstanding = $this->Movement-
>
> >find('count',array('conditions'=>array('OR'=>array('Movement.type'=>11,'Movement.status'=>12)),'recursive'=>-1));
>
> produces:
>
> SELECT COUNT(*) AS `count` FROM `movements` AS `Movement` WHERE
> ((`Movement`.`type` = 11) OR (`Movement`.`status` = 12))
>
> This leads me to believe I'm writing this correctly, cake just won't
> do the OR statement on a single column.
>
> Anyone have any ideas? Otherwise I'll just manually write the query,
> but I wanted to do it properly.
>
> Thanks.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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: Different performance between 1.1 and 1.2

2008-05-28 Thread Joel Perras

On May 28, 12:58 pm, "[EMAIL PROTECTED]"
<[EMAIL PROTECTED]> wrote:
> With debug=2 the queries are exaclty equal except for the DESCRIBE
> operation on the joinTable.

As I stated previously, when debug = 0 these queries are cached.
> Perhaps it'is a my feeling.
> Exist a instrument for evalute the time loading of a scripts?

A quick and dirty way of benchmarking page rendering time would be to
put a call to microtime() in app_controller.php in both the
beforeRender() and afterFilter() methods, and echo/log the time
difference between the two.

> Is it possible to use eAccelarator with Cake 1.2?

Cake actually uses Memcache (a PHP wrapper for memcached) for
caching.  Sadly there isn't anything in book.cakephp.org describing
this (yet), but a few well placed google queries and a quick search of
this group should give you an idea of how things work.  I've never
used eAccelerator, but I've heard of other people who have used it in
conjunction with Cake.


-Joel.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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: Different performance between 1.1 and 1.2

2008-05-28 Thread Joel Perras

When you set your debug configure level above 0 (which you have done
to be able to see the relevant SQL queires), the model caches are
refreshed.  When in production mode (debug level of 0), the DESCRIBE
query results are cached.

You'll have to be more specific when saying 'is slower than the same
application on 1.1.13' to get any useful information on how to
optimize.  Is there more data being sent to the views than necessary?
Are there superfluous queries being run?  Have you changed anything
else since your upgrade, i.e. controller logic, model logic, etc.?

-Joel.

On May 28, 9:49 am, "[EMAIL PROTECTED]"
<[EMAIL PROTECTED]> wrote:
> Hi
> I have a question.
> I upgrade my applications from 1.1.13 to 1.2
> I have noted that the same application in 1.2 is slower than the same
> application on 1.1.13.
> I use $this->Model->unbind and $this->Model->recursive=-1   in my
> applications.
> I have two query:
> 1) In Cake 1.2 for use $this->Model->unbind and $this->Model->recursive=-1 I 
> have to set some $actas or they work even if I have no
>
> $actas setted?
> 2)I have analized queries (debug set 2) and I see that there are some
> queries to determinate fields of the join tables of the HABTM's
> relation (DESCRIBE  ) .Is it possible to do that my application
> doesn't execute these queries?
>
> Many Thanks
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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: Auth heisenbug

2008-05-23 Thread Joel Perras

Thanks for the update.

On May 23, 11:19 am, "b logica" <[EMAIL PROTECTED]> wrote:
> It seems to have been related to the  known bug with security set to
> "high". I didn't think it was the same thing but I changed the setting
> to medium and the problem seems to have disappeared for the moment.
>
> On Fri, May 23, 2008 at 8:52 AM, Joel Perras <[EMAIL PROTECTED]> wrote:
>
> > Well, it's probably grasping at straws, but maybe take a look at
> > what's being done to your Cake session variables, especially
> > Auth.redirect.  Since this bug seems to appear and disappear at
> > random, there are very few things that could be causing it; I can only
> > think of HTTP headers and Session vars being lost or changed in some
> > way.
>
> > Let me know how you end up solving this.
>
> > -Joel.
>
> > On May 22, 6:05 pm, "b logica" <[EMAIL PROTECTED]> wrote:
> >> On Thu, May 22, 2008 at 3:21 PM, Joel Perras <[EMAIL PROTECTED]> wrote:
>
> >> > Try debugging env('HTTP_REFERER') in addition to what
> >> > Controller::referer($alt_redirect, true) gives you; your headers might
> >> > be getting mangled for some reason or other.
>
> >> I just can't imagine how that would affect things though, as these
> >> requests are coming after the login request. Cake authorises me, then
> >> forgets it for the next request (and sometimes for up to the next 3 or
> >> 4 requests).
>
> >> > Also, is there a specific reason you are statically accessing the
> >> > Controller::referer() method instead of using $this->referer() ?
>
> >> No. I have no idea why i wrote it like that. Hadn't noticed.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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: Auth heisenbug

2008-05-23 Thread Joel Perras

Well, it's probably grasping at straws, but maybe take a look at
what's being done to your Cake session variables, especially
Auth.redirect.  Since this bug seems to appear and disappear at
random, there are very few things that could be causing it; I can only
think of HTTP headers and Session vars being lost or changed in some
way.

Let me know how you end up solving this.

-Joel.

On May 22, 6:05 pm, "b logica" <[EMAIL PROTECTED]> wrote:
> On Thu, May 22, 2008 at 3:21 PM, Joel Perras <[EMAIL PROTECTED]> wrote:
>
> > Try debugging env('HTTP_REFERER') in addition to what
> > Controller::referer($alt_redirect, true) gives you; your headers might
> > be getting mangled for some reason or other.
>
> I just can't imagine how that would affect things though, as these
> requests are coming after the login request. Cake authorises me, then
> forgets it for the next request (and sometimes for up to the next 3 or
> 4 requests).
>
> > Also, is there a specific reason you are statically accessing the
> > Controller::referer() method instead of using $this->referer() ?
>
> No. I have no idea why i wrote it like that. Hadn't noticed.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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: hasOne association

2008-05-22 Thread Joel Perras

In your Player model:

class Player extends AppModel
{
var $name = 'Player';
var $primaryKey = 'player_id';// <-- Without this, Cake
assumes that the primary key of your model is named 'id'.
var $hasOne = array('Playerstat' => array(
'className' =>'Playerstat',
'foreignKey' =>'player_id',
'dependent' => true
));

}

On May 22, 1:30 pm, cooked <[EMAIL PROTECTED]> wrote:
> I am stumped with a problem when using model associations. For the
> some reason the findAll generates an incorrect join query. Will great
> appreciate any help. Both my models and controllers along with the
> MySql output
> is shown below.
>
> class Playerstat extends AppModel
> {
>     var $name = 'Playerstat';
>     var $belongsTo = array('Player' => array(
>                                               'className' => 'Player',
>                                               'foreignKey' =>
> 'player_id'));
>
> }
>
> class Player extends AppModel
> {
>     var $name = 'Player';
>     var $hasOne = array('Playerstat' => array(
>                                               'className' =>
> 'Playerstat',
>                                               'foreignKey' =>
> 'player_id',
>                                               'dependent' => true));
>
> }
>
> Each Player record has a corresponding Playerstat record. player_id is
> the primary key in
> table players and player_id is the foreign key in playerstat.
>
> I have the following code in one of my controller function
>
>         $status = PLAYER_ACTIVE;
>         $results = $this->Player->findAll("Player.active = $status AND
> Player.level = 'A'",
>                                            array("Player.fname", 
> "Player.lname",
> "Playerstat.wins", "Playerstat.loss",
>                                                    "Playerstat.points", 
> "Playerstat.last_played"),
> 'Playerstat.points DESC');
>
> I get the following result from MySql
>
> Query: SELECT `Player`.`fname`, `Player`.`lname`, `Playerstat`.`wins`,
> `Playerstat`.`loss`, `Playerstat`.`points`, `Playerstat`.`last_played`
> FROM `players` AS `Player` LEFT JOIN `playerstats` AS `Playerstat` ON
> (`Playerstat`.`player_id` = `Player`.`id`) WHERE `Player`.`active` = 1
> AND `Player`.`level` = 'A' ORDER BY `Playerstat`.`points` DESC
>
> Warning (512): SQL Error: 1054: Unknown column 'Player.id' in 'on
> clause' [CORE/cake/libs/model/datasources/dbo_source.php, line 440]
>
> The players table does not have an "id" field it is suppose to be
> player_id. What I am doing wrong? How can I make "id" into
> "player_id".
>
> Thanks,
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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: Auth heisenbug

2008-05-22 Thread Joel Perras

Try debugging env('HTTP_REFERER') in addition to what
Controller::referer($alt_redirect, true) gives you; your headers might
be getting mangled for some reason or other.
Also, is there a specific reason you are statically accessing the
Controller::referer() method instead of using $this->referer() ?

-Joel.


On May 22, 1:45 pm, "b logica" <[EMAIL PROTECTED]> wrote:
> Suddenly, authentication for my app hasbecome completely unhinged.
> This was working perfectly yesterday but now I'm (almost) always
> redirected back to the login page. The only thing I've changed has to
> do with $loginRedirect, but I can't see how that would cause Auth to
> forget that I'm authenticated.
>
> My login() looks like (in part):
>
> /* I have 3 types of users who might log in. I need to create model
> for each, rather than use roles, because
>  * their needs are quite different. So, I grab the model name from the
> users table
>  */
> $model_name = $user['User']['model'];
> $this->User->bindModel(array('hasOne'=>array($model_name=>array(;
>
> /* This allows me to save a bit of personal info and set the default
> redirect page if there's
>  * no referer.
>  */
> switch($model_name)
> {
>         case 'Admin':
>                 $name = 
> $this->User->Admin->getName($user['User']['foreign_key']);
>                 $user['User']['name'] = $name['name'];
>                 $alt_redirect = '/admin';
>                 break;
>         case 'Member':
>                 $name_and_slug =
> $this->User->Member->getNameAndSlug($user['User']['foreign_key']);
>                 $user['User']['name'] = $name_and_slug['name'];
>                 $user['User']['slug'] = $name_and_slug['slug'];
>                 $alt_redirect = '/';
>                 break;
>         case 'Artist':
>                 $name_and_slug =
> $this->User->Artist->getNameAndSlug($user['User']['foreign_key']);
>                 $user['User']['name'] = $name_and_slug['name'];
>                 $user['User']['slug'] = $name_and_slug['slug'];
>                 $alt_redirect = '/';
>                 break;
>
> }
>
> /* This is the only change made since yesterday. I added the
> $alt_redirect so that admins will be sent
>  * to their dashboard page if there's no referer
>  */
> $this->Session->write('User', $user['User']);
> $this->Auth->loginRedirect = Controller::referer($alt_redirect, true);
> $this->redirect($this->Auth->redirect());
>
> AppController::isAuthorised():
>
> function isAuthorized()
> {
>         if (isset($this->params[Configure::read('Routing.admin')]))
>         {
>                 if ($this->Auth->user('model') != 'Admin')
>                 {
>                         $this->log('not ok: '.$this->Auth->user('model'));    
>                         return false;
>                 }
>         }
>
>         $this->log('ok');
>         return true;
>
> }
>
> I put the log statements in just now to try to figure out what's going wrong.
>
> So, if I browse to:
> /admin/artists/edit/58
>
> I'm correctly redirected to the login page:
> /admin/users/login
>
> and, in turn, redirected to the edit form and the log says, "ok". When
> I hit submit, sometimes it works, and sometimes I'm sent back to the
> login page. In the latter case, I never see the "not ok: Admin" in the
> log. So, if the problem does not lie with isAuthorised() how/why am I
> being redirected?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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: Static Page

2008-05-22 Thread Joel Perras

Wow, I should really start taking the time to actually read the
snippets posted.
On the other hand, if people stop imagining that others can read their
minds and start formulating questions that actually address their
problem at hand, then they'd probably get more precise answers.

-J.

On May 22, 10:15 am, "b logica" <[EMAIL PROTECTED]> wrote:
> I suspect that Phaedo--like myself--has a flash() method in
> AppController that runs the redirect. Note the second param given.
>
> I see a few things not quite right with the example. Are you certain
> that the databas is being updated? There's no version given but, if
> using 1.2:
>
> $this->Sorrow->id = $id;
> This is superfluous. Better to just use read().
>
> if (empty($this->data)) {
>      $this->set('sorrow', $this->Sorrow->read());
>      $this->data = $this->Sorrow->read();
> Speaking of unnecessary, why do this twice? What are you doing in the
> view with $sorrow that can't be done with the anonymous (and, perhaps,
> less glamorous ;-) data array?
>
> Anyway, it should be $this->Sorrow->read(null, $id);
>
> } else {
>
>     if ($this->Sorrow->save($this->data['Sorrow'])) {
>
> That should be "...save($this->data)", AFAICT.
>
>         $this->flash('Your post has been updated.','/sorrows');
>
> Difficult to say without seeing your flash() method.
>
> On Wed, May 21, 2008 at 9:34 PM, Joel Perras <[EMAIL PROTECTED]> wrote:
>
> > $this->redirect('name_of_action_you_are_redirecting_to');
>
> > Boom-shacka-lacka-boom.
> > -Joel.
>
> > On May 21, 9:00 pm, phaedo5 <[EMAIL PROTECTED]> wrote:
> >> I have this Edit view in my controller.
>
> >>         function edit($id = null) {
> >>                 $this->Sorrow->id = $id;
> >>                 if (empty($this->data)) {
> >>                         $this->set('sorrow', $this->Sorrow->read());
> >>                         $this->data = $this->Sorrow->read();
> >>                 } else {
> >>                         if ($this->Sorrow->save($this->data['Sorrow'])) {
> >>                                 $this->flash('Your post has been 
> >> updated.','/sorrows');
> >>                         }
> >>                 }
> >>         }
>
> >> I was hoping that it would update the database, which it does, and
> >> then redirect to the index view.  Am I missing something?  Obviously I
> >> am, the question is - what am I missing?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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: Saving NOW() in model

2008-05-22 Thread Joel Perras

It doesn't really matter whether or not you obtain the date from
Apache/PHP or MySQL; as long as you are consistent.

On May 22, 4:01 am, djiize <[EMAIL PROTECTED]> wrote:
> I use the same way as Stephen
> Because what if MySQL is hosted on another server than Apache/PHP ?
> You'll save Apache/PHP time which can be different of MySQL time (no
> the same meridian for instance).
> Of course, it's a very specific case.
> And my servers are time synchronised together, but some time
> differences appeared once or twice a year.
>
> On 22 mai, 07:47, Stephen Orr <[EMAIL PROTECTED]> wrote:
>
> > I believe I used this method:
>
> > 'last_login' => '!-NOW()'
>
> > Which makes Cake stop trying to quote it. But I'm pretty sure the
> > latest SVN revision recognises NOW() and doesn't quote it anyway.
> > Maybe I'm confused.
>
> > Steve
>
> > On May 22, 2:12 am, Alex Ciobanu <[EMAIL PROTECTED]> wrote:
>
> > > Zifnab wrote:
> > > > I'm trying to figure out how to implicitly make a mysql NOW() call
> > > > when doing a model save...here's an example of the code:
>
> > > > $aUserData = array(
> > > >     'User'  =>  array(
> > > >         'id' => 4,
> > > >         'last_login' => 'NOW()'
> > > >     )
> > > > );
>
> > > > $this->User->save( $aUserData, false, array( 'last_login' ) );
>
> > > > Naturally the save doesn't work, because NOW() saves as a string
> > > > "NOW()" instead of as a mysql function NOW()How do I get it to
> > > > save as a mysql function?
>
> > > $aUserData['User']['last_login'] = date("Y-m-d H:i:s");
> > > $this->User->save($aUserData);
>
> > > Not using NOW(), but does the trick.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"CakePHP" 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
-~--~~~~--~~--~--~---



  1   2   3   >