Error() public method

Returns the last MySQL error as text
public Error ( ) : string
return string Error text from last known error
Beispiel #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();
 }
Beispiel #2
0
 /**
  * @see Element
  */
 function __construct($id = null, $params = "*", $key_name = null, $table_name = null, $md5 = false)
 {
     global $db;
     $this->querybuilder = new QueryBuilder();
     //print_r($this->querybuilder);
     $this->return = array();
     if (!is_null($key_name)) {
         $this->key = $key_name;
     }
     if (!is_null($table_name)) {
         $this->table = $table_name;
     }
     $this->return["success"] = false;
     $db = new MySQL(true, "test", "localhost", "root", "");
     //$db = new MySQL(true,DB_HOST,DB_NAME,DB_PASSWORD,DB_USER);
     if ($db->Error()) {
         $this->return["message"] = "Errore";
     }
     if ($id == null && $params != "*") {
         $this->create($params);
     } else {
         $this->updateParams($id, $params, $md5);
     }
 }
Beispiel #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");
}
Beispiel #4
0
$tables = $db->GetTables();
foreach ($tables as $table) {
    echo $table . "<br />\n";
}
// --- Show the columns (field names) in a table --------------------
$columns = $db->GetColumnNames("test");
foreach ($columns as $column) {
    echo $column . "<br />\n";
}
// --- Find a column (field) type and length ------------------------
echo "Type: " . $db->GetColumnDataType("Color", "Test") . "<br />\n";
echo "Length: " . $db->GetColumnLength("Color", "Test") . "<br />\n";
// --- Get a column's ordinal position (the column number) ----------
echo $db->GetColumnID("Age", "Test") . "<br />\n";
// --- Check for errors ---------------------------------------------
if ($db->Error()) {
    echo "<h3>" . $db->Error() . "</h3>\n";
} else {
    echo "<p>There were no errors</p>\n";
}
// --- Format some values ready for SQL -----------------------------
// You do not have to create the object to use these. Simply include
// the class in your PHP file. These are called "Static" methods.
echo "<br /><br />\n\n";
echo MySQL::SQLValue("Let's format some text") . "<br />\n";
echo MySQL::SQLValue(date("m/d/Y"), MySQL::SQLVALUE_DATE) . "<br />\n";
echo MySQL::SQLValue(123, MySQL::SQLVALUE_NUMBER) . "<br />\n";
// --- Format some values ready for SQL based on a boolean value ----
echo MySQL::SQLBooleanValue(false, "1", "0", MySQL::SQLVALUE_NUMBER);
echo MySQL::SQLBooleanValue("ON", "Ya", "Nope");
echo MySQL::SQLBooleanValue(1, '+', '-');
Beispiel #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'] . ")";
Beispiel #6
0
<?php

