Kill() public method

Stop executing (die/exit) and show last MySQL error message
public Kill ( $message = "" )
Exemplo n.º 1
0
 function __construct($connect = true, $database = null, $server = null, $username = null, $password = null, $charset = "utf8", $port = null)
 {
     parent::__construct($connect, $database, $server, $username, $password, $charset, $port);
     if (parent::Error()) {
         parent::Kill();
     }
     $this->ErrorMsgs = array();
 }
function chapter_show_data($id)
{
    $hmdb = new MySQL(true, DB_NAME, DB_HOST, DB_USER, DB_PASSWORD, DB_CHARSET);
    hook_action('chapter_show_data');
    if (!$hmdb->Query("SELECT * FROM " . DB_PREFIX . "content WHERE `status` = 'chapter' AND `parent` = '{$id}' ORDER BY id DESC")) {
        $hmdb->Kill();
    }
    $array_cha = array();
    while ($row = $hmdb->Row()) {
        $data_cha = content_data_by_id($row->id);
        $array_cha[] = array('id' => $row->id, 'name' => $row->name, 'slug' => $row->slug, 'public_time' => date('d-m-Y H:i', $data_cha['field']['public_time']));
    }
    $array['chapter'] = $array_cha;
    return hook_filter('chapter_show_data', json_encode($array, TRUE));
}
Exemplo n.º 3
0
    $_FILES = $HTTP_POST_FILES;
}
if (!isset($_SERVER)) {
    $_SERVER = $HTTP_SERVER_VARS;
}
if (!isset($_SESSION)) {
    $_SESSION = $HTTP_SESSION_VARS;
}
if (!isset($_POST)) {
    $_POST = $HTTP_POST_VARS;
}
if (!isset($_GET)) {
    $_GET = $HTTP_GET_VARS;
}
if ($_SERVER['REMOTE_ADDR'] == '127.0.0.1') {
    #echo "LAVORO LOCALE";
    define("DB_HOST", '192.168.0.15');
    define("DB_USER", 'sil_booking');
    define("DB_PASSWORD", 'lignano');
    define("DB_NAME", 'kicero');
} else {
}
define("VAT_VALUE", 22);
define("VAT_VALUE_X", 1.22);
require_once dirname(__FILE__) . '/config.inc.php';
require_once dirname(__FILE__) . '/db.class.inc.php';
#require_once dirname(__FILE__).'/ezmc.class.inc.php';
$db = new MySQL(true, DB_NAME, DB_HOST, DB_USER, DB_PASSWORD);
if ($db->Error()) {
    $db->Kill("Errore connessione a DB");
}
Exemplo n.º 4
0
-- SQL to generate test table
-- --------------------------------------------
CREATE TABLE `test` (
  `TestID` int(10)     NOT NULL auto_increment,
  `Color`  varchar(15) default NULL,
  `Age`    int(10)     default NULL,
  PRIMARY KEY  (`TestID`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
-- --------------------------------------------
*/
// --- Open the database --------------------------------------------
// (Also note that you can fill in the variables in the top of the class
// if you want to automatically connect when the object is created. If
// you fill in the values when you create the obect, this is not needed.)
if (!$db->Open("test", "localhost", "root", "password")) {
    $db->Kill();
}
echo "You are connected to the database<br />\n";
// --- Insert a new record ------------------------------------------
$sql = "INSERT INTO Test (Color, Age) Values ('Red', 7)";
if (!$db->Query($sql)) {
    $db->Kill();
}
echo "Last ID inserted was: " . $db->GetLastInsertID();
// --- Or insert a new record with transaction processing -----------
$sql = "INSERT INTO Test (Color, Age) Values ('Blue', 3)";
$db->TransactionBegin();
if ($db->Query($sql)) {
    $db->TransactionEnd();
    echo "Last ID inserted was: " . $db->GetLastInsertID() . "<br /><br />\n";
} else {
Exemplo n.º 5
0
 if (!$db->Query($fullquery)) {
     $db->Kill($db->Error());
 }
 $nbrlocalreq = $db->RowCount();
 while (!$db->EndOfSeek()) {
     $row = $db->Row();
     $dbd->Query($row->req);
 }
 $db->Query("update temprequet set stat=1 where stat=0");
 // ---------------------------------------------------
 // Execute Remote requete on locoal server
 // ---------------------------------------------------
 global $db;
 $fullquery = "SELECT req,id from temprequet where stat=0 ";
 if (!$dbd->Query($fullquery)) {
     $dbd->Kill($dbd->Error());
 }
 $nbrremotreq = $dbd->RowCount();
 while (!$dbd->EndOfSeek()) {
     $row = $dbd->Row();
     if (!$db->Query($row->req)) {
         $db->Kill($db->Error());
     } else {
         $dbd->Query("update temprequet set stat=1 where id=" . $row->id);
     }
 }
 // ---------------------------------------------------
 // Insert log Last update
 // ---------------------------------------------------
 $nbrreq = $nbrlocalreq + $nbrremotreq;
 $lastmaj = "Insert into maj_sys(nbrreq,user)values({$nbrreq}," . $_SESSION['userid'] . ")";
Exemplo n.º 6
0
Twig_Autoloader::register();
$loader = new Twig_Loader_Filesystem($APP_DIR . "/template");
if ($config->twig_cache) {
    $twig = new Twig_Environment($loader, array('debug' => $config->twig_debug, 'cache' => $APP_DIR . "/cache/" . $env));
} else {
    $twig = new Twig_Environment($loader, array('debug' => $config->twig_debug, 'cache' => ""));
}
//load extentions
$twig->addExtension(new Twig_Extension_User());
// BootStrap framework object
$cms = new bootstrap();
// Database framework object
$db = new MySQL();
if (!$db->Open($config->db_name, $config->db_host, $config->db_user, $config->db_pass)) {
    echo "There was a error connecting to the database of ssa, please try again later.";
    @$db->Kill();
}
$db->ThrowExceptions = true;
// User object
$user = new user();
//Set error settings
if ($config->debug) {
    error_reporting(-1);
    ini_set('display_errors', '1');
} else {
    error_reporting(0);
    ini_set('display_errors', '0');
}
// Stop loading stuff below, because its media
if (strpos((string) $_SERVER['REQUEST_URI'], "media/")) {
    $file = $APP_DIR . "/public" . $_SERVER['REQUEST_URI'];
Exemplo n.º 7
0
/** bảng danh sách thành viên */
function user_show_data($user_group, $perpage)
{
    $hmdb = new MySQL(true, DB_NAME, DB_HOST, DB_USER, DB_PASSWORD, DB_CHARSET);
    hook_action('user_show_data');
    $request_paged = hm_get('paged', 1);
    $paged = $request_paged - 1;
    $offset = $paged * $perpage;
    $limit = "LIMIT {$perpage} OFFSET {$offset}";
    if (!$hmdb->Query("SELECT * FROM " . DB_PREFIX . "users WHERE `user_group` = '{$user_group}' ORDER BY id DESC {$limit}")) {
        $hmdb->Kill();
    }
    if ($hmdb->HasRecords()) {
        /* Trả về các user */
        while ($row = $hmdb->Row()) {
            $array_use[] = array('id' => $row->id, 'user_nicename' => $row->user_nicename, 'user_role' => user_role_id_to_nicename($row->user_role));
        }
        $array['user'] = $array_use;
        /* Tạo pagination */
        $hmdb->Query(" SELECT * FROM " . DB_PREFIX . "users WHERE `user_group` = '{$user_group}' ");
        $total_item = $hmdb->RowCount();
        $total_page = ceil($total_item / $perpage);
        $first = '1';
        if ($request_paged > 1) {
            $previous = $request_paged - 1;
        } else {
            $previous = $first;
        }
        if ($request_paged < $total_page) {
            $next = $request_paged + 1;
        } else {
            $next = $total_page;
        }
        $array['pagination'] = array('first' => $first, 'previous' => $previous, 'next' => $next, 'last' => $total_page, 'total' => $total_item, 'paged' => $request_paged);
    } else {
        $array['user'] = array();
        $array['pagination'] = array();
    }
    return hook_filter('user_show_data', json_encode($array, TRUE));
}
function content_show_data($key, $status, $perpage)
{
    global $hmcontent;
    $hmdb = new MySQL(true, DB_NAME, DB_HOST, DB_USER, DB_PASSWORD, DB_CHARSET);
    hook_action('content_show_data');
    $request_paged = hm_get('paged', 1);
    $paged = $request_paged - 1;
    $offset = $paged * $perpage;
    $limit = "LIMIT {$perpage} OFFSET {$offset}";
    if (!$hmdb->Query("SELECT * FROM " . DB_PREFIX . "content WHERE `key` = '{$key}' AND status = '{$status}' ORDER BY id DESC {$limit}")) {
        $hmdb->Kill();
    }
    if ($hmdb->HasRecords()) {
        /* Trả về các content */
        while ($row = $hmdb->Row()) {
            $array_con[] = array('id' => $row->id, 'name' => $row->name, 'slug' => $row->slug);
        }
        $array['content'] = $array_con;
        /* Tạo pagination */
        $hmdb->Query(" SELECT * FROM " . DB_PREFIX . "content WHERE `key` = '{$key}' AND status = '{$status}' ");
        $total_item = $hmdb->RowCount();
        $total_page = ceil($total_item / $perpage);
        $first = '1';
        if ($request_paged > 1) {
            $previous = $request_paged - 1;
        } else {
            $previous = $first;
        }
        if ($request_paged < $total_page) {
            $next = $request_paged + 1;
        } else {
            $next = $total_page;
        }
        $array['pagination'] = array('first' => $first, 'previous' => $previous, 'next' => $next, 'last' => $total_page, 'total' => $total_item, 'paged' => $request_paged);
        $all_content = $hmcontent->hmcontent;
        if (isset($all_content[$key]['chapter']) and $all_content[$key]['chapter'] == TRUE) {
            $array['chapter'] = TRUE;
        } else {
            $array['chapter'] = FALSE;
        }
    } else {
        $array['content'] = array();
        $array['pagination'] = array();
        $array['chapter'] = FALSE;
    }
    return hook_filter('content_show_data', json_encode($array, TRUE));
}
Exemplo n.º 9
0
            $kga['server_password'] = $server_ext_password[$dbnr];
        }
        if ($server_ext_prefix[$dbnr] != '') {
            $kga['server_prefix'] = $server_ext_prefix[$dbnr];
        }
    }
} else {
    if (isset($_COOKIE['kimai_db']) && $_COOKIE['kimai_db'] == true) {
        $dbnr = $_COOKIE['kimai_db'] - 1;
        $kga['server_database'] = $server_ext_database[$dbnr];
        if ($server_ext_username[$dbnr] != '') {
            $kga['server_username'] = $server_ext_username[$dbnr];
        }
        if ($server_ext_password[$dbnr] != '') {
            $kga['server_password'] = $server_ext_password[$dbnr];
        }
        if ($server_ext_prefix[$dbnr] != '') {
            $kga['server_prefix'] = $server_ext_prefix[$dbnr];
        }
    }
}
// ===========================================================================
include WEBROOT . "libraries/mysql.class.php";
if (isset($utf8) && $utf8) {
    $conn = new MySQL(true, $kga['server_database'], $kga['server_hostname'], $kga['server_username'], $kga['server_password'], "utf-8");
} else {
    $conn = new MySQL(true, $kga['server_database'], $kga['server_hostname'], $kga['server_username'], $kga['server_password']);
}
if ($conn->Error()) {
    $conn->Kill();
}
Exemplo n.º 10
0
    $where .= " ( employee_name LIKE '" . $params['search']['value'] . "%' ";
    $where .= " OR employee_salary LIKE '" . $params['search']['value'] . "%' ";
    $where .= " OR employee_age LIKE '" . $params['search']['value'] . "%' )";
}
// getting total number records without any search
$sql = "SELECT * FROM `employee` ";
$sqlTot .= $sql;
$sqlRec .= $sql;
//concatenate search sql if value exist
if (isset($where) && $where != '') {
    $sqlTot .= $where;
    $sqlRec .= $where;
}
$sqlRec .= " ORDER BY " . $columns[$params['order'][0]['column']] . "   " . $params['order'][0]['dir'] . "  LIMIT " . $params['start'] . " ," . $params['length'] . " ";
if (!$db->Query($sqlTot)) {
    $db->Kill($db->Error());
}
//$queryTot = mysqli_query($conn, $sqlTot) or die("database error:". mysqli_error($conn));
$totalRecords = $db->RowCount();
//$totalRecords = mysqli_num_rows($queryTot);
if (!$db->Query($sqlRec)) {
    $db->Kill($db->Error());
}
//$queryRecords = mysqli_query($conn, $sqlRec) or die("error to fetch employees data");
//iterate on results row and create new index array of data
while (!$db->EndOfSeek()) {
    $row = $db->RowValue();
    $data[] = $row;
}
//while( $row = mysqli_fetch_row($queryRecords) ) {
//$data[] = $row;
Exemplo n.º 11
0
<?php

