node_save: The way to save node to your Drupal Code without running into INSERT query?
I was trying to create a new node programatically by inserting information in node, node_revision tables and using "sequences" table to figure out what is the latest nid and vid. But, for some reason it was failing and then I found the saviour, "node_save", the easy one.
The following code saves your node without any bug, error or tension:
| $edit = array(); $edit['type'] = 'daylife'; // get the node type defaults $edit['uid'] = 1; $edit['name'] = 'bollywood'; $edit['promote'] = 0; $edit['comment'] = 0; //$edit['revision'] = ; //$edit['format'] = FILTER_FORMAT_DEFAULT; $edit['status'] = 1; $edit['title'] = $article['headline']; $edit['date'] = format_date(time(), 'custom', 'Y-m-d H:i:s O'); node_invoke_nodeapi($edit, 'daylife'); node_validate($edit); $node = node_submit($edit); |

Recent comments
22 weeks 4 days ago
23 weeks 1 day ago
23 weeks 1 day ago
23 weeks 3 days ago
24 weeks 1 day ago
26 weeks 2 days ago
29 weeks 2 days ago
32 weeks 1 day ago
32 weeks 6 days ago
33 weeks 4 days ago