这是我的oop php代码,用于连接我的数据库。但我怎么做SELECT
函数。我想从数据库中显示我的网页中的数据。帮我这个mysql select oop php
class createConnection //create a class for make connection
{
var $host = "localhost";
var $username = "root"; // specify the sever details for mysql
var $password = "";
var $database = "akpGroup";
var $myconn;
function connectToDatabase() // create a function for connect database
{
$conn = mysql_connect($this->host, $this->username, $this->password);
if (!$conn) // testing the connection
{
die ("Cannot connect to the database");
} else {
$this->myconn = $conn;
echo "Connection established";
}
return $this->myconn;
}
function selectDatabase() // selecting the database.
{
mysql_select_db($this->database); //use php inbuild functions for select database
if (mysql_error()) // if error occured display the error message
{
echo "Cannot find the database " . $this->database;
}
echo "Database selected..";
}
function closeConnection() // close the connection
{
mysql_close($this->myconn);
echo "Connection closed";
}
选择功能?你的意思是数据库或查询来选择一个表?另外,尝试使用'mysqli_ *','mysql_ *'已弃用。 – putvande
yeahh我想从数据库中选择一个表。是啊它的查询选择一个table.thanx指出 – Niranjana668
'OOP'和'mysql',很好的组合 –