本文整理汇总了PHP中Db::close方法的典型用法代码示例。如果您正苦于以下问题:PHP Db::close方法的具体用法?PHP Db::close怎么用?PHP Db::close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Db
的用法示例。
在下文中一共展示了Db::close方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: rollback
/**
* 回滚所有全局事务。同时关闭全局事务选项.
* @param string $dbname
*/
static function rollback($dbname = null)
{
if ($dbname) {
if (isset(Db::$txDbs[$dbname])) {
$db = Db::$txDbs[$dbname];
$db->rollback();
unset(TxScope::$txDbs[$dbname]);
unset(Db::$txDbs[$dbname]);
}
} else {
Db::close();
self::$tx = false;
}
}
示例2: disconnect
/**
* Disconnect from database
*/
public static function disconnect()
{
self::$engine->close();
self::$engine = null;
}
示例3: reset
public static function reset($db = null, $atAllCost = false)
{
Db::close($db);
Db::get($db, $atAllCost);
}
示例4: catch
} catch (Exception $e) {
print "<div style='background:#FFBBBB;border:1px solid red'>";
print "Test '{$test_name}' (FALLÓ) con mensaje: ({$e->getMessage()})";
print "</div>";
}
if ($test) {
$end_benckmark = microtime(true) - $start_benchmark;
print "<div style='background:#CCFF99;border:1px solid green'>";
print "Test '{$test_name}' (OK) con tiempo: ({$end_benckmark})";
print "</div>";
}
$test = true;
$test_name = "CERRAR LA CONEXION A LA BASE DE DATOS";
$start_benchmark = microtime(true);
try {
$value1 = $db->close();
if (!$value1) {
throw new DbException("No se puede cerrar la conexion (1)");
}
} catch (Exception $e) {
print "<div style='background:#FFBBBB;border:1px solid red'>";
print "Test '{$test_name}' (FALLÓ) con mensaje: ({$e->getMessage()})";
print "</div>";
}
if ($test) {
$end_benckmark = microtime(true) - $start_benchmark;
print "<div style='background:#CCFF99;border:1px solid green'>";
print "Test '{$test_name}' (OK) con tiempo: ({$end_benckmark})";
print "</div>";
}
print "<div style='background:#CCFF99;border:1px solid green'>";
示例5: define
<?php
define('DEBUG', true);
$root = realpath(dirname(__FILE__));
$urls = array('^/$' => 'Principal', '^/ingresar$' => 'Ingresar', '^/ingresar/amnesia$' => 'IngresarAmnesia', '^/personas$' => 'Personas', '^/personas/(\\d+)$' => 'PersonasVer', '^/personas/(\\d+)/editar$' => 'PersonasEditar', '^/empresas$' => 'Empresas', '^/empresas/agregar$' => 'EmpresasAgregar', '^/empresas/(\\d+)$' => 'EmpresasVer', '^/empresas/(\\d+)/editar$' => 'EmpresasEditar', '^/empresas/(\\d+)/personas$' => 'EmpresasPersonas', '^/empresas/(\\d+)/personas/agregar$' => 'EmpresasPersonasAgregar', '^/configuracion$' => 'Configuracion', '^/configuracion/apariencia$' => 'ConfiguracionApariencia', '^/salir$' => 'Salir');
include_once "{$root}/config.php";
if (DEBUG) {
error_reporting(E_ALL);
}
include_once "{$root}/lib/Request.php";
include_once "{$root}/lib/Response.php";
include_once "{$root}/lib/Web.php";
include_once "{$root}/lib/WebBase.php";
include_once "{$root}/lib/Cookies.php";
include_once "{$root}/lib/Validation.php";
include_once "{$root}/lib/String.php";
include_once "{$root}/lib/Lang.php";
include_once "{$root}/lib/Db.php";
include_once "{$root}/lib/Config.php";
include_once "{$root}/lib/Session.php";
Db::open($dbConfig);
Cookies::$prefix = 'EME_';
Session::start();
Web::errorRegister(404, 'Error404');
Web::dispatch($urls);
Db::close();
示例6: count
$end = (int) $_POST['txtSize'];
$len = count($characters);
$list = array();
for ($i = 1; $i < 1 << $len; $i++) {
$c = '';
for ($j = 0; $j < $len; $j++) {
if ($i & 1 << $j) {
$c .= $a[$j];
}
}
$list[] = $c;
}
print_r($list);
//$query = "INSERT INTO " . $_POST['txtTableName'] . " (PasswordValue) VALUES ('" . $value . "')";
//$link -> query($query);
Db::close($link);
}
?>
</form>
<script type="text/javascript">
$(document).ready(function(){
$('#txtTableName').focus();
});
</script>
示例7: Db
$Data->cat_id = "";
if (!is_null($Data->n_cat_id) && trim($Data->n_cat_id) != '') {
$ShinshaDB = new Db();
if ($ShinshaDB->connect(SHINSHA) == -1) {
$Logger->error("DBコネクションエラーです。SHINSHA");
_error(1);
exit;
}
$result = $ShinshaDB->query("SELECT cat_id FROM catalog_master WHERE cat_id = " . $Data->n_cat_id);
if ($result != -1) {
if (pg_num_rows($result) > 0) {
$Data->cat_id = $Data->n_cat_id;
}
pg_free_result($result);
}
$ShinshaDB->close();
}
$Zaiko->setZaikoData($Data);
// アイコンデータの取得(一文字づつに分解して、配列化)
$option_values_ary = array();
$length = strlen($Data->option_values);
for ($i = 0; $i < $length; $i++) {
$option_values_ary[$i] = substr($Data->option_values, $i, 1);
}
$Zaiko->setOptionValues($option_values_ary);
$a_option_values_web = array();
$length = strlen($Data->option_values_web);
for ($i = 0; $i < $length; $i++) {
$a_option_values_web[$i] = substr($Data->option_values_web, $i, 1);
}
$Zaiko->setOptionValuesWeb($a_option_values_web);
示例8: create_table
color:green;
}
</style>
</head>
<body>
<h2>Ejemplo de uso de la clase Db</h2>
<?php
$db = new Db();
$columns = array('ID', 'Name', 'CountryCode', 'Population');
$resul = $db->select($columns, 'world.city')->limit(10)->exe();
?>
<h3>Resultado con nombres de las columnas de las tablas</h3>
<?php
echo create_table($resul);
echo "<br>";
?>
<h3>Resultado con Alias para las columnas</h3>
<?php
$columns = array('ID', 'Name', 'CountryCode', 'Population');
$resul = $db->select($columns, 'world.city')->where('CountryCode', '=', 'AFG')->andd('Population', '>', '130000')->exe();
$alias = array('Id', 'Nombre', 'Código de país', 'Población');
echo create_table($resul, $alias);
echo "<br>";
$db->close();
?>
</body>
</html>
示例9: checkExist
/**
*
* @param Db $db
* @param int $foodid
*/
function checkExist(&$db, $foodid)
{
$sql = "select food_id from canteen_food where food_id={$foodid};";
$res = $db->query($sql);
if ($res !== false) {
if (!empty($res)) {
echo getJsonResponse(3, "食物已经存在", null);
$db->rollback();
//回滚
$db->close();
exit;
}
$sql2 = "select user_id from recommendedfood where user_id={$_POST['user_id']} and \n\t\t canteen_id={$_POST['canteen_id']} and food_id={$foodid};";
$res2 = $db->query($sql2);
if ($res2 !== false) {
if (!empty($res2)) {
echo getJsonResponse(4, "食物已经推荐给食堂", null);
$db->rollback();
//回滚
$db->close();
exit;
}
} else {
echo getJsonResponse(1, $db->error, null);
Log::error_log('database error:' . $db->error . ' in ' . basename(__FILE__));
$db->rollback();
$db->close();
exit;
}
} else {
echo getJsonResponse(1, $db->error, null);
Log::error_log('database error:' . $db->error . ' in ' . basename(__FILE__));
$db->rollback();
$db->close();
exit;
}
}