Re: Using ORM Entity mutators to change value doesn't work
Do you mean a Type class to tranform spaces in commas and reverse it? Is it really useful? Or do you mean a Type to jsonize, serialize? Il 14/feb/2014 17:31 "José Lorenzo" ha scritto: > Thanks, for getting back. Also I realized that I wrote directly to you > instead of the group. The types system was designed with that in mind, you > should use it instead of entity getters and setters. I hope to post a few > examples on that when I get more time. Maybe you can help us writing that > specific type class and document it, that would be of great help! > > > On Fri, Feb 14, 2014 at 4:04 PM, Alberto Pagliarini > wrote: > >> Thanks José for the answer. >> >> Let me know what you decide and if I can help. >> Anyway my example is born because I often need to save data in different >> format from original (serialize/unserialize, json_encode, json_decode, >> etc..) and I think would be cleaver do it with setter and getter. >> >> For serialize and json maybe I could use custom Type >> http://book.cakephp.org/3.0/en/orm/database-basics. >> html#adding-custom-types but I need to study how it works and for other >> data manipulation (as in example above) define a custom type would be >> unsuitable. >> >> cheers >> alberto >> >> >> 2014-02-14 14:48 GMT+01:00 José Lorenzo : >> >>> I need to think about this for a bit. The only reason that people seem >>> to be wanting getters in the entity is for doing presentational formatting >>> on the same properties as the database, which was not my original >>> intention. I'll look into a solution for this so it is more intuitive. >>> >>> On Friday, February 14, 2014 11:02:39 AM UTC+1, bato wrote: Il giorno venerdì 14 febbraio 2014 01:57:53 UTC+1, mark_story ha scritto: > > One more thing. The orm will use the getter functions when preparing > the data to be saved. Since your getter reverses te setter. This might be > the source of your problem. > > > Yes, commenting the getter the save works as expected. But how can I do what I was trying to do? I would expect that saving use setter but not getter so as I can save some modified data and retireve later in the original format. I.e. saving data original data = 'name surname' => save (use setter) => save on db 'name,surname' retrieving data saved data on db 'name,surname' => find (use getter) => original data 'name surname' I know I could obtain the same results modifing original data before saving it but I would know if there is a method using ORM properties. thanks for your great work alberto >> >> >> -- >> -- bato --- >> >> -- 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 unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/groups/opt_out.
Re: Problem with encoding when reading in the mySql
- I've reinstalled mysql_server to latest version 5.5.35. - exported my database - I've added to the my.cnf: init_connect='SET collation_connection = utf8_unicode_ci' init_connect='SET NAMES utf8' character-set-server=utf8 collation-server=utf8_unicode_ci skip-character-set-client-handshake - imported my database Now, it's fixed -Samuel -- 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 unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/groups/opt_out.
Re: cakephp model returns data in wrong character set
- I've reinstalled mysql_server to latest version 5.5.35. - exported my database - I've added to the my.cnf: init_connect='SET collation_connection = utf8_unicode_ci' init_connect='SET NAMES utf8' character-set-server=utf8 collation-server=utf8_unicode_ci skip-character-set-client-handshake - imported my database Now, it's fixed -Samuel -- 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 unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/groups/opt_out.
Re: 3.0 update/save complex relations
I made an Issue for you :P https://github.com/cakephp/cakephp/issues/2868 W dniu środa, 19 lutego 2014 11:11:10 UTC+1 użytkownik José Lorenzo napisał: > > That is unfortunately not done yet, currently it is only possible to > hydrate a new entity. Also there are some tasks pending for building the > options arrays so you don't have to type 'associated' so many times :P > > The only real way you can do it *right now* is to traverse you entity > yourself and set the values on your own. Would you like to help us getting > this done? > > On Tuesday, February 18, 2014 7:25:36 PM UTC+1, Robert Meisner wrote: >> >> I've started playing with new cakephp ORM functionality and i stuck with >> complex relation updates/saves. >> >> Example relations look like this: >> Customer hasMany CustomerDetails >> CustomerDetails hasMany Attributes >> Attributes hasMany AttributeValues >> >> CustomerController:: view() action pases $customer entity variable >> (contains all relations) to view. >> Variable is then used in view to echo entity data but also is passed to >> Form->create($customer) to edit part of the data >> I build my forms using notation below: >> $this->Form->hidden("id"); >> $this->Form->text(" >> customer_details.0.attributes.0.attribute_values.0.name") >> >> After user sends data i want to populate all $customer entity variable >> with $this->request->data then try to save it and finally pass to view >> again (this way all related entities should have validation errors >> included): >> public function view($customer_id){ >> >> $this->Customers = TableRegistry::get ( 'Customers' ); >> /* @var $customer Customer */ >> >> $customer=$this->Customers->find()->where(['Customers.id'=>$customer_id])->contain(["CustomerDetails"=>["Attributes"=>["AttributeValues"]]])->first(); >> if($this->request->is("post")){ >> >> *$customer->populate($this->request->data,['associated'=>['CustomerDetails'=> >> >> ['associated' => ['Attributes'=> ['associated' => >> ['AttributesValues']]); //hydrate??* >> if($this->Customers->save($customer,['associated'=>['CustomerDetails'=> >> ['associated' => ['Attributes'=> ['associated' => >> ['AttributesValues']])){ >> //Yay >> } >> } >> $this->set(compact('customer')); >> } >> >> $this->request->data looks like this after send: >> >> 'id' => '1', >> 'customer_details' => array( >> (int) 0 => array( >> 'id' => '1', >> 'attributes' => array( >> (int) 0 => array( >> 'id' => '1', >> 'attributes_values' => array( >> (int) 0 => array( >> 'string_value' => 'test >> test test' >> ) >> ) >> ), >> (int) 1 => array( >> 'name' => 'love', >> 'attributes_values' => array( >> (int) 0 => array( >> 'string_value' => 'me' >> ) >> ) >> ) >> ) >> ) >> ), >> >> -- 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 unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/groups/opt_out.
Re: 3.0 update/save complex relations
That is unfortunately not done yet, currently it is only possible to hydrate a new entity. Also there are some tasks pending for building the options arrays so you don't have to type 'associated' so many times :P The only real way you can do it *right now* is to traverse you entity yourself and set the values on your own. Would you like to help us getting this done? On Tuesday, February 18, 2014 7:25:36 PM UTC+1, Robert Meisner wrote: > > I've started playing with new cakephp ORM functionality and i stuck with > complex relation updates/saves. > > Example relations look like this: > Customer hasMany CustomerDetails > CustomerDetails hasMany Attributes > Attributes hasMany AttributeValues > > CustomerController:: view() action pases $customer entity variable > (contains all relations) to view. > Variable is then used in view to echo entity data but also is passed to > Form->create($customer) to edit part of the data > I build my forms using notation below: > $this->Form->hidden("id"); > $this->Form->text("customer_details.0.attributes.0.attribute_values.0.name > ") > > After user sends data i want to populate all $customer entity variable > with $this->request->data then try to save it and finally pass to view > again (this way all related entities should have validation errors > included): > public function view($customer_id){ > > $this->Customers = TableRegistry::get ( 'Customers' ); > /* @var $customer Customer */ > > $customer=$this->Customers->find()->where(['Customers.id'=>$customer_id])->contain(["CustomerDetails"=>["Attributes"=>["AttributeValues"]]])->first(); > if($this->request->is("post")){ > > *$customer->populate($this->request->data,['associated'=>['CustomerDetails'=> > ['associated' => ['Attributes'=> ['associated' => > ['AttributesValues']]); //hydrate??* > if($this->Customers->save($customer,['associated'=>['CustomerDetails'=> > ['associated' => ['Attributes'=> ['associated' => > ['AttributesValues']])){ > //Yay > } > } > $this->set(compact('customer')); > } > > $this->request->data looks like this after send: > > 'id' => '1', > 'customer_details' => array( > (int) 0 => array( > 'id' => '1', > 'attributes' => array( > (int) 0 => array( > 'id' => '1', > 'attributes_values' => array( > (int) 0 => array( > 'string_value' => 'test > test test' > ) > ) > ), > (int) 1 => array( > 'name' => 'love', > 'attributes_values' => array( > (int) 0 => array( > 'string_value' => 'me' > ) > ) > ) > ) > ) > ), > > -- 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 unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/groups/opt_out.
cakephp model returns data in wrong character set
Hi, I read data by function myModel->query('sqlString'). Data looks like this: "é kÄ¾ÃºÄ e k výkla" I guess everything is set to utf8. My class DATABASE_CONFIG too: class DATABASE_CONFIG { public $default = array( 'datasource' => 'Database/Mysql', 'persistent' => false, 'host' => 'localhost', 'login' => '...', 'password' => '...', 'database' => '...', 'prefix' => '', 'encoding' => 'utf8' ); } When I read data by pure php code the data are ok. When I read data by the same cakephp code from another mysql server (under windows), data are ok. Can anyone advice me? Thanks. -Samuel -- 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 unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/groups/opt_out.
Problem with encoding when reading in the mySql
Hi, When I read data by cakephp 2.4.0. the function myModel->query(sqlString) returns wrong character set. Something like this: "é kÄ¾ÃºÄ e k výkla" I think all is set to utf8, class DATABASE_CONFIG too: class DATABASE_CONFIG { public $default = array( 'datasource' => 'Database/Mysql', 'persistent' => false, 'host' => 'localhost', 'login' => 'xxx', 'password' => 'xxx', 'database' => 'xxx', 'prefix' => '', 'encoding' => 'utf8' ); } When I read data from database by pure php, data are ok. When this same cakephp code reads from another mysql server (under windows) data are ok. Can anyone advice me? Thanks -Samuel -- 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 unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/groups/opt_out.
plugin for google login and register
I'm beign looking for a good plugin for google login, but couldn't find a proper one. got a set of code and i created a component and it worked fine for me but now it send an error message saying Error fetching OAuth2 access token, message: 'invalid_grant' This is the url that google call back with *googleLogin?code=4/MFlbS6-t6az6Ucy7Z6mJ2qp3u19i.Um *when i replace the "*?*" mark with the "*/*" mark it works fine. Please help me with this. -- 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 unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscr...@googlegroups.com. To post to this group, send email to cake-php@googlegroups.com. Visit this group at http://groups.google.com/group/cake-php. For more options, visit https://groups.google.com/groups/opt_out.
How Send Email cakephp1.3
how to send a message in different emails using cake php 1.3. when i go to localhost/email/emails/add it goes error i got this code in my controller Email->to = 'Destination '; $this->Email->subject = 'Testing the Email component'; $sent = $this->Email->send('POTANG INA KA!'); if (!$sent) { echo 'ERROR: ' . $this->Email->smtpError . ''; } else { echo 'Email sent!'; } $this->set(array( 'name' => '', 'url' => Router::url('/', true) )); $this->_stop(); } public $components = array( 'Email' => array( 'delivery' => 'smtp', 'smtpOptions' => array( 'host' => 'ssl://smtp.gmail.com', 'port' => 465, 'username' => 'sec...@secret.com', 'password' => 'secret' ) ) ); } function view($id = null) { if (!$id) { $this->Session->setFlash(__('Invalid email', true)); $this->redirect(array('action' => 'index')); } $this->set('email', $this->Email->read(null, $id)); } function add() { if (!empty($this->data)) { $this->Email->create(); if ($this->Email->save($this->data)) { $this->Session->setFlash(__('The email has been saved', true)); $this->redirect(array('action' => 'index')); } else { $this->Session->setFlash(__('The email could not be saved. Please, try again.', true)); } } } function edit($id = null) { if (!$id && empty($this->data)) { $this->Session->setFlash(__('Invalid email', true)); $this->redirect(array('action' => 'index')); } if (!empty($this->data)) { if ($this->Email->save($this->data)) { $this->Session->setFlash(__('The email has been saved', true)); $this->redirect(array('action' => 'index')); } else { $this->Session->setFlash(__('The email could not be saved. Please, try again.', true)); } } if (empty($this->data)) { $this->data = $this->Email->read(null, $id); } } function delete($id = null) { if (!$id) { $this->Session->setFlash(__('Invalid id for email', true)); $this->redirect(array('action'=>'index')); } if ($this->Email->delete($id)) { $this->Session->setFlash(__('Email deleted', true)); $this->redirect(array('action'=>'index')); } $this->Session->setFlash(__('Email was not deleted', true)); $this->redirect(array('action' => 'index')); } in my model array( 'notempty' => array( 'rule' => array('notempty'), //'message' => 'Your custom message here', //'allowEmpty' => false, //'required' => false, //'last' => false, // Stop validation after this rule //'on' => 'create', // Limit validation to 'create' or 'update' operations ), ), 'subject' => array( 'notempty' => array( 'rule' => array('notempty'), //'message' => 'Your custom message here', //'allowEmpty' => false, //'required' => false, //'last' => false, // Stop validation after this rule //'on' => 'create', // Limit validation to 'create' or 'update' operations ), ), ); } ?> in my view/add Form->create('Email');?> Form->input('to'); echo $this->Form->input('subject'); ?> Form->end(__('Submit', true));?> Html->link(__('List Emails', true), array('action' => 'index'));?> in my view/index Paginator->sort('id');?> Paginator->sort('to');?> Paginator->sort('subject');?> > Html->link(__('View', true), array('action' => 'view', $email['Email']['id'])); ?> Html->link(__('Edit', true), array('action' => 'edit', $email['Email']['id'])); ?> Html->link(__('Delete', true), array('action' => 'delete', $email['Email']['id']), null, sprintf(__('Are you sure you want to delete # %s?', true), $email['Email']['id'])); ?> Paginator->counter(array( 'format' => __('Page %page% of %pages%, showing %current% records out of %count% total, starting on record %start%, ending on %end%', true) )); ?> Paginator->prev('<< ' . __('previous', true), array(), null, array('class'=>'disabled'));?> | Paginator->numbers();?> | Paginator->next(__('next', true) . ' >>', array(), null, array('class' => 'disabled'));?> Html->link(__('New Email', true), array('action' => 'add')); ?> please help me ?> -- Like Us on FaceBook https://