function create_post($authorname = '') { global $db, $tprefix, $tld, $install_folder; $today = date('Y-m-d H:m:s'); //========================================== //create entry in meta table $new_meta_id = get_new_meta_id(); echo 'new meta_id = ' . $new_meta_id . '<br>'; $meta_sql = "INSERT INTO `{$tprefix}" . "_meta` (`meta_id`,`path`,`meta_canonical`,`type`) VALUES ('{$new_meta_id}','{$tld}','checked','post')"; echo $meta_sql . '<br>'; //create entry in content table $new_post_id = get_latest_post_id(); echo 'new post_id = ' . $new_post_id . '<br>'; $content_sql = "INSERT INTO `{$tprefix}" . "_content` (`id`,`meta_id`,`date_posted`,`published`,`author`,`title`) \n\t\tVALUES ('{$new_post_id}', '{$new_meta_id}','{$today}' ,'N','{$authorname}','YOUR TITLE HERE')"; echo $content_sql . '<br>'; $db->query($meta_sql) or die('query failed'); $db->query($content_sql) or die('query failed'); //create entry in cat_post table //get the uncategorized cat_id $sql = "select `cat_id` from `{$tprefix}" . "_category` where `cat_label` = 'uncategorized'"; $result = $db->query($sql); $row = $result->fetch_assoc(); if (empty($row['cat_id'])) { echo 'uncategorized not available'; exit; } else { $cat_id = $row['cat_id']; } //create cat_post association $cat_post_sql = "insert into `{$tprefix}" . "_cat_post` (`cat_id`,`post_id`) VALUES ('" . $row['cat_id'] . "','" . $new_post_id . "')"; echo $cat_post_sql; $db->query($cat_post_sql); //========================================== return $new_post_id; }
/** * add brand new tags to tags table and meta table * @param [type] $tags_to_add [description] */ function add_cms_tags($tags_to_add) { global $tprefix, $db, $tld2; for ($i = 0; $i < count($tags_to_add); $i++) { $meta_id = get_new_meta_id(); //insert the meta if only it is not already present //// use $db->insert_id?? $entry = $tld2 . "/tag/" . $tags_to_add[$i] . "/"; echo '<br>entry = ' . $entry; $entry_exists = check_meta_entry($entry); if ($entry_exists === FALSE) { $sql1 = "insert into `{$tprefix}" . "_meta` (`meta_id`,`query_string`,`path`,`type`,`meta_canonical`) values ('{$meta_id}','/tag/" . $tags_to_add[$i] . "/','" . $tld2 . "/tag/" . $tags_to_add[$i] . "/','tag','checked') "; //echo '<br>4.0'.$sql1 ; $db->query($sql1); $sql2 = "insert into `{$tprefix}" . "_tags` (`meta_id`,`tag_label`) values ('{$meta_id}','" . $tags_to_add[$i] . "')"; //echo '<br>4.1'.$sql2 ; $db->query($sql2); } } }