I create a Drupal module which install database tables during module installation, table is created using Drupal way. The tables are created perfectly and now i have to insert data into those tables.
Example table structure where i want data to be inserted in sequence :
- Node (insert product name)
- myproduct_category (take the inserted node id and save the product category and nid at the same time in this table)
- myproduct_price (take the inserted node id and save the product price and nid at the same time in this table)
Once data are inserted into database, the site admin will retrieve those saved data and show it in front-end.
here's my current code to insert data into node, i just can't get the last inserted id and continue insert data into other tables :
$node = new stdClass();
$node->title = $val['ADDRESS_1'];
$node->type = 'basil_veco';
node_object_prepare($node);
$node->language = LANGUAGE_NONE;
$node->uid = $user->uid;
$node->status = 1;
$node->promote = 0;
$node->comment = 0;
$node->created = timestamp;
$node = node_submit($node); // Prepare node for saving
node_save($node);
Please tell me the way to go about if my approach is not the right way.
Thank you.