Re: Saving Whole array to database

2010-12-06 Thread Miles J
There are two ways (assuming this is within a loop).

$this->SavedNews->save(array('title' => $title, 'description' =>
$desc), false);

Or you can save the whole array.

$this->SavedNews->save($data, false, array('title', 'description'));

On Dec 6, 11:53 am, NB  wrote:
> 'm out of ideas here is my controller:
>
>     class GoogleNewsController extends AppController {
>         var $name = 'GoogleNews';
>         var $uses = array('GoogleNews', 'SavedNews');
>         var $helpers = array('Html','Form');
>         function index() {
>
>     $saved = $this->set('news',$this->GoogleNews->find('all'));
> Im reading data from 'GoogleNews' and they are in my array. Array
> looks like this:
>
>       array(10) {
>       [0]=>
>       array(1) {
>         ["GoogleNews"]=>
>         array(12) {
>           ["title"]=>
>           string(32) "FIFA 11 für 25,49€ aus Jersey"
>           ["link"]=>
>           string(54) "http://feedproxy.google.com/~r/myDealZ/~3/
> HuNxRhQJraQ/"
>           ["pubDate"]=>
>           string(31) "Mon, 06 Dec 2010 10:53:22 +"
>           ["creator"]=>
>           string(5) "admin"
>           ["guid"]=>
>           array(2) {
>             ["value"]=>
>         string(30) "http://www.mydealz.de/?p=15137";
>         ["isPermaLink"]=>
>         string(5) "false"
>       }
>       ["description"]=>
>       string(355) "
> And I want to save elements to my database 'SavedNews'
>
> I need to save description and title.
>
> Can anybody tell me how should I write it?
>
>      $this->SavedNews->set(array('description' =>$this->GoogleNews-
>
> >find('description')));

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


Saving Whole array to database

2010-12-06 Thread NOOOOB
'm out of ideas here is my controller:



class GoogleNewsController extends AppController {
var $name = 'GoogleNews';
var $uses = array('GoogleNews', 'SavedNews');
var $helpers = array('Html','Form');
function index() {

$saved = $this->set('news',$this->GoogleNews->find('all'));
Im reading data from 'GoogleNews' and they are in my array. Array
looks like this:



  array(10) {
  [0]=>
  array(1) {
["GoogleNews"]=>
array(12) {
  ["title"]=>
  string(32) "FIFA 11 für 25,49€ aus Jersey"
  ["link"]=>
  string(54) "http://feedproxy.google.com/~r/myDealZ/~3/
HuNxRhQJraQ/"
  ["pubDate"]=>
  string(31) "Mon, 06 Dec 2010 10:53:22 +"
  ["creator"]=>
  string(5) "admin"
  ["guid"]=>
  array(2) {
["value"]=>
string(30) "http://www.mydealz.de/?p=15137";
["isPermaLink"]=>
string(5) "false"
  }
  ["description"]=>
  string(355) "
And I want to save elements to my database 'SavedNews'

I need to save description and title.

Can anybody tell me how should I write it?



 $this->SavedNews->set(array('description' =>$this->GoogleNews-
>find('description')));

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