/** * Create a post using the given information * * @param string $title * @param string $slug * @param int $time * @param bool $status * @param bool $Locked * @param int $poster_id * @param string $content * @param string $bbcode_uid * @param string $bbcode_bitfield * @param array $categories Array of category IDs * @param array $tags Array of tag IDs * @return bool */ public function create($title, $slug, $time, $status, $locked, $poster_id, $content, $bbcode_uid, $bbcode_bitfield, array $categories, array $tags) { $sql = 'INSERT INTO ' . $this->blog_posts_table . ' ' . $this->db->sql_build_array('INSERT', array('title' => $title, 'slug' => $slug, 'time' => (int) $time, 'status' => (bool) $status, 'locked' => (bool) $locked, 'poster_id' => (int) $poster_id, 'content' => $content, 'bbcode_uid' => $bbcode_uid, 'bbcode_bitfield' => $bbcode_bitfield)); $this->db->sql_query($sql); $post_id = (int) $this->db->sql_next_id(); foreach ($categories as $category_id) { $sql = 'INSERT INTO ' . $this->blog_post_categories_table . ' ' . $this->db->sql_build_array('INSERT', array('post_id' => (int) $post_id, 'category_id' => (int) $category_id)); $this->db->sql_query($sql); $sql = 'UPDATE ' . $this->blog_categories_table . ' SET post_count = post_count + 1 WHERE id = ' . (int) $category_id; $this->db->sql_query($sql); } foreach ($tags as $tag_id) { $sql = 'INSERT INTO ' . $this->blog_post_tags_table . ' ' . $this->db->sql_build_array('INSERT', array('post_id' => (int) $post_id, 'tag_id' => (int) $tag_id)); $this->db->sql_query($sql); } return true; }