Question: USE THE FOLLOWING PHP CODE TO ANSWER THE QUESTIONS public function search($search_term, $from_record_num, $records_per_page){ // select query $query = SELECT c.name as category_name, p.id, p.name,

USE THE FOLLOWING PHP CODE TO ANSWER THE QUESTIONS

public function search($search_term, $from_record_num, $records_per_page){ // select query $query = "SELECT c.name as category_name, p.id, p.name, p.description, p.price, p.category_id, p.created FROM " . $this->table_name . " p LEFT JOIN categories c ON p.category_id = c.id WHERE p.name LIKE ? OR p.description LIKE ? ORDER BY p.name ASC LIMIT ?, ?"; // prepare query statement $stmt = $this->conn->prepare( $query ); // bind variable values $search_term = "%{$search_term}%"; $stmt->bindParam(1, $search_term); $stmt->bindParam(2, $search_term); $stmt->bindParam(3, $from_record_num, PDO::PARAM_INT); $stmt->bindParam(4, $records_per_page, PDO::PARAM_INT); // execute query $stmt->execute(); // return values from database return $stmt; }

  • In the method, search(), why are there percent signs in the statement,
    • $search_term = "%{$search_term}%";
  • In the method, search(), what is accomplished by the following statement,

    • $stmt->bindParam(3, $from_record_num, PDO::PARAM_INT);

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!