嗨,大家好,我有以下代码:PHP OOP取回阵列从数据库和MySQL
$this->db->setQuery("SELECT id,grad FROM login WHERE Email='$Email' AND Parola='$Parola' LIMIT 1");
//setQuery Is setting the Query
if($this->db->NumRows() > 0) {
//Checking if Number of Rows is greater than 0
if(session_id() == ''){
session_start();
}
$this->Email = $Email;
while($row = mysql_fetch_array($this->db->GetResource())){
//Fetching from the database the "Id" And "Grad"
$this->Id = $row[0];
$this->Grad = $row[1];
}
echo $this->Id . "<br />";
echo $this->Grad . "<br/>";
}
虽然是工作,我的计划,我很不满意的代码,我想为“ID信息“和”毕业“从这样的”数据库“。
$this->Id = $this->db->getInfo();
$this->Grad = $this->db->getInfo();
那么这里我想呼应 “ID” 和 “梯度” 我得到他的注意,当遇到问题
注意:数组字符串转换在 C:\ XAMPP \ htdocs中\便便\类\ MVC \ userlogin.php第39行上阵列
代码的getInfo():
//$this->Resource is the mysql_query of the setQuery
$this->Rows = array();
if ($this->Resource) {
while ($row = mysql_fetch_array($this->Resource)) {
$this->Rows[] = $row;
}
}
return $this->Rows;
我想提一提的是我是PHP和OOP的初学者。 代码对所有功能使用http://tny.cz/4c5596fc
我意识到SQL注入是可能的,我将在稍后检查PDO,因为我可以获得更多关于PHP的知识。 – camin10 2015-01-26 21:45:10