我正在使用PHP中的搜索功能,所以我确实希望能够研究所有数据库表中的任何关键字,但我无法获取 SQL 语句的结果:
SELECT * FROM All_Tables
这是我的代码:
$getTables = $this->db->query("show tables");
$tmpString = '';
while ($table_data = $getTables->fetch(PDO::FETCH_NUM))
{
$tmpString.=$table_data[0].',';
}
$ALL_DATABASE_TABLES = substr($tmpString,0,strlen($tmpString)-1); //Remove the last ,
echo " $ALL_DATABASE_TABLES "; // Works, it shows all database tables
$query = "SELECT * FROM $ALL_DATABASE_TABLES" ;
$stmt = $this->db->query($query) or die(print_r($this->db->errorInfo())) ;
echo "Cool1"; // Works
echo "$ALL_DATABASE_TABLES "; //Works
// This Loop doesn't work-----------------------
while ($row = $stmt->fetch(PDO::FETCH_NUM))
{
echo "Cool2"; // Doesn't work
echo "$row[0]" ; // Doesn't work
}
//----------------------------------------------
$stmt->closeCursor();
你对此有什么想法吗?感谢你们