include "../user/config.php";
include "../core/includes/class/mysql.class.php";
$db = new MySQL(false, $sql_dbname, $sql_host, $sql_user, $sql_pass, $sql_charset, $sql_pcon);
$db->Open();
$result = $db->Query("CREATE TABLE IF NOT EXISTS `ac_global` (\n\t\t`player_identifier` int(11) NOT NULL AUTO_INCREMENT,\n\t\t`player_auth` varchar(36) COLLATE utf8_unicode_ci NOT NULL,\n\t\t`total_tokens` int(11) NOT NULL,\n\t\t`name` varchar(32) COLLATE utf8_unicode_ci NOT NULL,\n\t\tPRIMARY KEY (`player_identifier`),\n\t\tUNIQUE KEY `player_auth` (`player_auth`)\n\t) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;");
if (!$result) {
    die("MySQL: " . $db->Error() . "");
}
foreach ($servers as $k => $unimportant) {
    $result = $db->Query("CREATE TABLE IF NOT EXISTS `ac_{$k}_list` (\n\t\t\t`id` int(11) NOT NULL AUTO_INCREMENT,\n\t\t\t`name` varchar(64) NOT NULL,\n\t\t\t`desc` varchar(256) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,\n\t\t\t`value_id` varchar(32) NOT NULL,\n\t\t\t`icon` varchar(256) NOT NULL,\n\t\t\t`available` int(11) NOT NULL DEFAULT '1',\n\t\t\t`value` int(11) NOT NULL DEFAULT '0',\n\t\t\t`tokens` int(11) NOT NULL DEFAULT '0',\n\t\t\t`max` int(11) NOT NULL DEFAULT '0',\n\t\t\t`created` int(11) NOT NULL DEFAULT '0',\n\t\t\t`cat` int(11) NOT NULL DEFAULT '0',\n\t\t\tPRIMARY KEY (`id`),\n\t\t\tUNIQUE KEY `id` (`id`)\n\t\t) ENGINE=MyISAM  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;");
    if (!$result) {
        die("There was an error processing the SQL query. Check if any of the server shorts in config file are incorrect. Only alphanumeric values are allowed.");
    }
    $result = $db->Query("CREATE TABLE IF NOT EXISTS `ac_{$k}_data` (\n\t\t\t `player_auth` varchar(64) COLLATE utf8_unicode_ci NOT NULL,\n\t\t\t\t`value_id` varchar(32) CHARACTER SET latin1 NOT NULL,\n\t\t\t\t`value_status` int(11) NOT NULL,\n\t\t\t\t`value_extra` int(11) NOT NULL,\n\t\t\t\tPRIMARY KEY (`player_auth`,`value_id`),\n\t\t\t\tKEY `player_auth` (`player_auth`)\n\t\t) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;");
    if (!$result) {
        die("There was an error processing the SQL query. Check if any of the server shorts in config file are incorrect. Only alphanumeric values are allowed.");
    }
    $result = $db->Query("CREATE TABLE IF NOT EXISTS `ac_{$k}_cats` (\n\t\t\t`cat_id` int(11) NOT NULL AUTO_INCREMENT,\n\t\t\t`cat_name` varchar(32) NOT NULL,\n\t\t\tPRIMARY KEY (`cat_id`),\n\t\t\tUNIQUE KEY `cat_id` (`cat_id`)\n\t\t) ENGINE=InnoDB  DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;");
    if (!$result) {
        die("There was an error processing the SQL query. Check if any of the server shorts in config file are incorrect. Only alphanumeric values are allowed.");
    }
}
echo "All missing tables (if there were any) were successfully created.";
Beispiel #7
0
 /**
  * @param string $scope
  */
 private function logLastError($scope)
 {
     Kimai_Logger::logfile($scope . ': ' . $this->conn->Error());
 }
            $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();
}
 //
 // Installation actions
 //  - Set collected data
 //
 // Let's start with a clean sheet
 $err = 0;
 // Include MySQL class && initiate
 /*MARKER*/
 require_once BASE_PATH . '/lib/class/mysql.class.php';
 $db = new MySQL();
 //
 // Try database connection
 //
 if (!$db->Open(null, $_SESSION['variables']['db_host'], $_SESSION['variables']['db_user'], $_SESSION['variables']['db_pass'], 'utf8', 'utf8_unicode_ci')) {
     $errors[] = 'Error: could not connect to the database engine';
     $errors[] = $db->Error();
     $errors[] = $db->MyDyingMessage();
     $err++;
 } else {
     $log[] = "Database engine connection successful";
 }
 //
 // Either Select the database or create it when it does not exist yet
 //
 if (!$db->SelectDatabase($_SESSION['variables']['db_name'])) {
     if (!$db->CreateDatabase($_SESSION['variables']['db_name'])) {
         $errors[] = 'Error: could not create the database "' . $_SESSION['variables']['db_name'] . '"';
         $errors[] = $db->Error();
         $errors[] = $db->MyDyingMessage();
         $err++;
     } else {
Beispiel #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;
<?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"');
}
<?php

include "../user/config.php";
include "../core/includes/class/mysql.class.php";
$db = new MySQL(false, $sql_dbname, $sql_host, $sql_user, $sql_pass, $sql_charset, $sql_pcon);
$db->Open();
foreach ($servers as $k => $unimportant) {
    $result = $db->Query("ALTER IGNORE TABLE  `ac_{$k}_plrdata` ADD COLUMN  `plrid` INT NOT NULL AUTO_INCREMENT, ADD PRIMARY KEY (  `plrid` )");
    if ($result) {
        echo "Done adding column plrid to table ac_{$k}_plrdata.<br>";
    } else {
        echo "There was a problem adding column plrid to table ac_{$k}_plrdata. MySQL says: <i>";
        echo $db->Error();
        echo "</i><br>";
    }
}