结构:
CREATE TABLE `links` (
`id` int(11) NOT NULL auto_increment,
`title` int(11) default NULL,
`url` varchar(200) NOT NULL,
`seourl` varchar(150) default NULL,
`linkset` varchar(50) NOT NULL default 'main',
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8
我在这里遇到了一个奇怪的问题,查询DESCRIBE links
只返回第一行(id
)。
// my query...
$data = $db->query('DESCRIBE `links`')->fetch();
// query function
public function query($sql, $id = false){
$this->query_id = mysqli_query($this->connection, $sql);
if(!$this->query_id){
psyo::error("Error while executing query (sql: {$sql}).");
return NULL;
}else{
$this->result = mysqli_store_result($this->connection);
$this->affected = mysqli_affected_rows($this->connection);
return $id ? $this->query_id : $this;
}
}
// fetch function
public function fetch($query_id = NULL){
if($query_id)
$this->query_id = $query_id;
if($this->query_id){
$data = mysqli_fetch_assoc($this->query_id);
}else{
psyo::error("Error while fetching results (query id: {$this->query_id}).");
}
$this->free();
return $data;
}
// connection set by
public function connect(){
$this->connection = mysqli_connect($this->server, $this->username, $this->password, $this->database);
if(!$this->connection){
psyo::error("Error connecting to server or while selecting database (database: {$this->database}).");
}
}
所以这些是我从一个类中取出的函数(询问是否需要更多......),是的,执行的查询只返回第一行,但在这种情况下$this->affected
返回正确的值。5
在 phpMyAdmin 中运行查询时返回预期结果。
可能是什么问题呢?