Exemplo n.º 1
0
 public static function getInstallPackageIds(User $user, $app_id)
 {
     $sql = 'SELECT distinct(package_id) as pkg_id FROM install_log WHERE mail=:mail AND app_id=:app_id';
     $bind = array(':mail' => $user->getMail(), ':app_id' => $app_id);
     $rows = mfwDBIBase::getAll($sql, $bind);
     $ids = array();
     foreach ($rows as $r) {
         $ids[] = $r['pkg_id'];
     }
     return $ids;
 }
Exemplo n.º 2
0
 public static function updateCursor($repo_id, $cursor, $con = null)
 {
     $cursor_table = 'repository_cursor';
     $sql = "SELECT * FROM {$cursor_table} WHERE repo_id=?";
     $row = mfwDBIBase::getRow($sql, array($repo_id), $con);
     if (empty($row)) {
         $sql = "INSERT INTO {$cursor_table} (repo_id,number) VALUES (:repo_id,:number) ON DUPLICATE KEY UPDATE number=:number";
     } else {
         $sql = "UPDATE {$cursor_table} SET number=:number WHERE repo_id=:repo_id";
     }
     $bind = array(':repo_id' => $repo_id, ':number' => $cursor);
     return mfwDBIBase::query($sql, $bind, $con);
 }
Exemplo n.º 3
0
 public static function post(User $user, Application $app, $package_id, $message)
 {
     $sql = 'SELECT number FROM comment WHERE app_id=?ORDER BY id DESC LIMIT 1';
     $max_num = (int) mfwDBIBase::getOne($sql, array($app->getId()));
     $row = array('app_id' => $app->getId(), 'package_id' => $package_id ?: null, 'number' => $max_num + 1, 'mail' => $user->getMail(), 'message' => $message, 'created' => date('Y-m-d H:i:s'));
     $comment = new Comment($row);
     $comment->insert();
     return $comment;
 }
Exemplo n.º 4
0
 public function delete()
 {
     $sql = 'DELETE FROM app_install_user WHERE app_id = :app_id AND mail = :mail';
     $bind = array(':app_id' => $this->getAppId(), ':mail' => $this->getMail());
     return mfwDBIBase::query($sql, $bind, $con);
 }
Exemplo n.º 5
0
 public static function selectCount()
 {
     $table = static::TABLE_NAME;
     $sql = "SELECT count(*) FROM `{$table}`";
     return mfwDBIBase::getOne($sql);
 }
Exemplo n.º 6
0
 public static function addOwner($app_id, $owners, $con = null)
 {
     $bind = array(':app_id' => $app_id);
     $values = array();
     foreach ($owners as $k => $v) {
         $key = ":mail_{$k}";
         $values[] = "(:app_id,{$key})";
         $bind[$key] = $v;
     }
     $sql = 'INSERT INTO application_owner (app_id,owner_mail) VALUES ' . implode(',', $values);
     return mfwDBIBase::query($sql, $bind, $con);
 }
Exemplo n.º 7
0
 public static function selectByAppIdPfTagsWithLimit($app_id, $pf_filter, array $tags, $offset, $count)
 {
     if (!$pf_filter && empty($tags)) {
         $query = 'WHERE app_id = :app_id';
         $query .= sprintf(' ORDER BY id DESC LIMIT %d, %d', $offset, $count);
         return static::selectSet($query, array(':app_id' => $app_id));
     }
     $sql = 'SELECT p.* FROM package AS p LEFT JOIN package_tag AS t ON p.id = t.package_id WHERE p.app_id = :app_id';
     $bind = array(':app_id' => $app_id);
     if ($pf_filter) {
         $sql .= ' AND p.platform = :platform';
         $bind[':platform'] = $pf_filter;
     }
     if (!empty($tags)) {
         $ph = static::makeInPlaceHolder($tags, $bind, 'tag');
         $c = count($tags);
         $sql .= " AND t.tag_id in ({$ph}) GROUP BY p.id HAVING COUNT(p.id) = {$c}";
     }
     $sql .= sprintf(' ORDER BY p.id DESC LIMIT %d, %d', $offset, $count);
     return new PackageSet(mfwDBIBase::getAll($sql, $bind));
 }
Exemplo n.º 8
0
 public static function removeFromPackage(Package $pkg, $con = null)
 {
     $sql = 'DELETE FROM package_tag WHERE package_id = ?';
     mfwDBIBase::query($sql, array($pkg->getId()), $con);
 }
Exemplo n.º 9
0
 /**
  * オブジェクトのレコードを削除.
  */
 public static function delete(mfwObject $obj, $con = null)
 {
     $table = static::TABLE_NAME;
     $sql = "DELETE FROM `{$table}` WHERE `id` = ?";
     return mfwDBIBase::query($sql, array($obj->getId()), $con);
 }
Exemplo n.º 10
0
 public static function totalCountForRepository(Repository $repo)
 {
     $sql = 'SELECT count(*) FROM pull_request WHERE repo_id=?';
     return mfwDBIBase::getOne($sql, array($repo->getId()));
 }