Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class db_system
- {
- private $link;
- private $result;
- /*
- Constructor connects to database and store in link
- */
- public function __construct()
- {
- $lines = file('../../secret/topsecret');
- $this->link = mysqli_connect(trim($lines[0]), trim($lines[1]), trim($lines[2]), trim($lines[3])) or die("Could not connect to " . mysqli_error($this->link));
- if(is_resource($this->link))
- echo "true";
- else
- echo "false"; // it always prints false;
- }
- /*
- this method process the query and returns the result od the query
- */
- public function sqlquery($query)
- {
- $this->result = mysqli_query($this->link, $query) or die('query failed ' . mysqli_error($this->link));
- }
- /*
- this method returns the rows in an array form
- */
- public function get_data()
- {
- return mysqli_fetch_array($this->result);
- }
- /*
- destructor closes sql connection if link is active
- */
- public function __destruct()
- {
- if($this->link)
- {
- mysqli_close($this->link);
- }
- }
- public function getlink()
- {
- return $this->link;
- }
- }
- include 'library.php';
- $view = new db_system(); // connection object made
- $per = "%";
- $qry = sprintf('SELECT * FROM inventory WHERE description LIKE "%s%s%s"',$per,mysql_real_escape_string($find,$view->getlink()),$per);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement