当前位置: 首页>>代码示例>>PHP>>正文


PHP BD::conn方法代码示例

本文整理汇总了PHP中BD::conn方法的典型用法代码示例。如果您正苦于以下问题:PHP BD::conn方法的具体用法?PHP BD::conn怎么用?PHP BD::conn使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在BD的用法示例。


在下文中一共展示了BD::conn方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: conn

 public function conn()
 {
     if (is_null(self::$conn)) {
         self::$conn = new PDO('mysql:host=' . HOST . ';dbname=' . BD . '', '' . USER . '', '' . PASS . '');
     }
     return self::$conn;
 }
开发者ID:eduardosilvapereira,项目名称:mcja,代码行数:7,代码来源:BD.class.php

示例2: getConn

 public static function getConn()
 {
     if (is_null(self::$conn)) {
         self::$conn = new PDO(DSN, USER, PASS);
     }
     return self::$conn;
 }
开发者ID:n2dev,项目名称:controles,代码行数:7,代码来源:BD.class.php

示例3: mysqli

 function __construct($s = '127.0.0.1', $u = 'root', $p = '', $b = '')
 {
     if (empty(self::$conn)) {
         self::$conn = new mysqli($s, $u, $p);
         self::$conn->query("SET NAMES 'utf8'");
     }
     if (!empty($b)) {
         $this->base = self::$conn->select_db($b) ? $b : null;
     } else {
         $resp = $this->consulta('select database()');
         $resp = $resp->fetch_row();
         $this->base = $resp[0];
     }
 }
开发者ID:oscargalileo,项目名称:liga3,代码行数:14,代码来源:BD.php

示例4: foreach

            foreach ($ids as $indice => $id) {
                $selecionar = BD::conn()->prepare("SELECT * FROM `mensagens` WHERE id_de = ? AND id_para = ? OR id_de = ? AND id_para = ?");
                $selecionar->execute(array($_SESSION['usuario_id'], $id, $id, $_SESSION['usuario_id']));
                $mensagem = '';
                while ($ft = $selecionar->fetchObject()) {
                    $nome = BD::conn()->prepare("SELECT nome FROM `usuario` WHERE usuario_id = ?");
                    $nome->execute(array($ft->id_de));
                    $name = $nome->fetchObject();
                    $mensagem .= '<li><span>' . $name->nome . ' disse:</span><p>' . $ft->mensagem . '</p></li>';
                }
                $retorno['mensagens'][$id] = $mensagem;
            }
        }
        $verificar = BD::conn()->prepare("SELECT id_de FROM `mensagens` WHERE id_para = ? AND lido = ? GROUP BY id_de");
        $verificar->execute(array($_SESSION['usuario_id'], 0));
        if ($verificar->rowCount() == 0) {
            $retorno['nao_lidos'] == '';
        } else {
            while ($user = $verificar->fetchObject()) {
                $retorno['nao_lidos'][] = $user->id_de;
            }
        }
        $retorno = json_encode($retorno);
        echo $retorno;
        break;
    case 'mudar_status':
        $user = $_POST['user'];
        $mudar_st = BD::conn()->prepare("UPDATE `mensagens` SET lido = '1' WHERE id_de = ? AND id_para = ?");
        $mudar_st->execute(array($user, $_SESSION['usuario_id']));
        break;
}
开发者ID:eduardosilvapereira,项目名称:mcja,代码行数:31,代码来源:chat.php

示例5: strip_tags

	div#formulario input[type=text]{padding:5px; width:485px; border:1px solid #ccc; outline:none; font:16px tahoma, arial;
	color:#666;}
	div#formulario input[type=text]:focus{border-color:#036;}
	div#formulario input[type=submit]{padding:4px 6px; background:#069; font:15px tahoma, arial; color:#fff; border:1px solid #036;
	float:left; margin-top:5px; text-align:center; width:95px; text-shadow:#000 0 1px 0;}
	div#formulario input[type=submit]:hover{cursor:pointer; background:#09f;}
</style>
</head>

