ok

Mini Shell

Direktori : /home2/selectio/www/mm-tailor-billing/hrm/config/
Upload File :
Current File : /home2/selectio/www/mm-tailor-billing/hrm/config/config.php

<?php
ini_set('error_reporting', E_ALL);

date_default_timezone_set('Asia/Kolkata');
$dbhost = 'localhost';
$dbname = 'selectio_mm_tailor_dashboard';
$dbuser = 'selectio_mm_tailor_dashboard';
$dbpass = 'selectio_mm_tailor_dashboard';
try {
	$pdo = new PDO("mysql:host={$dbhost};dbname={$dbname}", $dbuser, $dbpass);
	$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
}
catch( PDOException $exception ) {
	echo "Connection error :" . $exception->getMessage();
	header("location: db-connection-error.php");
}

class Database
{
        
function insert($table, $params = array())
    {
        $dbhost = 'localhost';
        $dbname = 'mm_tailor';
        $dbuser = 'root';
        $dbpass = '';
         $pdo = new PDO("mysql:host={$dbhost};dbname={$dbname}", $dbuser,$dbpass);
    	 $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    	 $statement = $pdo->prepare("SET SESSION sql_mode = ''");
    	 $statement->execute();

        $sql = 'INSERT INTO `' . $table . '` (`' . implode('`, `', array_keys($params)) . '`) VALUES ("' . implode('", "', $params) . '")';
            
        $statement = $pdo->prepare($sql);
        if ($statement->execute()) {
            return $pdo->lastInsertId(); 
        } else {
            return false; 
        }
    }
    
public function update($table, $params = array(), $where)
    {
        $dbhost = 'localhost';
        $dbname = 'mm_tailor';
        $dbuser = 'root';
        $dbpass = '';

         $pdo = new PDO("mysql:host={$dbhost};dbname={$dbname}", $dbuser,$dbpass);
    	 $pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    	 $statement = $pdo->prepare("SET SESSION sql_mode = ''");
    	 $statement->execute();
    	 
        $args = array();
        foreach ($params as $field => $value) {
            $args[] = $field . '="' . $value . '"';
        }
        $sql = 'UPDATE ' . $table . ' SET ' . implode(',', $args) . ' WHERE ' . $where;
        $statement = $pdo->prepare($sql);
        if ($statement->execute()) {
            return true; 
        } else {
            return false; 
        }
    }
}
?>

Zerion Mini Shell 1.0