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