本文整理汇总了PHP中closeConnection函数的典型用法代码示例。如果您正苦于以下问题:PHP closeConnection函数的具体用法?PHP closeConnection怎么用?PHP closeConnection使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了closeConnection函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: doCheckUpdate
function doCheckUpdate($v, $d)
{
$db = openConnection();
$sql = "";
$user_id = "";
$str = "{\"result\":\"0\",\"version_code\":\"0\",\"version_name\":\"\",\"file\":\"\",\"size\":\"\",\"desc\":\"\"}";
if (!empty($d)) {
$sql = "select id from root_tools_update_user where device='{$d}'";
$result = query($db, $sql);
while (list($id) = mysql_fetch_row($result)) {
$user_id = $id;
break;
}
if ($user_id != "") {
$sql = "select * from root_tools_update where ver_code > {$v} order by id desc limit 0,1";
$result = query($db, $sql);
}
} else {
$sql = "select * from root_tools_update where tag=0 and ver_code > {$v} order by id desc limit 0,1";
$result = query($db, $sql);
}
closeConnection($db);
while (list($id, $name, $ver_code, $size, $filename, $update_desc) = mysql_fetch_row($result)) {
$str = "{\"result\":\"1\",\"version_code\":\"{$ver_code}\",\"version_name\":\"{$name}\",\"file\":\"{$filename}\",\"size\":\"{$size}\",\"desc\":" . json_encode($update_desc) . "}";
break;
}
return $str;
}
示例2: doUploadFont
function doUploadFont($n, $t)
{
$dbRet = 0;
$sql = "select id from fonts where name='{$n}'";
$db = openConnection();
$result = query($db, $sql);
$hasRecord = 0;
while (list($id) = mysql_fetch_row($result)) {
$hasRecord = 1;
break;
}
if ($hasRecord == 0) {
$istop = 0;
if ($t == "1") {
$istop = 1;
}
$fileName = $n . ".ttf";
$previewName = $n . ".png";
$sql = "insert into fonts (name, filename, istop, preview) values ('{$n}','{$fileName}',{$istop},'{$previewName}')";
$result = query($db, $sql);
$dbRet = $result;
}
closeConnection($db);
return $dbRet;
}
示例3: DoQuery
function DoQuery($t) {
$db = openConnection();
$id = 0;
$versionCode = 0;
$versionName = "";
$url = "";
$desc = "";
$desc_en = "";
$ret = "{\"versionCode\":0}";
if ($t == "last" || empty($t)) {
$stmt = $db->prepare("select * from version order by versionCode desc limit 0, 1");
$stmt->execute();
$stmt->bind_result($id, $versionCode, $versionName, $url, $desc, $desc_en);
$stmt->fetch();
$ret = "{\"versionCode\":${versionCode}, \"versionName\":".json_encode($versionName).", \"url\":".json_encode($url).", \"description\":".json_encode($desc).",\"desc_en\":".json_encode($desc_en)."}";
$stmt->close();
} else if ($t == "all") {
$ret = "{\"result\":0, \"data\":[";
$stmt = $db->prepare("select * from version order by versionCode desc limit 0, 10");
$stmt->execute();
$stmt->bind_result($id, $versionCode, $versionName, $url, $desc, $desc_en);
while($stmt->fetch()) {
$ret .= "{\"versionCode\":${versionCode}, \"versionName\":".json_encode($versionName).", \"url\":".json_encode($url).", \"description\":".json_encode($desc).",\"desc_en\":".json_encode($desc_en)."},";
}
$ret = rtrim($ret, ",");
$ret .= "]}";
}
closeConnection($db);
return $ret;
}
示例4: getUserRoleByID
/**
* UserRoles model
*
* @author Enrique Bondoc <enrique.bondoc@writetospeak.info>
* @since 2016-01-13 03:03:54 +08:00
**/
function getUserRoleByID($config, $id)
{
$connection = getConnection($config);
if (false === $connection['status']) {
return $connection;
}
$connection = $connection['connection'];
try {
$query = sprintf('
SELECT
`UserRoles`.*
FROM `UserRoles`
WHERE
`ID` = :ID
LIMIT 1
');
$data = ['ID' => $id];
$preparedStatement = $connection->prepare($query, [PDO::ATTR_CURSOR => PDO::CURSOR_FWDONLY]);
$preparedStatement->execute($data);
$preparedStatement->setFetchMode(PDO::FETCH_ASSOC);
$record = $preparedStatement->fetch();
if (!empty($record)) {
$record = ['ID' => $record['ID'], 'Name' => $record['Name'], 'Code' => $record['Code'], 'DateAdded' => $record['DateAdded'], 'DateModified' => $record['DateModified']];
return ['status' => true, 'message' => 'User Role found and retrieved successfully.', 'userRole' => $record];
}
closeConnection($connection);
return ['status' => false, 'message' => 'No user role found with given ID.'];
} catch (Exception $e) {
closeConnection($connection);
return ['status' => false, 'message' => $e->getMessage(), 'code' => 500];
}
}
示例5: printTestUsers
function printTestUsers($accounts)
{
$connection = mysql_connect(DB_SERVER, DB_USER, DB_PASS) or die("Problemas en la conexion");
mysql_select_db(DB_NAME, $connection);
$html = "";
if (isset($accounts['data']) && count($accounts['data'])) {
$html .= "<table>";
$html .= "<tr class=\"head\"><td colspan=\"5\">Usuarios de prueba</td></tr>";
$html .= "<tr class=\"head\"><td>ID</td><td>Nombre</td><td>App user</td><td>Login URL</td><td>Borrar</td></tr>";
foreach ($accounts['data'] as $arr) {
$html .= "<tr>";
$html .= "<td>{$arr['id']}</td>";
$fbid = $arr['id'];
$fbid = quote_smart($fbid, $connection);
$SQL = "SELECT * FROM USER_APP2 WHERE fbid = {$fbid}";
$result = mysql_query($SQL) or die("MySQL-err.Query: " . $SQL . " - Error: (" . mysql_errno() . ") " . mysql_error());
$num_rows = mysql_num_rows($result);
if ($num_rows == 1) {
$aRow = mysql_fetch_array($result);
$html .= "<td>" . $aRow['fbname'] . "</td>";
} else {
$html .= "<td>-</td>";
}
$html .= "<td>" . (empty($arr['access_token']) ? "NO" : "YES") . "</td>";
$html .= "<td><a href=\"{$arr['login_url']}\" target=\"_blank\">Test User Login</a></td>";
$html .= "<td><a href=\"{$_SERVER['PHP_SELF']}?id={$arr['id']}&action=delete\">Delete Test User</a></td>";
$html .= "</tr>";
}
$html .= "</table>";
} else {
$html = "No hay usuarios";
}
closeConnection($connection);
return $html;
}
示例6: DoUpload
function DoUpload($n, $p, $u, $i, $a, $m, $ai)
{
$ret = "";
$str = "";
if ($m == 1) {
// update
$db = openConnection();
$sql = "update root_tools_recommand set name='{$n}',icon_url='{$i}',download_url='{$a}' where package_name='{$p}'";
$str = query($db, $sql);
closeConnection($db);
} else {
// add
$id = generateId("root_tools_recommand", "id");
$db = openConnection();
$sql = "insert into root_tools_recommand (id, name, package_name, main_activity, icon_url, download_url, unix_name, app_order) values ({$id}, '{$n}', '{$p}', 'null', '{$i}', '{$a}', '{$u}', 0)";
$str = query($db, $sql);
closeConnection($db);
}
if ($str == "0") {
$ret = "1";
} else {
$ret = "0";
}
return $ret;
}
示例7: DoQuery
function DoQuery($t) {
$str = "{\"result\":0, \"data\":[";
$db = openConnection();
$stmt = $db->prepare("select id, nickname, comment, photo1, photo2, photo3, photo4, photo5, commit_date from feedback where status = ? order by id desc");
$stmt->bind_param("i", $t);
$stmt->execute();
$id = 0;
$nickname = "";
$comment = "";
$photo1 = "";
$photo2 = "";
$photo3 = "";
$photo4 = "";
$photo5 = "";
$commit_date = "";
$stmt->bind_result($id, $nickname, $comment, $photo1, $photo2, $photo3, $photo4, $photo5, $commit_date);
while ($stmt->fetch()) {
$str .= "{\"id\":${id},\"nickname\":".json_encode($nickname).",\"comment\":".json_encode($comment).",\"photo1\":\"${photo1}\",\"photo2\":\"${photo2}\",\"photo3\":\"${photo3}\",\"photo4\":\"${photo4}\",\"photo5\":\"${photo5}\",\"commit_date\":\"${commit_date}\"},";
}
$stmt->close();
closeConnection($db);
$str = rtrim($str, ",");
$str .= "]}";
return $str;
}
示例8: DoQuery
function DoQuery($n, $c, $p1, $p2, $p3, $p4, $p5) {
$str = "{\"result\":1}";
date_default_timezone_set("Asia/Hong_Kong");
$t_str = date("YmdHis");
$commit_date = date("Y-m-d H:i:s");
$pname = generateToken().".${t_str}.";
$path1 = "./files/${pname}1";
$path2 = "./files/${pname}2";
$path3 = "./files/${pname}3";
$path4 = "./files/${pname}4";
$path5 = "./files/${pname}5";
$dbp1 = "";
$dbp2 = "";
$dbp3 = "";
$dbp4 = "";
$dbp5 = "";
if (isset($p1)) { move_uploaded_file($p1["tmp_name"], $path1); $dbp1 = "${pname}1"; }
if (isset($p2)) { move_uploaded_file($p2["tmp_name"], $path2); $dbp2 = "${pname}2"; }
if (isset($p3)) { move_uploaded_file($p3["tmp_name"], $path3); $dbp3 = "${pname}3"; }
if (isset($p4)) { move_uploaded_file($p4["tmp_name"], $path4); $dbp4 = "${pname}4"; }
if (isset($p5)) { move_uploaded_file($p5["tmp_name"], $path5); $dbp5 = "${pname}5"; }
$db = openConnection();
$stmt = $db->prepare("insert into feedback(nickname, comment, photo1, photo2, photo3, photo4, photo5, commit_date) values (?, ?, ?, ?, ?, ?, ?, ?)");
$stmt->bind_param("ssssssss", $n, $c, $dbp1, $dbp2, $dbp3, $dbp4, $dbp5, $commit_date);
$stmt->execute();
$rows = intval($stmt->affected_rows);
$stmt->close();
closeConnection($db);
if ($rows != 0) {
$str = "{\"result\":0}";
}
return $str;
}
示例9: addStudentSubjectMatch
/**
* StudentsSubjectsMatch model
*
* @author Enrique Bondoc <enrique.bondoc@writetospeak.info>
* @since 2016-01-13 04:04:01 +08:00
**/
function addStudentSubjectMatch($config, $studentID, $subjectID)
{
$connection = getConnection($config);
if (false === $connection['status']) {
return $connection;
}
$connection = $connection['connection'];
try {
/**
* Insert into StudentsSubjectsMatch table.
*/
$query = sprintf('
INSERT INTO `StudentsSubjectsMatch` ( `UserID`, `SubjectID` )
VALUES ( :UserID, :SubjectID )
');
$preparedStatement = $connection->prepare($query);
$preparedStatement->bindValue(':UserID', $studentID, PDO::PARAM_INT);
$preparedStatement->bindValue(':SubjectID', $subjectID, PDO::PARAM_INT);
$result = $preparedStatement->execute();
closeConnection($connection);
if ($result) {
return ['status' => true, 'message' => 'Match (Student-Subject) has been added successfully.'];
}
return ['status' => false, 'message' => 'An error occured while trying to add the Student-Subject match.'];
} catch (Exception $e) {
closeConnection($connection);
return ['status' => false, 'message' => $e->getMessage(), 'code' => 500];
}
}
示例10: execute
function execute($sql)
{
global $invalidQueryInputError;
$connection = connectToDatabase();
$result = mysqli_query($connection, $sql);
closeConnection($connection);
$rows = array();
if (mysqli_num_rows($result) > 0) {
$i = 0;
while ($row = mysqli_fetch_assoc($result)) {
$rows[$i] = $row;
$i++;
}
}
if ($invalidQueryInputError != "") {
$rows["PHP_ERROR"] = $invalidQueryInputError;
//This is not safe [Security Flow]
$invalidQueryInputError = "";
}
if (mysqli_error($connection) != null) {
$rows["SQL_ERROR"] = mysqli_connect_error();
//This is not safe [Security Flow]
}
return $rows;
}
示例11: DoChangeOrder
function DoChangeOrder($i, $a)
{
$sql = "update root_tools_recommand set app_order={$a} where id={$i}";
$db = openConnection();
$result = query($db, $sql);
closeConnection($db);
return $result;
}
示例12: doUploadNewVersion
function doUploadNewVersion($n, $v, $s, $f, $u, $t)
{
$db = openConnection();
$sql = "insert into root_tools_update (name, ver_code, size, filename, update_desc,tag) values ('{$n}',{$v},'{$s}','{$f}','{$u}',{$t})";
$result = query($db, $sql);
closeConnection($db);
return $result;
}
示例13: doAddDevice
function doAddDevice($d, $u)
{
$db = openConnection();
$sql = "insert into root_tools_update_user (device, user_memo) values ('{$d}', '{$u}')";
$result = query($db, $sql);
closeConnection($db);
return $result;
}
示例14: DoDeletePackage
function DoDeletePackage($i)
{
$sql = "delete from root_tools_recommand where id={$i}";
$db = openConnection();
$result = query($db, $sql);
closeConnection($db);
return $result;
}
示例15: doDeleteDevice
function doDeleteDevice($i)
{
$db = openConnection();
$sql = "delete from root_tools_update_user where id={$i}";
$result = query($db, $sql);
closeConnection($db);
return $result;
}