Example #1
0
function qdb()
{
    $args = func_get_args();
    if (count($args) < 1) {
        throw new InvalidArgumentException("qdb needs at least 1 argument");
    }
    $stmt = prep_stmt($args[0]);
    $stmt->execute(array_slice($args, 1));
    return $stmt;
}
Example #2
0
 public function set_tags($tags)
 {
     $tx = new Transaction();
     try {
         foreach ($tags as $tag) {
             $tag->save();
         }
         qdb("DELETE FROM `PREFIX_article_tag_relations` WHERE `article`= ?", $this->id);
         $articleid = $this->id;
         if (!empty($tags)) {
             $stmt = prep_stmt("INSERT INTO `PREFIX_article_tag_relations` (`article`, `tag`) VALUES " . implode(",", array_fill(0, count($tags), "(?,?)")));
             $args = array();
             foreach ($tags as $tag) {
                 $args[] = $articleid;
                 $args[] = $tag->get_id();
             }
             $stmt->execute($args);
         }
         $tx->commit();
     } catch (Exception $e) {
         $tx->rollback();
         throw $e;
     }
 }