// 代码一
public function getPCA($level = false) { $results = array(); $where = $level ? " where f_level={$level}" : ''; $sql = "select * from {$this->_table}{$where}"; $query = $this->dbLink->query($sql); if (! $this->dbLink->errno()) { if ($this->dbLink->num_rows($query)) { $row = $this->dbLink->fetch_assoc($query); while ($row) { $results[$row['id']] = $row['f_name']; $row = $this->dbLink->fetch_assoc($query); } } } return $results; }
代码二:
public function getPCA($level = false , $debug = false) { $results = array(); $where = $level ? " where f_level={$level}" : ''; $sql = "select * from {$this->_table}{$where}"; $query = $this->dbLink->query($sql); if($debug) { echo $sql; echo $this->dbLink->errno(); } if (! $this->dbLink->errno()) { if ($this->dbLink->num_rows($query)) { while ($row = $this->dbLink->fetch_assoc($query)) { $results[$row['id']] = $row['f_name']; } } } return $results; }