Friday, April 1, 2011

Re: 1 form 2 models - how to validate without savingAll?

hi ryandesign,

thanks for pointing me to this wizard..

I had a look and I saw on the function _validateData and in the example that it's using a formula like this

var $uses = array('User','Profile');
$this->User->set($this->data);
$this->Profile->set($this->
data);
if ($this->User->validates() && $this->Profile->validates()) {

which I had also tried without success what could be doing so?

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
 
 
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

Re: 1 form 2 models - how to validate without savingAll?

hi ryandesign,

thanks for pointing me to this wizard..

I had a look and I saw on the function _validateData and in the example that it's using a formula like this

var $uses('User','Profile');
$this->User->set($this->data);
$this->Profile->set($this->data);
if ($this->User->validates() && $this->Profile->validates()) {

which I had also tried without success what could be doing so?

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
 
 
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

Re: execute query twice in a short time is a problem?

Couldn't do what? It's hard to work out what you are trying to achieve. Can you explain in simple language?

On 1 Apr 2011, at 08:27, Shinya Koizumi wrote:

CakePHP didn't or couldn't do it that's why i was experimenting something different.


On Fri, Apr 1, 2011 at 12:25 AM, Ryan Schmidt <google-2010@ryandesign.com> wrote:
On Mar 31, 2011, at 14:52, cake-learner wrote:

> foreach( $arrEmp as $employeeObj ){
> $options = array( "survey_name" => $surveyObj[ 0 ][ 'Survey' ]
> [ 'survey_name' ] );
> $this -> Notification -> create( 'Report card is realeased','',
> $currentUser[ 'Account' ][ 'id' ], $employeeObj[ 'e' ]
> [ 'accounts_id' ], 7, "HR Department", $options );
> }
>
> /**
> * create function in Notification Component
> */
> function create( $subject, $message="", $creator, $recepient, $type =
> 0, $from, $options=null ){
> $this -> controller -> loadModel('Notification');
> $this -> controller ->  Notification -> create();
> $notification[ 'subject' ] = htmlentities( $subject );
> $notification[ 'message' ] = htmlentities( $message ) .
> $defaultMessage;
> $notification[ 'from' ] = htmlentities( $from );
> $notification[ 'creator' ] = $creator;
> $notification[ 'sentto' ] = $recepient;
> $notification[ 'type' ] = $type;
>
> foreach( $notification as $key => $value ){
>  $arrKey[] = $key;
>  $arrValues[] = $value;
> }
>
> $sql .= "INSERT INTO notifications (" . implode( ",", $arrKey ) . ")
> values (" . implode( "," , $arrValues ) . " )";
> $this -> controller ->  Notification -> Query( $sql );
> }

This looks fairly messy. Why are you writing raw SQL and not letting a CakePHP model do it for you?


--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php


--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
 
 
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

Re: execute query twice in a short time is a problem?

CakePHP didn't or couldn't do it that's why i was experimenting something different.


On Fri, Apr 1, 2011 at 12:25 AM, Ryan Schmidt <google-2010@ryandesign.com> wrote:
On Mar 31, 2011, at 14:52, cake-learner wrote:

> foreach( $arrEmp as $employeeObj ){
> $options = array( "survey_name" => $surveyObj[ 0 ][ 'Survey' ]
> [ 'survey_name' ] );
> $this -> Notification -> create( 'Report card is realeased','',
> $currentUser[ 'Account' ][ 'id' ], $employeeObj[ 'e' ]
> [ 'accounts_id' ], 7, "HR Department", $options );
> }
>
> /**
> * create function in Notification Component
> */
> function create( $subject, $message="", $creator, $recepient, $type =
> 0, $from, $options=null ){
> $this -> controller -> loadModel('Notification');
> $this -> controller ->  Notification -> create();
> $notification[ 'subject' ] = htmlentities( $subject );
> $notification[ 'message' ] = htmlentities( $message ) .
> $defaultMessage;
> $notification[ 'from' ] = htmlentities( $from );
> $notification[ 'creator' ] = $creator;
> $notification[ 'sentto' ] = $recepient;
> $notification[ 'type' ] = $type;
>
> foreach( $notification as $key => $value ){
>  $arrKey[] = $key;
>  $arrValues[] = $value;
> }
>
> $sql .= "INSERT INTO notifications (" . implode( ",", $arrKey ) . ")
> values (" . implode( "," , $arrValues ) . " )";
> $this -> controller ->  Notification -> Query( $sql );
> }

This looks fairly messy. Why are you writing raw SQL and not letting a CakePHP model do it for you?


--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.
 
 
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

Re: execute query twice in a short time is a problem?

On Mar 31, 2011, at 14:52, cake-learner wrote:

> foreach( $arrEmp as $employeeObj ){
> $options = array( "survey_name" => $surveyObj[ 0 ][ 'Survey' ]
> [ 'survey_name' ] );
> $this -> Notification -> create( 'Report card is realeased','',
> $currentUser[ 'Account' ][ 'id' ], $employeeObj[ 'e' ]
> [ 'accounts_id' ], 7, "HR Department", $options );
> }
>
> /**
> * create function in Notification Component
> */
> function create( $subject, $message="", $creator, $recepient, $type =
> 0, $from, $options=null ){
> $this -> controller -> loadModel('Notification');
> $this -> controller -> Notification -> create();
> $notification[ 'subject' ] = htmlentities( $subject );
> $notification[ 'message' ] = htmlentities( $message ) .
> $defaultMessage;
> $notification[ 'from' ] = htmlentities( $from );
> $notification[ 'creator' ] = $creator;
> $notification[ 'sentto' ] = $recepient;
> $notification[ 'type' ] = $type;
>
> foreach( $notification as $key => $value ){
> $arrKey[] = $key;
> $arrValues[] = $value;
> }
>
> $sql .= "INSERT INTO notifications (" . implode( ",", $arrKey ) . ")
> values (" . implode( "," , $arrValues ) . " )";
> $this -> controller -> Notification -> Query( $sql );
> }

This looks fairly messy. Why are you writing raw SQL and not letting a CakePHP model do it for you?


--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

Re: Cake PHP session does not work

On Mar 31, 2011, at 10:26, Eriko wrote:

> I made some system for my customer with CakePHP 1.3.6.
> It worked as we planned on the test server but it go wrong on the
> customer's server.
>
> 1. Session does not work.
> 2. Some garbaged character is shown one moment and after then it is
> shown precisely.
> That system is in Japanese.
> It seems one moment it is shown in Shift_JIS and then redirect to
> UTF-8.
> 3. Redirect does not work because "header is already sent" error.

Why is the header already sent? Where?


> PHP version is 5.2.17.

Please upgrade to 5.3.x.


> The difference of the test server and customer's server is that PHP is
> CGI mode one the customer's server.

Then you should probably be developing with PHP's CGI SAPI on your development machine too. Make your development machine as similar to the production machine as possible.


--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php

Re: 1 form 2 models - how to validate without savingAll?

On Mar 31, 2011, at 19:10, netusco wrote:

> I'm having a 3 steps form so I'm not saving the data in each step, only validating it and passing it hidden in each step.
>
> In the form I use 2 different models.
>
> So if I try to validate like this:
> $this->User->set($this->data);
> $this->User->Profile->set($this->data);
> if ($this->User->validates() && $this->User->Profile->validates()) { ...
>
> I'm only getting the User data validated. If I comment the first line the one that sets the data for User model then I get the Profile data validated.
>
> So How can I get them both at the same time??? (without using saveAll!)

For a multi-page form, consider using the Wizard component, or reading its code to see how it does it.

https://github.com/jaredhoyt/cakephp-wizard


--
Our newest site for the community: CakePHP Video Tutorials http://tv.cakephp.org
Check out the new CakePHP Questions site http://ask.cakephp.org and help others with their CakePHP related questions.


To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php