Server IP : 192.124.249.33 / Your IP : 66.248.200.33 Web Server : Apache System : Linux 141.134.66.148.host.secureserver.net 3.10.0-1160.119.1.el7.tuxcare.els6.x86_64 #1 SMP Fri Sep 13 13:42:20 UTC 2024 x86_64 User : tarangglobal ( 1001) PHP Version : 7.2.34 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /home/tarangglobal/public_html/cyber/admin/ |
Upload File : |
<?php class connection { public $cnn; public function __construct() { $host = 'localhost'; $db_name = "db_name"; $username = "root"; $password = ""; $local_IP = array('localhost', '127.0.0.1', '192.168.100.38'); $this_host = $_SERVER['HTTP_HOST']; if (in_array($this_host, $local_IP)) { $host = 'localhost'; $db_name = "etco"; $username = "root"; $password = ""; } else { $host = 'localhost'; $db_name = "taranggl_tarangwp"; $username = "taranggl_tarangw"; $password = "taraDB4321@"; } try { $this->cnn = new PDO("mysql:host={$host};dbname={$db_name}", $username, $password); } catch (PDOException $e) { echo 'Connection failed: ' . $e->getMessage(); } } public function selectp($query, $array) { //this function is created for get data $sth = $this->cnn->prepare($query); $sth->execute($array); return $sth->fetchAll(PDO::FETCH_ASSOC); } public function insertp($query, $array) { //this function is created for insert data. it will be return last inserted id. $sth = $this->cnn->prepare($query); $sth->execute($array); return $this->cnn->lastInsertId(); } public function updatep($query, $array) { //this function is created for update data and it will be return effected rows (which are updated) $sth = $this->cnn->prepare($query); return $sth->execute($array); } public function deletep($query, $array) { // this function is use to delete data. $sth = $this->cnn->prepare($query); return $sth->execute($array); } public function select($query) { //this function is created for get data $result = $this->cnn->query($query); return $result->fetchAll(PDO::FETCH_ASSOC); } } /* public function select($query){ //this function is created for get data $result = $this->cnn->query($query); return $result->fetchAll(PDO::FETCH_ASSOC); } public function insert($query){ //this function is created for insert data. it will be return last inserted id. $this->cnn->exec($query); return $this->cnn->lastInsertId(); } public function update($query){ //this function is created for update data and it will be return effected rows (which are updated) return $this->cnn->exec($query); } public function delete($query){ // this function is use to delete data. return $this->cnn->exec($query); } */ ?>Private