back
<?php
require_once('dbConnect.php');
// Includes the connection class file for further use.
class selectClass extends dbConnect{
// This class extends the dbConnect class from the dbConnect.php class file.
// This is needed to access the connection variable for further sql query.
public function selectFunction($id){
// This is the function which will select a row of data in the database uniquely identified by $id.
// For this the function takes $id as argument.
$query="select * from oop_table where oop_table.id=".$id;
// Passing the sql query to the variable $query.
$result=$this->con->query($query);
// In dbConnect.php class file, $con variable is set as an object of the readymade mysqli class.
// query is the fuction of this class which takes the sql query as the argument.
return $result->fetch_assoc();
// Returns $result as an associative array with id and name for the row identified by $id in the database.
}
}
?>