<body>
<?php 
if (isset($_POST['acao']) && $_POST['acao'] == 'logar') {
    $email = strip_tags(filter_input(INPUT_POST, 'email', FILTER_SANITIZE_STRING));
    if ($email == '') {
    } else {
        $pegar_user = BD::conn()->prepare("SELECT id FROM `usuarios` WHERE email = ?");
        $pegar_user->execute(array($email));
        if ($pegar_user->rowCount() == 0) {
            echo '<script>alert("usuario nao encontrado")</script>';
        } else {
            $fetch = $pegar_user->fetchObject();
            $_SESSION['id_user'] = $fetch->id;
            echo '<script>alert("Login efetuado");location.href="chat.php"</script>';
        }
    }
}
?>
	<div id="formulario">
	<span>Digite seu e-mail</span>
		<form action="" method="post" enctype="multipart/form-data">
			<label>
开发者ID:eduardosilvapereira,项目名称:mcja,代码行数:31,代码来源:old_index.php

示例6: array

                $verifica->execute();
                $resultados = $verifica->rowCount();
                $tempoGasto += 1;
            }
        }
    }
    $novasMensagens = array();
    if ($resultados >= 1) {
        $emotions = array(':)', ':@', '8)', ':D', ':3', ':(', ';)');
        $imgs = array('<img src="emotions/nice.png" width="14"/>', '<img src="emotions/angry.png" width="14"/>', '<img src="emotions/cool.png" width="14"/>', '<img src="emotions/happy.png" width="14"/>', '<img src="emotions/ooh.png" width="14"/>', '<img src="emotions/sad.png" width="14"/>', '<img src="emotions/right.png" width="14"/>');
        while ($row = $verifica->fetch()) {
            $fotoUser = '';
            $janela_de = 0;
            if ($userOnline == $row['id_de']) {
                $janela_de = $row['id_para'];
            } elseif ($userOnline == $row['id_para']) {
                $janela_de = $row['id_de'];
                $pegaUsr = BD::conn()->prepare("SELECT `foto` FROM `usuarios` WHERE `id` = '{$row['id_de']}'");
                $pegaUsr->execute();
                while ($usr = $pegaUsr->fetch()) {
                    $fotoUser = $usr['foto'] == '' ? 'default.jpg' : $usr['foto'];
                }
            }
            $msg = str_replace($emotions, $imgs, $row['mensagem']);
            $novasMensagens[] = array('id' => $row['id'], 'mensagem' => utf8_encode($msg), 'fotoUser' => $fotoUser, 'id_de' => $row['id_de'], 'id_para' => $row['id_para'], 'janela_de' => $janela_de);
        }
    }
    $ultimaMsg = end($novasMensagens);
    $ultimoId = $ultimaMsg['id'];
    die(json_encode(array('status' => 'resultados', 'timestamp' => time(), 'lastid' => $ultimoId, 'dados' => $novasMensagens, 'users' => $usersOn)));
}
开发者ID:CodAssmann,项目名称:chat2.0,代码行数:31,代码来源:stream.php

示例7: while

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Bem vindo ao chat</title>
<link href="css/style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="js/jquery.js"></script>
<script type="text/javascript" src="js/functions.js"></script>
<script type="text/javascript" src="js/chat.js"></script>
</head>

<body>
<div id="contatos">
	<ul>
	<?php 
