Asking for a simple PHP question
I want to get the number of rows affected by the database but $row how to get the number of rows that are affected on the implementation class side, and the novice can't afford to hurt, the bend won't turn.
class_user.php
Class userinfo{
Private $userName; attribute, user name
Private $passWord; Property
Private $userGrade; Properties, User Level
Private $row;
Private $userInfo; An array variable that stores the information returned by the database.
Public function __construct ($sql) {
Require_once ("db_config.php"); Contains configuration information.
$result = mysql_query ($sql, $conn); Execute Query statement
$this->userinfo = mysql_fetch_array ($result); Returning query results to an array
$row =mysql_num_rows ($result);
mysql_query ("Set names UTF8");
Mysql_close ($conn); To close a database connection
$this->getinfo (); Invokes the method that passes the information.
}
How to get information passed to a property
Private Function GetInfo () {
$this->username = $this->userinfo["UserName"];
$this->password = $this->userinfo["PassWord"];
$this->usergrade = $this->userinfo["Usergrade"];
}
Returns the public method for each property.
Public Function GetRow () {
return $this->row;
}
Public Function GetUserName () {
return $this->username;
}
Public Function GetPassword () {
return $this->password;
}
Public Function Getusergrade () {
return$this->usergrade;
}
}
$sql = "SELECT * from userinfo where username= ' sa '";
Require_once ("class_user.php");
$user = new UserInfo ($sql); Creates a user object.
Writing SQL
$row = $user->getrow ();
$username = $user->getusername (); Call method to get data separately
$password = $user->getpassword ();
$usergrade = $user->getusergrade ();
echo "Your name is". $username. "
"; Output data
echo "Your password is". $password. "
";
echo "Your grade is". $usergrade. "
";
echo "Your ROW is". $row. "
";
?>
PHP Database SQL function
------Solution--------------------