示例#1
0
 static function getInstance()
 {
     if (self::$instance == NULL) {
         self::$instance = new model_db();
     }
     return self::$instance;
 }
示例#2
0
 static function getTags($modelId, $entityId)
 {
     $db = model_db::getInstance();
     $sql = "select tag.`value` from tags b join tag on tag.id=b.tagid where b.model=? and b.id = ?";
     $stmt = $db->prepare($sql);
     $stmt->execute(array($modelId, $entityId));
     return $stmt->fetchAll(PDO::FETCH_COLUMN, 0);
 }
示例#3
0
 static function getInstance()
 {
     if (self::$instance == NULL) {
         self::$instance = new model_db();
         $s = self::$instance->prepare('set names utf8');
         $s->execute();
     }
     return self::$instance;
 }
示例#4
0
 public function delete($params)
 {
     $db = model_db::getInstance();
     $sqlDelete = sprintf("delete from %scomment where id = ?", $this->parentModel);
     $stmtDelete = $db->prepare($sqlDelete);
     if (is_array($params)) {
         foreach ($params as $id) {
             $stmtInsert->execute(array($id));
         }
     } else {
         $stmtInsert->execute(array($params));
     }
 }
示例#5
0
 public function getGroups($userid)
 {
     $args = array($userid);
     $db = model_db::getInstance();
     $sql = "select `groups`.groupid from `groups` where group.userid = ?";
     $stmt = $db->prepare($sql);
     $stmt->execute($args);
     $stmt->setFetchMode(PDO::FETCH_NAMED);
     $groups = $stmt->fetchAll();
     $groups_short = array();
     foreach ($groups as $g) {
         $groups_short[] = $g['groupid'];
     }
     return $groups_short;
 }
示例#6
0
 public function update($values)
 {
     $db = model_db::getInstance();
     $sqlUpdateA = "update user set name=?, email=? where id=?;";
     $sqlUpdateB = "update user set name=?, email=?, password=? where id=?;";
     $stmtInsert = $db->prepare(count($values) > 3 ? $sqlUpdateB : $sqlUpdateA);
     $stmtInsert->execute($values);
 }