Server IP : 103.53.40.154 / Your IP : 18.221.175.48 Web Server : Apache System : Linux md-in-35.webhostbox.net 4.19.286-203.ELK.el7.x86_64 #1 SMP Wed Jun 14 04:33:55 CDT 2023 x86_64 User : ppcad7no ( 715) PHP Version : 8.2.25 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON Directory (0755) : /home2/ppcad7no/automationpowersolutions.com/admin/ |
[ Home ] | [ C0mmand ] | [ Upload File ] |
---|
<?php class Database{ private $db_server = "localhost"; private $db_user = "root"; private $db_pass = ""; private $db_name = "arham_db"; private $mysqli = ""; private $msg = array(); private $conn = false; public function __construct(){ if (!$this->conn) { $this->mysqli = new mysqli($this->db_server,$this->db_user,$this->db_pass,$this->db_name); $this->conn = true; if ($this->mysqli->error) { array_unshift($this->msg, "Database Not Connected".$this->mysqli->error); return false; }else{ array_unshift($this->msg, "Database Connected"); return true; } } } public function insert($table,$data=array()){ if($this->checktable($table)){ $table_columns = implode(', ',array_keys($data)); $table_value =implode("', '", $data); $sql="INSERT INTO $table ($table_columns) VALUES ('$table_value')"; if($this->mysqli->query($sql)){ array_unshift($this->msg,'The data has been inserted'); return true; }else{ array_unshift($this->result,$this->mysqli->error); return false; } }else{ return false; } } public function checktable($table){ $sql = "SHOW TABLES FROM $this->db_name LIKE '$table'"; $run = $this->mysqli->query($sql); if($run){ if($run->num_rows == 1){ return true; }else{ array_unshift($this->msg,$table." This Table is not Found"); return false; } } } public function showmsg(){ $showm = $this->msg[0]; echo $showm; return true; } } ?>