Ejemplo n.º 1
0
 /**
  * select object set.
  * @return instance of SET_CLASS.
  */
 protected static function selectSet($query, $bind = array(), $con = null)
 {
     $table = static::TABLE_NAME;
     $sql = "SELECT * FROM `{$table}` {$query}";
     $rows = mfwDBIBase::getAll($sql, $bind, $con);
     $class = static::SET_CLASS;
     return new $class($rows);
 }
Ejemplo n.º 2
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;
 }
Ejemplo n.º 3
0
 public static function selectCountsByAppIds(array $app_ids)
 {
     if (empty($app_ids)) {
         return array();
     }
     $bind = array();
     $pf = static::makeInPlaceholder($app_ids, $bind);
     $table = static::TABLE_NAME;
     $sql = "SELECT app_id,count(*) FROM {$table} WHERE app_id IN ({$pf}) GROUP BY app_id";
     $rows = mfwDBIBase::getAll($sql, $bind);
     $counts = array();
     foreach ($rows as $r) {
         $counts[$r['app_id']] = $r['count(*)'];
     }
     return $counts;
 }
Ejemplo n.º 4
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));
 }
Ejemplo n.º 5
0
 public static function selectByPackageId($pakcage_id)
 {
     $sql = 'SELECT t.* FROM package_tag j LEFT JOIN tag t ON j.tag_id = t.id WHERE package_id = ?';
     $rows = mfwDBIBase::getAll($sql, array($pakcage_id));
     return new TagSet($rows);
 }