【发布时间】:2015-03-25 07:25:36
【问题描述】:
大家好,我有以下代码:
$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 / >";
}
虽然按照我的计划工作,但我对代码不满意,我想像这样从“db”中获取“Id”和“Grad”的信息。
$this->Id = $this->db->getInfo();
$this->Grad = $this->db->getInfo();
好吧,当我尝试回显“Id”和“Grad”时,我被卡住了,我收到了他的通知
注意:数组到字符串的转换 C:\xampp\htdocs\poo\classes\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
【问题讨论】: