2
我的想法,這裏是我的控制器:從「了Googlenews」數組保存到數據庫中的CakePHP
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'));
即時閱讀數據和他們在我的數組。數組是這樣的:
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 +0000"
["creator"]=>
string(5) "admin"
["guid"]=>
array(2) {
["value"]=>
string(30) "http://www.mydealz.de/?p=15137"
["isPermaLink"]=>
string(5) "false"
}
["description"]=>
string(355) "
我想保存元素,我的數據庫「SavedNews」 我需要保存的說明和標題。 有人可以告訴我該怎麼寫嗎?
$this->SavedNews->set(array('description' =>$this->GoogleNews->find('description')));
這是一個解決方案嗎? 它的工作原理是唯一的方式,但它將空值添加到我的列中。
非常感謝,現在我明白了,這非常有幫助 – Jasiufila 2010-12-07 08:03:45