php - Getting a results of DB query basing on rows number by function -


this long.
i'm making class data teams - 5 steam users basing on 32bit steamids stored in database - 1 row = 1 team. want 1 result, when specify teamid , rows, when it's not defined(or when equals 'all'). , here starts problem, 'cause specified team gives return, can't rows, gives null when var_dumped. have created method:

public static function basedata($teamid = null){         if(!empty($teamid)){             if(is_numeric($teamid)){                 db::getinstance()->get('', 'o90eprrzc3v8', ['53qwi8md3rm7', '=', $teamid]);             }             elseif($teamid == 'all'){                 db::getinstance()->getordered('', 'o90eprrzc3v8', '53qwi8md3rm7', 'asc');             }             return db::getinstance()->results();         }         return false;     } 

where db class' methods use in team class looks this:

public function bquery($sql, $params = array()){         $this->_error = false;          if($this->_query = $this->_pdo->prepare($sql)){             $x = 1;             if(count($params)) {                 foreach($params $param){                     $this->_query->bindvalue($x, $param);                     $x++;                 }             }              if($this->_query->execute()){                 $this->_results = $this->_query->fetchall(pdo::fetch_obj);                 $this->_count = $this->_query->rowcount();             }              else{                 $this->_error = true;             }         }          return $this;     }      public function action($action, $table, $where = null){         if(!empty($where)){             (array)$where;             if(count($where) === 3){                 $operators = ['=', '>', '<', '>=', '<='];                  $field = $where[0];                 $operator = $where[1];                 $value = $where[2];                  if(in_array($operator, $operators)){                     $sql = "{$action} {$table} {$field} {$operator} ?";                      if(!$this->bquery($sql, array($value))->error()){                         return $this;                     }                 }             }             return false;         }         elseif(empty($where)){             $sql = "{$action} {$table}";              if(!$this->bquery($sql, null)->error()){                         return $this;             }         }     } public function get($selector, $table, $where = null){         if(empty($selector)){             if(!empty($where)){                 return $this->action('select *', $table, $where);             }             else{                 return $this->action('select *', $table);             }         }         else{             if(!empty($where)){                 return $this->action('select '.$selector.'', $table, $where);             }             else{                 return $this->action('select '.$selector.'', $table);             }         }     }      public function getordered($selector, $table, $order, $ordertype, $where = null){         $ordertype = strtoupper($ordertype);         if(($selector = '') or (empty($selector))){             return $this->action('select *', $table, 'order '.$order.' '.$ordertype.'');         }         else{             return $this->action('select '.$selector.'', $table, 'order '.$order.' '.$ordertype.'');         }     }      public function results(){         return $this->_results;     } public function count(){         return $this->_count;     } 

and want to
- loop through results
- return variables, can echo them on index page i've tried create method this, until basedata() doesn't work, can't check if it's working (it won't, of apps write :d):

public static function getsteamdata($teamid = 0){         for($teamid = 0;$teamid<(db::getinstance()->count());$teamid++){             $result = self::basedata($teamid);              $stmid_capt = "steam_0:$result->stmidcapt_1:$result->stmidcapt_2";             $stmid_p2 = "steam_0:$result->stmidp2_1:$result->stmidp2_2";             $stmid_p3 = "steam_0:$result->stmidp3_1:$result->stmidp3_2";             $stmid_p4 = "steam_0:$result->stmidp4_1:$result->stmidp4_2";             $stmid_p5 = "steam_0:$result->stmidp5_1:$result->stmidp5_2";              $stmid64 = [                 'capt' => convertid($result->stmidcapt_2),                 'p2' => convertid($result->stmidp2_2),                 'p3' => convertid($result->stmidp3_2),                 'p4' => convertid($result->stmidp4_2),                 'p5' => convertid($result->stmidp5_2),             ];              $stmid3 = [                 'capt' => convertid3($result->stmidcapt_1, $result->stmidcapt_2),                 'p2' => convertid3($result->stmidp2_1, $result->stmidp2_2),                 'p3' => convertid3($result->stmidp3_1, $result->stmidp3_2),                 'p4' => convertid3($result->stmidp4_1, $result->stmidp4_2),                 'p5' => convertid3($result->stmidp5_1, $result->stmidp5_2),             ];              $profile_get[0] = arrays::get('response→players', json_decode(file_get_contents('http://api.steampowered.com/isteamuser/getplayersummaries/v0002/?key='.arrays::get("steamapi→key").'&steamids='.$stmid64['capt']),true));             $profile_get[1] = arrays::get('response→players', json_decode(file_get_contents('http://api.steampowered.com/isteamuser/getplayersummaries/v0002/?key='.arrays::get("steamapi→key").'&steamids='.$stmid64['p2']),true));             $profile_get[2] = arrays::get('response→players', json_decode(file_get_contents('http://api.steampowered.com/isteamuser/getplayersummaries/v0002/?key='.arrays::get("steamapi→key").'&steamids='.$stmid64['p3']),true));             $profile_get[3] = arrays::get('response→players', json_decode(file_get_contents('http://api.steampowered.com/isteamuser/getplayersummaries/v0002/?key='.arrays::get("steamapi→key").'&steamids='.$stmid64['p4']),true));             $profile_get[4] = arrays::get('response→players', json_decode(file_get_contents('http://api.steampowered.com/isteamuser/getplayersummaries/v0002/?key='.arrays::get("steamapi→key").'&steamids='.$stmid64['p5']),true));              $profile_avatar = [                 'capt' => arrays::get('0→avatarmedium', $profile_get[0]),                 'p2' => arrays::get('0→avatarmedium', $profile_get[1]),                 'p3' => arrays::get('0→avatarmedium', $profile_get[2]),                 'p4' => arrays::get('0→avatarmedium', $profile_get[3]),                 'p5' => arrays::get('0→avatarmedium', $profile_get[4]),             ];              $profile_status = [                 'capt' => arrays::get('0→personastate', $profile_get[0]),                 'p2' => arrays::get('0→personastate', $profile_get[1]),                 'p3' => arrays::get('0→personastate', $profile_get[2]),                 'p4' => arrays::get('0→personastate', $profile_get[3]),                 'p5' => arrays::get('0→personastate', $profile_get[4]),             ];              $profile_name = [                 'capt' => escape(arrays::get('0→personaname', $profile_get[0])),                 'p2' => escape(arrays::get('0→personaname', $profile_get[1])),                 'p3' => escape(arrays::get('0→personaname', $profile_get[2])),                 'p4' => escape(arrays::get('0→personaname', $profile_get[3])),                 'p5' => escape(arrays::get('0→personaname', $profile_get[4]))             ];         }     } 

i hope patient read of stuff , can me making work :d


Comments

Popular posts from this blog

Fail to load namespace Spring Security http://www.springframework.org/security/tags -

sql - MySQL query optimization using coalesce -

unity3d - Unity local avoidance in user created world -