Pastebin

Paste #234:

< previous paste - next paste>

Pasted by tdn

Download View as text

/* Insert a new article with tags*/
function store_new_article($body, $title, $visibility, $tags) {
	begin();
	$q = prepare_statement("INSERT INTO article (body, title, visibility) 
VALUES(%s, %s, %s)", $body, $title, $visibility);
  exec_statement($q);
	$q = prepare_statement("SELECT CURRVAL('article_article_id_seq')");
	$article_id = pg_fetch_array(exec_statement($q));
	$article_id = $article_id[0];

  /* Insert an article tag */
	foreach ($tags as $tag) {
	$q = prepare_statement("INSERT INTO article_tag (name, article_id)
VALUES (%s, %s)", $tag, $article_id);
  exec_statement($q);
	}

	commit();
}

New Paste


Do not write anything in this field if you're a human.

Go to most recent paste.