IsConnected() public method

Determines if a valid connection to the database exists
public IsConnected ( ) : boolean
return boolean TRUE idf connectect or FALSE if not connected
Ejemplo n.º 1
0
 /**
  * @return bool
  */
 public function isConnected()
 {
     return $this->conn->IsConnected();
 }
Ejemplo n.º 2
0
<?php

// Include the Ultimate MySQL class and create the object
include "mysql.class.php";
$db = new MySQL();
// Connect to the database
// CHANGE THESE VALUES TO MATCH YOUR DATABASE!
if (!$db->Open(true, "test", "localhost", "root", "password")) {
    $db->Kill();
}
// --------------------------------------------------------------------------
// Want to know if you are connected? Use IsConnected()
echo "Are we connected? ";
var_dump($db->IsConnected());
echo "\n<br />\n";
// --------------------------------------------------------------------------
// Now we can generate SQL statements from arrays!
// Let's create an array for the examples
// $arrayVariable["column name"] = formatted SQL value
$values["Name"] = MySQL::SQLValue("Violet");
$values["Age"] = MySQL::SQLValue(777, MySQL::SQLVALUE_NUMBER);
// Echo out some SQL statements
echo "<pre>" . "\n";
echo MySQL::BuildSQLDelete("Test", $values) . "\n<br />\n";
echo MySQL::BuildSQLInsert("Test", $values) . "\n<br />\n";
echo MySQL::BuildSQLSelect("Test", $values) . "\n<br />\n";
echo MySQL::BuildSQLUpdate("Test", $values, $values) . "\n<br />\n";
echo MySQL::BuildSQLWhereClause($values) . "\n<br />\n";
echo "</pre>" . "\n";
// Or create more advanced SQL SELECT statements
$columns = array("Name", "Age");
Ejemplo n.º 3
0
                $useDatabases[] = $row[0];
            }
        }
    } catch (Exception $ex) {
        // we cannot always detect if we can read read databases, see https://github.com/kimai/kimai/issues/492
        // no need for error handling, user will see an input field for the database name
    }
}
if (count($useDatabases) == 0) {
    if ($lang == 'de') {
        echo 'Keine Datenbank(en) vorhanden oder keine Berechtigung um Datenbanken aufzulisten. Name der zu verwendenden Datenbank:<br/>';
    } else {
        echo 'No database(s) found or no permission to list databases. Name of the database to use:<br/>';
    }
    echo '<input type="text" id="db_names" value="' . htmlspecialchars($database) . '"/>';
    if ($database !== '' && $create_database === '' && !$con->IsConnected()) {
        $errors = true;
        if ($lang == 'de') {
            echo '<strong id="db_select_label" class="arrow">Diese Datenbank konnte nicht geöffnet werden.</strong>';
        } else {
            echo '<strong id="db_select_label" class="arrow">Unable to open that database.</strong>';
        }
    } else {
        echo '<strong id="db_select_label"></strong>';
    }
    echo '<br/><br/>';
} else {
    // if there are databases build selectbox
    if ($lang == 'de') {
        echo 'Bitte wählen Sie eine Datenbank:';
    } else {
Ejemplo n.º 4
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"');
}