PHP函数导致503错误

时间:2017-03-11 22:01:33

标签: php mysql nette

我正在努力解决我的APP问题。我有几个PHP函数导致我503错误。 我正在使用Nette框架。

第一个函数获取'商品生产'的大小通过连接到Mysql并将Mysql条目与常量相乘。我对此没有任何问题。

public function GetCommodityProduction($estId, $commodity)
    {
        switch ($commodity)
        {
            case 'money':
                $cityCount = $this->database->table('buildings')->where('id = ?', $estId)->fetch()->city;
                $commodityProduction = ($cityCount * self::CITY_PRODUCTION);
                return round($commodityProduction);
            break;
            case 'resources':
                $mineCount = $this->database->table('buildings')->where('id = ?', $estId)->fetch()->mine;
                $commodityProduction = ($mineCount * self::MINE_PRODUCTION);
                return round($commodityProduction);
            break;
            case 'energy':
                ........
        }
    }

第二个函数使用该商品的方式与我获得商品生产的方式相同:

public  function GetCommodityUsage($estId, $commodity)
    {
        switch ($commodity)
        {
            case 'money':
                $barracksCount = $this->database->table('buildings')->where('id = ?', $estId)->fetch()->barracks;
                $tankCount = $this->database->table('army')->where('id = ?', $estId)->fetch()->tank;
                $commodityUsage = (($barracksCount * self::BARRACKS_MONEY_CONSUMPTION) +
                    ($tankCount * self::TANK_MONEY_CONSUMPTION));
                return round($commodityUsage);
            break;
            case 'resources':
                $tankProduction = $this->factoryProduction->getFactoryProduction($estId, 'tank');
                $commodityUsage = (($tankProduction * self::TANK_RESOURCES_CONSUMPTION));
                return round($commodityUsage);
            break;
            case 'energy':
                ..........
        }
    }

当我尝试在这一个函数中减去两个函数的值时,问题就开始了:

public function GetActualCommodityProduction($estId, $commodity)
    {
        switch ($commodity)
        {
            case 'money':
                $actualProduction = $this->GetActualCommodityProduction($estId, 'money') -
                    $this->GetCommodityUsage($estId, 'money');
                return round($actualProduction);
            break;
            case 'resources':
                $actualProduction = $this->GetActualCommodityProduction($estId, 'resources') -
                    $this->GetCommodityUsage($estId, 'resources');
                return round($actualProduction);
            break;
            case 'energy':
                .......
        }
    }

我认为问题是最后一个功能是重载服务器。但我不确定。您能告诉我如何修改这些功能以使其正常工作吗?

0 个答案:

没有答案