public function __construct($pID = -1) { if (is_null(self::$conn)) { self::$conn = mysqli_connect('localhost', 'root', 'iti', 'eShop'); } if ($pID != -1) { $query = "select * from products where pID={$pID} "; $result = mysqli_query(self::$conn, $query); // if(mysqli_num_rows($result)>0) // { $product = mysqli_fetch_assoc($result); $this->pID = $product['pID']; $this->pName = $product['pName']; $this->pPrice = $product['pPrice']; $this->pQuantity = $product['pQuantity']; $this->pImg = $product['pImg']; $this->pDesc = $product['pDesc']; $this->scID = $product['scID']; // } // else // } // return 'undefined'; // } } }
public function __construct() { $servername = "localhost"; $username = "******"; $password = "******"; $dbname = "ecommerce"; if (is_null(self::$conn)) { self::$conn = mysqli_connect('localhost', 'root', 'iti', 'ecommerce'); } }
function __construct($id = -1) { if (self::$conn == Null) { self::$conn = mysqli_connect('localhost', 'root', 'iti', 'store'); } }