$selecionar_usuarios = BD::conn()->prepare("SELECT * FROM `usuario` WHERE usuario_id != ?");
$selecionar_usuarios->execute(array($_SESSION['usuario_id']));
if ($selecionar_usuarios->rowCount() == 0) {
    echo '<p>Desculpe, não há contatos ainda!</p>';
} else {
    while ($usuario = $selecionar_usuarios->fetchObject()) {
        ?>
		<li><a href="javascript:void(0);" nome="<?php 
        echo $usuario->nome;
        ?>
" id="<?php 
        echo $usuario->usuario_id;
        ?>
" class="comecar"><?php 
        echo $usuario->nome;
        ?>
开发者ID:eduardosilvapereira,项目名称:mcja,代码行数:31,代码来源:chat.php

示例8:

<?php

if (isset($_POST['ler'])) {
    include_once "../defines.php";
    require_once '../classes/BD.class.php';
    BD::conn();
    $online = (int) $_POST['online'];
    $user = (int) $_POST['user'];
    $upd = BD::conn()->prepare("UPDATE `mensagens` SET `lido` = 1 WHERE `id_de` = ? AND `id_para` = ?");
    if ($upd->execute(array($user, $online))) {
        echo 'ok';
    }
}
开发者ID:CodAssmann,项目名称:chat2.0,代码行数:13,代码来源:ler.php

示例9: strip_tags

		<div class="formulario">
			<h1>Bem vindo ao chat, faça login</h1>
			<?php 
if (isset($_POST['acao']) && $_POST['acao'] == 'logar') {
    $email = strip_tags(trim(filter_input(INPUT_POST, 'email', FILTER_SANITIZE_STRING)));
    if ($email == '') {
        echo 'informe o email';
    } else {
        $pegaUser = BD::conn()->prepare("SELECT * FROM `usuarios` WHERE `email` = ?");
        $pegaUser->execute(array($email));
        if ($pegaUser->rowCount() == 0) {
            echo 'Não encontramos este login!';
        } else {
            $agora = date('Y-m-d H:i:s');
            $limite = date('Y-m-d H:i:s', strtotime('+2 min'));
            $update = BD::conn()->prepare("UPDATE `usuarios` SET `horario` = ?, `limite` = ? WHERE `email` = ?");
            if ($update->execute(array($agora, $limite, $email))) {
                while ($row = $pegaUser->fetchObject()) {
                    $_SESSION['email_logado'] = $email;
                    $_SESSION['id_user'] = $row->id;
                    header("Location: chat.php");
                }
            }
            //se atualizou
        }
    }
}
?>
			<form action="" method="post" enctype="multipart/form-data">
				<label>
					<span>Informe seu e-mail</span>
开发者ID:CodAssmann,项目名称:chat2.0,代码行数:31,代码来源:index.php

示例10: while

$pegadesBloqueados = BD::conn()->prepare("SELECT * FROM `usuarios` WHERE `id` != ?");
$pegadesBloqueados->execute(array($_SESSION['id_user']));
while ($desbloqueado = $pegadesBloqueados->fetch()) {
    if (!in_array($desbloqueado['id'], $arrayBloqueados)) {
        echo '<input type="checkbox" name="bloquear[]" value="' . $desbloqueado['id'] . '" /> ' . utf8_encode($desbloqueado['nome']) . '<br />';
    }
}
?>
			<input type="hidden" name="acao" value="block" />
			<input type="submit" value="Bloquear" />
		</form>

		<aside id="users_online">
			<ul>
			<?php 
$pegaUsuarios = BD::conn()->prepare("SELECT * FROM `usuarios` WHERE `id` != ?");
$pegaUsuarios->execute(array($_SESSION['id_user']));
while ($row = $pegaUsuarios->fetch()) {
    $foto = $row['foto'] == '' ? 'default.jpg' : $row['foto'];
    $blocks = explode(',', $row['blocks']);
    $agora = date('Y-m-d H:i:s');
    if (!in_array($_SESSION['id_user'], $blocks)) {
        $status = 'on';
        if ($agora >= $row['limite']) {
            $status = 'off';
        }
        ?>
				<li id="<?php 
        echo $row['id'];
        ?>
">
开发者ID:CodAssmann,项目名称:chat2.0,代码行数:31,代码来源:chat.php

示例11: utf8_decode

<?php

if (isset($_POST['mensagem'])) {
    include_once "../defines.php";
    require_once '../classes/BD.class.php';
    BD::conn();
    $mensagem = utf8_decode(strip_tags(trim(filter_input(INPUT_POST, 'mensagem', FILTER_SANITIZE_STRING))));
    $de = (int) $_POST['de'];
    $para = (int) $_POST['para'];
    if ($mensagem != '') {
        $insert = BD::conn()->prepare("INSERT INTO `mensagens` (id_de, id_para, mensagem, time, lido) VALUES (?,?,?,?,?)");
        $arrayInsert = array($de, $para, $mensagem, time(), 0);
        if ($insert->execute($arrayInsert)) {
            echo 'ok';
        } else {
            echo 'no';
        }
    }
}
开发者ID:CodAssmann,项目名称:chat2.0,代码行数:19,代码来源:submit.php


注:本文中的BD::conn方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。