I cannot echo any rows when I bind $limit variable and $offset variable to a PDO ?,?,? limit and offset clause.
connection class
protected function connect(){ $dsn='mysql:host='.$this->host.';dbname='.$this->dbName; $pdo = new PDO($dsn, $this->user, $this->pwd); $pdo->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC); return $pdo; } Another class that uses the connect method($this) of the connection class.
protected function getAlllimitedprivilege($privilege,$status,$company, $limit, $offset){ $sql="SELECT * FROM `privilege` WHERE `privilege`=? AND `status`=? AND `company`=? ORDER BY `id` DESC LIMIT ? OFFSET ?"; $stmt= $this->connect()->prepare($sql); $stmt->execute([$privilege,$status,$company, $limit, $offset]); $user=$stmt->fetchAll(); return $user; } Code where the variables are passed
$list=$usersview->showAllprivilege('Friends','APPROVED',$_SESSION['company_id'], $limit, $offset); https://stackoverflow.com/questions/66878036/cast-php-pagination-variable-for-use-in-pdo-prepared-statement March 31, 2021 at 04:28AM
没有评论:
发表评论