> 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
No comments:
Post a Comment