node_save

Events happening in the community are now at Drupal community events on www.drupal.org.
nhocmuonlanhoc's picture

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_node

thì 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

Hic

kuydoha's picture

Đ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

itqn2004's picture

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][

itqn2004's picture

$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
)

                [uid] => 1
                [filename] => 375121181068.mov_.flv
                [filepath] => sites/default/files/videos/375121181068.mov_.flv
                [filemime] => video/x-flv
                [filesize] => 42947155
                [status] => 1
                [timestamp] => 1288333461
            )

    )

[last_comment_timestamp] => 1288333474
[last_comment_name] => 
[comment_count] => 0
[taxonomy] => Array
    (
        [1] => stdClass Object
            (
                [tid] => 1
                [vid] => 1
                [name] => FourSpots
                [description] => FourSpots
                [weight] => 0
            )

    )

)


Tel: 0905 403 723


sửa lại : $node->body

itqn2004's picture

sửa lại : $node->body


Tel: 0905 403 723