/**
  * @param ISqlQuery $query
  * @param string $errormsg
  * @param integer $errorno
  */
 function __construct(ISqlQuery $query, $errormsg, $errorno)
 {
     Assert::isScalar($errormsg);
     Assert::isNumeric($errorno);
     parent::__construct($errormsg, $errorno);
     $this->query = $query;
 }
 /**
  * @see CachePeer::set()
  *
  * @return SysVCachePeer
  */
 function set($key, $value, $ttl = CacheTtl::HOUR)
 {
     Assert::isNumeric($ttl);
     if ($this->isAlive()) {
         shm_put_var($this->getSegmentPtr(), $this->key2int($key), array(self::FIELD_EXPIRES => time() + $ttl, self::FIELD_DATA => $value));
     }
     return $this;
 }
 /**
  * Choose russion word declension based on numeric.
  *
  * Example for $expressions: array("ответ", "ответа", "ответов")
  *
  * @param int $number
  * @param array $expressions
  * @return string
  */
 static function getDeclension($number, array $expressions)
 {
     Assert::isNumeric($number);
     if (count($expressions) < 3) {
         $expressions[2] = $expressions[1];
     }
     $count = $number % 100;
     if ($count >= 5 && $count <= 20) {
         $result = $expressions[2];
     } else {
         $count = $count % 10;
         if ($count == 1) {
             $result = $expressions[0];
         } elseif ($count >= 2 && $count <= 4) {
             $result = $expressions[1];
         } else {
             $result = $expressions[2];
         }
     }
     return $result;
 }
Beispiel #4
0
function highscore_list($filter, $pages, $page = 1, $rows = 50)
{
    Assert::isId($page);
    Assert::isId($rows);
    if ($filter['hours'] || $filter['days']) {
        if ($filter['hours']) {
            Assert::isNumeric($filter['hours']);
            $timeout = date("Y-m-d H:m:s", time() - (int) $filter['hours'] * 60 * 60);
        } else {
            Assert::isNumeric($filter['days']);
            $timeout = date("Y-m-d H:m:s", time() - (int) $filter['days'] * 24 * 60 * 60);
        }
        $count = selectsql("\n              select count(*) as count\n              from user u\n              left join activity a on (a.uid = u.uid)\n              where a.stamp > '{$timeout}'\n              group by u.uid\n        ");
        $count = count($count);
        #Seitenamzahl berechnen
        $pages = ceil($count / $rows);
        #Seite checken
        if ($pages < $page && $pages != 0) {
            $page = $pages;
        }
        $result = selectsql("\n          select u.*,ga.*,a.*,sum(ac.bonus) as activity_points\n          from user u\n          left join activity ac on (ac.uid = u.uid)\n          left join galaxy ga on (ga.gala = u.gala)\n          left join alliance a on(a.aid = ga.aid)\n          where ac.stamp > '{$timeout}'\n          group by u.uid\n          order by activity_points desc, u.nick asc\n          LIMIT " . $rows * ($page - 1) . ",{$rows}\n        ");
    } else {
        $count = selectsqlLine("\n              select count(*) as count\n              from user u\n        ");
        #Seitenamzahl berechnen
        $pages = ceil($count['count'] / $rows);
        #Seite checken
        if ($pages < $page && $pages != 0) {
            $page = $pages;
        }
        $result = selectsql("\n          select * from user u\n          left join galaxy ga on (ga.gala = u.gala)\n          left join alliance a on(a.aid = ga.aid)\n          order by u.activity_points desc, u.nick asc\n          LIMIT " . $rows * ($page - 1) . ",{$rows}\n        ");
    }
    for ($i = 0; $i < count($result); $i++) {
        $result[$i]['place'] = $rows * ($page - 1) + $i + 1;
    }
    return $result;
}
Beispiel #5
0
 /**
  * @param integer $port
  * @return HttpUrl itself
  */
 function setPort($port)
 {
     Assert::isNumeric($port);
     $this->port = $port;
     return $this;
 }
Beispiel #6
0
 public function test_should_support_numeric_assertion()
 {
     $this->assertTrue(Assert::isNumeric(3));
 }
 /**
  * Sets the mask to what errors should be translated to exceptions. E.g., if you specify
  * E_WARNING | E_NOTICE as the cover mask, E_NOTICE and E_WARNING errors would be translated
  * to exceptions, but E_ERROR is not.
  * @param integer $coverMask integer mask to specify what errors should be translated to
  * 	exceptions. E.g., if you specify E_WARNING | E_NOTICE as the cover mask, E_NOTICE
  *  and E_WARNING errors would be translated to exceptions, but E_ERROR is not.
  * 	Default is E_ALL.
  * @return Exceptionizer itself
  */
 function setCoverMask($coverMask = E_ALL)
 {
     Assert::isNumeric($coverMask);
     Assert::isTrue(!!($coverMask & E_ALL), 'not an error mask');
     $this->mask = $coverMask;
     return $this;
 }
Beispiel #8
0
function miliscan_fleet_get_bykoords($gala, $pos, $num)
{
    Assert::isId($gala);
    Assert::isId($pos);
    Assert::isNumeric($num);
    return selectsqlline("\n    select * from scans s\n      left join scanmili_fleet mf using(sid)\n      left join fleet f on (f.fid = mf.fid)\n      where s.gala = {$gala} and s.pos = {$pos} and mf.num = {$num}\n  ");
}