sitNsmile
04-01-2010, 07:09 PM
Okay. I've got a client that has some large websites, and need to be sure when I build the functions its as fast as possible... with showing you my function of querying results for games, (the database query system is already using caching (apc). but with code here, would something like this big okay, or is there ways to improve code that I already put together?
Just looking for new ideas...
public function queryGames($order,$oType,$limit,$active){
$gameTable = $this->_gameTable;
$gameStatus = $this->_gameStatus;
/* ORDER presets */
switch($order)
{
case 'ID':$gameOrder = $this->type0;break;
case 'DATE':$gameOrder = $this->type1;break;
case 'RANDOM':$gameOrder = $this->type2;break;
case 'RATING':$gameOrder = $this->type3;break;
case 'TOTALPOPULAR':$gameOrder = $this->type4;break;
case 'TODAYPOPULAR':$gameOrder = $this->type5;break;
}
$orderType = $oType == 'DESC' ? 'DESC' : 'ASC' ;
$statusType = $active == true ? "$gameStatus='1'" : "$gameStatus>='0'" ;
$sql = "SELECT * FROM $gameTable
WHERE $statusType
ORDER by $gameOrder $orderType
LIMIT $limit";
return $runSql = $this->_db->arcade->fetchAll($sql);
}
trying to do low procedural coding as possible.
Just looking for new ideas...
public function queryGames($order,$oType,$limit,$active){
$gameTable = $this->_gameTable;
$gameStatus = $this->_gameStatus;
/* ORDER presets */
switch($order)
{
case 'ID':$gameOrder = $this->type0;break;
case 'DATE':$gameOrder = $this->type1;break;
case 'RANDOM':$gameOrder = $this->type2;break;
case 'RATING':$gameOrder = $this->type3;break;
case 'TOTALPOPULAR':$gameOrder = $this->type4;break;
case 'TODAYPOPULAR':$gameOrder = $this->type5;break;
}
$orderType = $oType == 'DESC' ? 'DESC' : 'ASC' ;
$statusType = $active == true ? "$gameStatus='1'" : "$gameStatus>='0'" ;
$sql = "SELECT * FROM $gameTable
WHERE $statusType
ORDER by $gameOrder $orderType
LIMIT $limit";
return $runSql = $this->_db->arcade->fetchAll($sql);
}
trying to do low procedural coding as possible.