コード例 #1
0
 /**
  * @param int[] $uids
  *
  * @return array
  */
 public function findRankingPointsByIds(array $uids)
 {
     $uids = array_map('intval', $uids);
     $sql = 'SELECT rua.uid, SUM(rua.user_points) ranking FROM ranking_user_achievements rua WHERE rua.uid IN (:UIDS) GROUP BY rua.uid';
     $query = $this->mysql->query($sql)->bindIntArray('UIDS', $uids);
     // $sql = $query->getSQL(); // for debugging
     $result = $query->fetchAll();
     return $result;
 }
コード例 #2
0
 /**
  * @param $userIdentifier
  * @return int
  */
 public function removeUserByUserIdentifier($userIdentifier)
 {
     list($userId, $userSubId) = explode(':', $userIdentifier, 2);
     $this->clearUserCache($userIdentifier);
     $query = $this->mysqlWrite->query('DELETE FROM contentpartner_externaluser WHERE contentPartnerId = :CONTENT_PARTNER_ID AND externalUserId = :EXTERNAL_USER_ID')->bindInt('CONTENT_PARTNER_ID', $userId)->bindInt('EXTERNAL_USER_ID', $userSubId);
     return $query->delete();
 }
コード例 #3
0
    /**
     * @param array $uids
     * @param int   $minFsk
     * @param int   $maxFsk
     * @param bool  $higherFskFirst
     *
     * @return array
     */
    public function findHostsStaticPictureModelByIds(array $uids, $minFsk = 12, $maxFsk = 18, $higherFskFirst = true)
    {
        $sql = '
		SELECT uid, pictureStr FROM (
			SELECT
				uid,
				COALESCE(' . $this->getFieldsByAge($minFsk, $maxFsk, $higherFskFirst) . ') as pictureStr
			FROM hosts_archive a
			WHERE uid IN (:UIDS)
		) t1
		WHERE pictureStr != ""
		';
        $query = $this->mysql->query($sql)->bindIntArray('UIDS', $uids);
        /** @noinspection PhpUnusedLocalVariableInspection */
        $sql = $query->getSQL();
        // for debugging
        $result = $query->fetchAll();
        return $result;
    }
コード例 #4
0
 /**
  * @param $userId
  * @param $key
  * @param $lang
  * @param $text
  */
 public function setText($userId, $key, $lang, $text)
 {
     KeyEnum::validate($key);
     LangEnum::validate($lang);
     $sql = '
         INSERT IGNORE INTO users_texts (`hostUid`, `key`, `lang`, `text`)
         VALUES (:HOST_UID, :KEY, :LANG, :TEXT)
         ON DUPLICATE KEY UPDATE text=:TEXT
     ';
     $query = $this->mysqlWrite->query($sql)->bindInt('HOST_UID', (int) $userId)->bindString('KEY', $key)->bindString('LANG', $lang)->bindString('TEXT', $text);
     /** @noinspection PhpUnusedLocalVariableInspection */
     $sql = $query->getSQL();
     $result = $query->update();
     if ($result) {
         $this->redis->set($this->buildKey($userId, $key, $lang), $text);
     }
 }