I have a class php file named recordSet.class.php here.
abstract class R_RecordSet {
protected $db;
protected $stmt;
function __construct() {
$this->db = pdoDB:: getConnection();
}
function getRecordSet($sql, $params = null) {
if (is_array($params)) {
$this->stmt = $this->db->prepare($sql);
// execute the statement passing in the named placeholder and the value it'll have
$this->stmt->execute($params);
}
else {
$this->stmt = $this->db->query($sql);
}
return $this->stmt;
}
}
class JSONRecordSet extends R_RecordSet {
function getRecordSet($sql, $elementName = "ResultSet", $params = null) {
$stmt = parent::getRecordSet($sql, $params);
$recordSet = $stmt->fetchAll(PDO::FETCH_ASSOC);
$nRecords = count($recordSet);
if ($nRecords == 0) {
$status = 'error';
$message = json_encode(array("text" => "No records found"));
$result = '[]';
}
else {
$status = 'ok';
$message = json_encode(array("text" => ""));
$result = json_encode($recordSet);
}
//return "{\"status\": \"$status\", \"message\":$message, \"$elementName\" :{\"RowCount\": $nRecords ,\"Result\": $result}}";
//these RowCount and results matters in service.js
return "{\"RowCount\": $nRecords ,\"results\": $result}";
}
}
So when I call a getRecordSet() from other place like:
$loginSQL = "SELECT * FROM l_user WHERE userID='".$userid."' AND password='".$password."'";
echo $rs->getRecordSet($loginSQL, 'ResultSet');
How can I check access to this variable $rs? sqlite is used to retrieve data here. I am not familiar with PHP and I do not know how I can see what is in $rs. I am trying to check if there are any record set to make a session.
If you just want to see the output of $rs then you can your print_r or var_dump for the same
echo "<pre>";
print_r($rs);
echo "</pre>";
OR
var_dump($rs);
如果您要检查输入的参数是否存在任何行,则可以轻松编写这样的查询。
$query = "COUNT(*) user_count FROM l_user WHERE userID = ? AND password = ?";
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.