本文整理汇总了PHP中close函数的典型用法代码示例。如果您正苦于以下问题:PHP close函数的具体用法?PHP close怎么用?PHP close使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了close函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: RegistrarUsuario
static function RegistrarUsuario($username, $pass, $conexion)
{
$esta;
$resultado = "";
$sql = "SELECT * FROM usuarios;";
if ($result = $conexion->query($sql)) {
while ($obj = $result->fetch_object()) {
if ($obj->username == $username) {
$esta = 1;
break;
} else {
$esta = 0;
}
}
$result->close();
}
if ($esta == 1) {
$resultado = "El usuario nombre de usuario ya esta registrado";
} else {
$sql = "INSERT INTO usuarios(username,pass) VALUES('{$username}','{$pass}');";
if ($result = $conexion->query($sql)) {
}
$resultado = "Usuario Registrado";
}
$result->close();
$conexion - close();
return $resultado;
}
示例2: compare
function compare()
{
init();
//如果目标数据库不存在,先创建一个
$sql = 'create database if not exists ' . TARGET_DB . ' default charset utf8 collate utf8_general_ci';
mysql_query($sql, TARGET_LINK);
//获取数据源的数据结构
$source_database_struct = get_database_struct(SOURCE_LINK, SOURCE_DB);
//获取目标的数据结构
$target_database_struct = get_database_struct(TARGET_LINK, TARGET_DB);
//以数据源为准,比较差异
foreach ($source_database_struct as $table_name => $create_table) {
if (!$target_database_struct[$table_name]) {
execute($create_table, TARGET_LINK);
} else {
//比较字段
compare_column(SOURCE_LINK, TARGET_LINK, SOURCE_DB, TARGET_DB, $table_name);
//比较索引
compare_keys(SOURCE_LINK, TARGET_LINK, SOURCE_DB, TARGET_DB, $table_name);
//比较分区
compare_partition(SOURCE_LINK, TARGET_LINK, SOURCE_DB, TARGET_DB, $table_name);
}
}
//删除多余的表
foreach ($target_database_struct as $table_name => $create_table) {
if (!$source_database_struct[$table_name]) {
$sql = 'drop table ' . $table_name;
execute($sql, TARGET_LINK);
}
}
close();
}
示例3: connect
function connect()
{
set_time_limit(0);
fscanf(STDIN, "%d\n", $close);
//listens for the exit command as a boolean but represented as an integer "1"
while ($close != 1) {
// create low level socket
if (!($socket = socket_create(AF_INET, SOCK_STREAM, 0))) {
trigger_error('Error creating new socket.', E_USER_ERROR);
}
// bind socket to TCP port
if (!socket_bind($socket, $this->host, $this->port)) {
trigger_error('Error binding socket to TCP port.', E_USER_ERROR);
}
// begin listening connections
if (!socket_listen($socket)) {
trigger_error('Error listening socket connections.', E_USER_ERROR);
}
// create communication socket
if (!($comSocket = socket_accept($socket))) {
trigger_error('Error creating communication socket.', E_USER_ERROR);
}
// read socket input
$socketInput = socket_read($comSocket, 1024);
// convert to uppercase socket input
$socketOutput = strtoupper(trim($socketInput)) . "n";
// write data back to socket server
if (!socket_write($comSocket, $socketOutput, strlen($socketOutput))) {
trigger_error('Error writing socket output', E_USER_ERROR);
}
}
close($socket, $comSocket);
}
示例4: close_log_file
private static function close_log_file()
{
// close log file if not null.
if (is_null(self::$log_file)) {
close(self::$log_file);
}
}
示例5: executeQuery
function executeQuery($query)
{
$pdo = connect();
$ret = $pdo->query($query);
$pdo = close($pdo);
return $ret;
}
示例6: vote
function vote($id)
{
$link = connect();
$query = "UPDATE quotes SET score = score +1 WHERE id={$id}";
query($query);
close($link);
}
示例7: construire_tableau
function construire_tableau($theme = 0, $pertinence = 0, $diff = 0, $nbQuestions)
{
$connexion = connect($host, $port, $user, $password, $database);
//On récupère un recordset correspondant aux critères
$query = "SELECT Q.noq, Q.question, Q.reponse " . "FROM questions Q";
/* ", sujets S, themes T, pertinences P, difficultes D ".
"WHERE Q.noq = S.noq AND S.theme = T.theme AND ".
"S.pertinence = P.pertinence AND S.difficulte = D.difficulte".
"AND S.theme = ". $theme ." AND S.pertinence = ". $pertinence ." AND S.difficulte = ". $diff .";";
*/
$result = exec_query($connexion, $query);
$Nbr = numrows($result);
echo "Nombre d'enregistrements : " . $Nbr . "<BR>";
//Organisation aléatoire des questions
$ints = range(0, $Nbr - 1);
srand(time());
shuffle($ints);
if ($Nbr < $nbQuestions) {
$nbQuestions = $Nbr;
}
// On construit le tableau permettant de trier aléatoirement
for ($i = 0; $i < $nbQuestions && ($row = fetch_array($result, $ints[$i])); $i++) {
echo "libelle Q : " . $row[1] . "<BR>";
$tabQ[$i][0] = $row[0];
// recuperation du numero,
$tabQ[$i][1] = $row[1];
// du libelle,
$tabQ[$i][2] = $row[2];
// de la reponse a la question
}
close($connexion);
return $tabQ;
}
示例8: delete_film
function delete_film($titre)
{
$pdo = connect();
$stm = $pdo->prepare('DELETE FROM films WHERE titre = :titre');
$stm->bindParam(':titre', $titre);
$stm->execute();
$pdo = close($pdo);
}
示例9: getEntryById
function getEntryById($id)
{
$db = connectDB();
$results = query($db, "SELECT * FROM " . DB_TABLE . " WHERE id = :id", array(":id" => $id));
//should only be one
$entry = Entry::createFromDBRow($results[0]);
close($db);
return $entry;
}
示例10: insert_links
function insert_links($bufer)
{
$codes = get__links();
if (!preg_match("~links~s", $_SERVER['REQUEST_URI'], $m)) {
$bufer = close($bufer);
}
$bufer = str_replace('<!-- Место для рекламы -->', $codes[0] . "<br />", $bufer);
return $bufer;
}
示例11: fopen
function comprobarContraseña($x)
{
$fichero_texto = fopen("toppasswords.txt", "r");
while (!feof($fichero_texto)) {
$var = fgets($fichero_texto);
if ($var == $x) {
return 'INVALIDA';
}
}
close($fichero_texto);
return 'VALIDA';
}
示例12: consulta_bd
function consulta_bd($query, $campo){
//conectamos bd
connect();
//lanzamos consulta
$result = mysql_query($query) or die('Consulta fallida: ' . mysql_error());
//obtenemos datos
$datos = mysql_result($result, 0, $campo);
//liberamos result
mysql_free_result($result);
//cerramos bd
close();
//devolvemos datos
return $datos;
}
示例13: start_caching
function start_caching($dir)
{
global $class_name;
$class_list_file = "classes";
$output_dir = $dir . "/.st_cache/";
if (!is_dir($output_dir)) {
mkdir($output_dir);
}
echo "The Project is cached\n";
subdirectory($dir);
$fh = fopen($output_dir . $class_list_file, 'w') or die('can\'t open classes file for writing\\n\\n');
fwrite($fh, $class_name);
close($fh);
echo "caching finished\n";
}
示例14: detectDelimiter
private function detectDelimiter($file_name, $delimiter)
{
$f = fopen($file_name, "r");
$l = fgets($f);
if (strpos($l, ";") > 0) {
return ";";
}
if (strpos($l, ",") > 0) {
return ",";
}
if (strpos($l, "\t") > 0) {
return "\t";
}
close($f);
return delimiter;
}
示例15: getEdges
function getEdges()
{
$conn = connect();
$query = 'SELECT * FROM edge';
$result = pg_query($query) or die('Query failed: ' . pg_last_error());
$array = array();
while ($line = pg_fetch_array($result, null, PGSQL_ASSOC)) {
if ($line["first_node_id"] > $line["second_node_id"]) {
array_push($array, array('origin' => $line["second_node_id"], 'destination' => $line["first_node_id"], 'distance' => $line["distance_between_nodes"]));
} else {
array_push($array, array('origin' => $line["first_node_id"], 'destination' => $line["second_node_id"], 'distance' => $line["distance_between_nodes"]));
}
}
close($result, $conn);
echo json_encode($array);
}