I developed on Java Swing OOP so I am a little confused with a PHP OOP Techniques, they are the same in logic but not the same with syntax. Please help me with this, I need your specialties. Thank you all.
this is my index.php
<?php
require_once("DB.class.php");
$db = new DB("localhost", "root", "100510", "findersa_jfph_smart");
$db->select("t1.`sid` AS 'id', t1.`Title` AS 'title', t1.`JobDescription` AS 'content', t1.`Location_City` AS 'city', t1.`SalaryType` AS 'salary',
t1.`EmploymentType` AS 'working_hours', t2.`CompanyName` AS 'company', t1.`JobRequirements` AS 'requirements', t1.`JobCategory` AS 'category', t1.`activation_date` AS 'date',
t2.`PhoneNumber` AS 'contact_telephone'","`listings` AS t1
LEFT JOIN `users` AS t2
ON t1.`user_sid` = t2.`sid`","t1.`activation_date` BETWEEN '2016-02-02 00:00:00' AND '2016-05-02 23:59:59' AND t1.active = '1' AND t1.listing_type_sid = '6'
LIMIT 50000");
?>
this is my DB.class.php
<?php
class DB {
public $host;
public $user;
public $pass;
public $dbase;
public function __construct($host, $user, $pass, $dbase) {
$this->host = $host;
$this->user = $user;
$this->pass = $pass;
$this->dbase = $dbase;
$conn = new mysqli($this->host, $this->user, $this->pass, $this->dbase);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
echo "Connected Successfully!";
}
public function select($myCols, $myTable, $myQuery) {
if (!isset($myQuery)) {
$sql = "select " . $myCols . " from " . $myTable;
} else {
$sql = "select " . $myCols . " from " . $myTable . " from " . $myQuery;
}
$result = $this->conn->query($sql);
if ($result->num_rows > 0) {
return $result;
} else {
return "0 results";
}
$conn->close();
}
}
?>
Sorry I can't get all the code in the box. But this is where i have a particular error:
$result = $this->conn->query($sql);
in DB.class.php.
Thank you. This is my first question here, please bear with me.