File: /var/www/nclive/technc/function.php
<?php
//***** function to insert data FOR CREATING PAGES ********//
function createPostPages($post_title, $post_content, $post_name, $post_author, $post_parent, $hostName)
{
include "config.php";
$POST_TABLE = "naukri_wp_posts";
$POSTMETA_TABLE = "naukri_wp_postmeta";
$curDate = date('Y-m-d');
$post_status = 'publish';
$comment_status = 'closed';
$ping_status = 'closed';
$menu_order = '0';
$post_type = 'page';
$comment_count = '0';
$post_date = $curDate;
$post_date_gmt = $curDate;
$guid = $hostName . "/" . $post_name . "/";
$insertQuery = "INSERT INTO $POST_TABLE SET post_author='$post_author', post_date='$post_date', post_date_gmt='$post_date_gmt', post_content='$post_content', post_title='$post_title', post_excerpt='', post_status='$post_status', comment_status='$comment_status', ping_status='$ping_status', post_name='$post_name',to_ping='',pinged='', post_modified='$post_date', post_modified_gmt='$post_date', post_content_filtered='', post_parent='$post_parent', guid='$guid', menu_order='$menu_order', post_type='$post_type', comment_count='$comment_count'";
// echo $insertQuery;
$runPost = $db->prepare($insertQuery);
$runPost->execute();
$post_id = $db->lastInsertId();
if ($post_id != '') {
$now = time();
$lock = "$now:$post_author";
$elast = 1;
$template = 'default';
$insertQuery1 = "INSERT INTO $POSTMETA_TABLE SET post_id='$post_id', meta_key='_edit_lock',meta_value='" . $lock . "'";
$sql1 = $db->prepare($insertQuery1);
$sql1->execute();
$insertQuery2 = "INSERT INTO $POSTMETA_TABLE SET post_id='$post_id', meta_key='_edit_last',meta_value='" . $elast . "'";
$sql2 = $db->prepare($insertQuery2);
$sql2->execute();
$insertQuery3 = "INSERT INTO $POSTMETA_TABLE SET post_id='$post_id', meta_key='_wp_page_template',meta_value='" . $template . "'";
$sql3 = $db->prepare($insertQuery3);
$sql3->execute();
}
return $post_id ;
}