/** 
 * Xử lý kết nối database
 * Vị trí : hm_include/database.php 
 */
if (!defined('BASEPATH')) {
    exit('403');
}
/**
 * Gọi thư viện mysql
 */
require_once BASEPATH . HM_INC . '/database/mysql.php';
/**
 * Kết nối mysql
 */
$hmdb = new MySQL(true, DB_NAME, DB_HOST, DB_USER, DB_PASSWORD, DB_CHARSET);
if (!$hmdb->IsConnected()) {
    exit('Không thể kết nối đến cơ sở dữ liệu');
} else {
    if ($hmdb->Error()) {
        exit($hmdb->Kill());
    }
    $hmdb->Query('SET NAMES "UTF8"');
}
Exemplo n.º 12
0
}
// blow away $cfg['language'] to ensure the language file(s) are loaded this time - it's our first anyhow.
unset($cfg['language']);
$language = SetUpLanguageAndLocale($language);
// SECURITY ==
// Include security file only for administration directory
$location = explode("/", $_SERVER['PHP_SELF']);
$php_src_is_admin_code = in_array("admin", $location);
if ($php_src_is_admin_code) {
    /*MARKER*/
    require_once BASE_PATH . '/admin/includes/security.inc.php';
}
// DATABASE ==
// All set! Now this statement will connect to the database
if (!$db->Open($cfg['db_name'], $cfg['db_host'], $cfg['db_user'], $cfg['db_pass'])) {
    $db->Kill($ccms['lang']['system']['error_database']);
}
// ENVIRONMENT ==
// Some variables to help this file orientate on its environment
$current = basename(filterParam4FullFilePath($_SERVER['REQUEST_URI']));
// [i_a] $curr_page was identical (enough) to $pagereq before
$pagereq = checkSpecialPageName(getGETparam4Filename('page'), SPG_GIVE_PAGENAME);
$ccms['pagereq'] = $pagereq;
$ccms['printing'] = getGETparam4boolYN('printing', 'N');
$preview = getGETparam4IdOrNumber('preview');
// in fact, it's a hash plus ID!
$preview = IsValidPreviewCode($preview);
$ccms['preview'] = $preview ? 'Y' : 'N';
//$ccms['responsecode'] = null; // default: 200 : OK
//$ccms['page_id'] = false;
//$ccms['page_name'] = false;