Posted by nhocmuonlanhoc on November 15, 2010 at 6:33am
mình gặp vấn đề với việc insert node to database
function create_node()
{
//body content
$body_text ='body here';
///////////////////////////////////////////
$node = new stdClass();
//setup default value for the node
$node->type ='page';
node_object_prepare($node);
$node->title = ' Page tested create';
$node->language = LANGUAGE_NONE;
$node->body[$node->language][0]['value'] = $body_text;
$node->body[$node->language][0]['format'] = 'php_code';
node_save($node);
//menu for page
$menu = array();
$menu['link_title']='tested page';
$menu['menu_name'] ='main-menu';
$menu['link_path']= 'node/'.$node->nid;
$menu['router_path']='node/%';
menu_link_save($menu);
//save node id
variable_set('tested',$node->nid);
}//function create_nodethì có thể sử dụng save node để ghi vào database
nhưng khi phần body_text =' các đọan code htlm , và php , javascript phức tạp' ;
thì lại không thể thực hiện đụơc
server trả về lỗi : PDOException: in field_sql_storage_field_storage_write()
bro nào có thể nêu nguyên nhân và cách khắc phục giúp mình đuợc không ?
cảm ơn
Comments
http://www.rtraction.com/blog
http://www.rtraction.com/blog/devit/drupal-import-data-into-nodes-and-co... bạn thử cách này xem?
Hic
Đang định ngâm cứu về drupal mà thấy...@@
à à sao không lập website riêng nhở.
Mình có khả năng lập forum+ tự lo hosting được, nếu anh em ok thì bắt tay làm ngay
Bạn sửa lại cái này: $node
Bạn sửa lại cái này:
$node ->format = 1 // neu la filter html thay doi 1 thanh 2, 3 cho phu hop voi id input format cua ban.
Tel: 0905 403 723
$node->body[$node->language][
$node->body[$node->language][0]['value'] thành $node->$body = $body_text;
stdClass Object
(
[nid] => 1
[type] => video
[language] =>
[uid] => 1
[status] => 1
[created] => 1288333474
[changed] => 1288832487
[comment] => 2
[promote] => 1
[moderate] => 0
[sticky] => 0
[tnid] => 0
[translate] => 0
[vid] => 1
[revision_uid] => 1
[title] => The FourSpots Creative Exchange
[body] => The FourSpots Creative Exchange
[teaser] => The FourSpots Creative Exchange
[log] =>
[revision_timestamp] => 1288832487
[format] => 1
[name] => admin
[picture] =>
[data] => a:1:{s:13:"form_build_id";s:37:"form-ff6ed3b0af37339d3d27cbe4525db25e";}
[field_video_file] => Array
(
[0] => Array
(
[fid] => 1
[list] => 1
[data] => Array
(
[dimensions] => 320x240
[player_dimensions] => 640x350
)
)
Tel: 0905 403 723
sửa lại : $node->body
sửa lại : $node->body
Tel: 0905 403 723