本文整理汇总了PHP中MyDB::close方法的典型用法代码示例。如果您正苦于以下问题:PHP MyDB::close方法的具体用法?PHP MyDB::close怎么用?PHP MyDB::close使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MyDB
的用法示例。
在下文中一共展示了MyDB::close方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: user_register
function user_register($userName, $userPassword, $checkbox)
{
$db = new MyDB();
if (!$db) {
echo $db->lastErrorMsg();
} else {
echo "Opened database successfully</br>";
}
$sql = <<<EOF
SELECT * FROM User WHERE name = '{$userName}';
EOF;
$ret = $db->query($sql);
if (!$ret) {
echo $db->lastErrorMsg();
} else {
if ($row = $ret->fetchArray(SQLITE3_ASSOC)) {
header("Location: http://www.kmoving.com/user/register.php?Error=userExist");
} else {
$sql = <<<EOF
INSERT INTO User (name, password, last, doctor, gender, height, weight, country, city, address)
VALUES ('{$userName}', '{$userPassword}', '{$userName}', '{$checkbox}', '--', '--', '--', '--', '--', '--');
EOF;
$ret = $db->exec($sql);
if (!$ret) {
echo $db->lastErrorMsg();
} else {
$db->close();
setcookie("username", $userName, null, "/");
header("Location: http://www.kmoving.com/server/user/user_details.php");
}
}
}
$db->close();
}
示例2: add_member
function add_member($activityId)
{
$db = new MyDB();
if (!$db) {
echo $db->lastErrorMsg();
} else {
}
$userId = get_userId();
$sql = <<<EOF
SELECT * FROM ActivityMember WHERE userId={$userId} and activityId={$activityId};
EOF;
$ret = $db->query($sql);
if ($row = $ret->fetchArray(SQLITE3_ASSOC)) {
$db->close();
header("Location: http://www.kmoving.com/user/groups/activity.php?msg=memberExist");
} else {
$data = $_COOKIE['date'];
$sql = <<<EOF
INSERT INTO ActivityMember (userId, activityId, createAt)
VALUES ('{$userId}', '{$activityId}', '{$data}');
EOF;
$ret = $db->exec($sql);
if (!$ret) {
echo $db->lastErrorMsg();
} else {
$db->close();
header("Location: http://www.kmoving.com/user/groups/activity.php");
}
}
}
示例3: activity_delete
function activity_delete($delete_ID)
{
$db = new MyDB();
if (!$db) {
echo $db->lastErrorMsg();
} else {
}
$sql = <<<EOF
DELETE from Activity where id = {$delete_ID};
EOF;
$ret = $db->exec($sql);
if (!$ret) {
echo $db->lastErrorMsg();
} else {
$sql = <<<EOF
DELETE from ActivityMember where activityId = {$delete_ID};
EOF;
$ret = $db->exec($sql);
if (!$ret) {
echo $db->lastErrorMsg();
} else {
$db->close();
header("Location: http://www.kmoving.com/user/groups/activity.php");
}
}
}
示例4: go_digital_panel
function go_digital_panel()
{
$db = new MyDB();
if (!$db) {
echo $db->lastErrorMsg();
} else {
echo "Opened database successfully</br>";
}
$userName = $_COOKIE["username"];
$sql = <<<EOF
SELECT * FROM User WHERE name = '{$userName}';
EOF;
$ret = $db->query($sql);
if (!$ret) {
echo $db->lastErrorMsg();
} else {
if ($row = $ret->fetchArray(SQLITE3_ASSOC)) {
$name = $row["name"];
$gender = $row["gender"];
$height = $row["height"];
$weight = $row["weight"];
$date = date("Y-m-d");
setcookie("date", $date, null, "/");
$url = "http://www.kmoving.com/home.php?name={$name}&gender={$gender}&height={$height}&weight={$weight}";
header("Location: {$url}");
}
}
$db->close();
}
示例5: csvToJson
function csvToJson($filename, $separator = ",")
{
//create the resulting array
$result = array("records" => array());
//check if the file handle is valid
//echo $filename;
if (($handle = fopen($filename, "r")) !== false) {
//"Contact","Company","Business Email","Business Phone","Direct Phone","Time Zone","Fax","Web","Source"
//check if the provided file has the right format
if (($data = fgetcsv($handle, 4096, $separator)) == false || ($data[0] != "Contact" || $data[1] != "Company" || $data[2] != "Business Email")) {
throw new InvalidImportFileFormatException(sprintf('The provided file (%s) has the wrong format!', $filename));
}
$db = new MyDB();
if (!$db) {
echo $db->lastErrorMsg();
} else {
echo "Opened database successfully\n";
}
//loop through your data
while (($data = fgetcsv($handle, 4096, $separator)) !== false) {
$TZ = $db->UpdateTimeZone($data[3]);
echo json_encode($TZ);
//store each line in the resulting array
$result['records'][] = array("Contact" => $data[0], "Business Email" => $data[2], "Business Phone" => $data[3], "Time Zone" => $TZ);
}
//close the filehandle
$db->close();
fclose($handle);
}
//return the json encoded result
//echo json_encode($result);
return;
}
示例6: get_user_len
function get_user_len()
{
$db = new MyDB();
if (!$db) {
echo $db->lastErrorMsg();
} else {
}
$sql = <<<EOF
SELECT count(*) AS length FROM User;
EOF;
$ret = $db->query($sql);
if ($row = $ret->fetchArray(SQLITE3_ASSOC)) {
$db->close();
return $row['length'];
}
$db->close();
return null;
}
示例7: import_advice
function import_advice($address)
{
$reader = PHPExcel_IOFactory::createReader('Excel5');
$PHPExcel = $reader->load($address);
// 载入excel文件
$sheet = $PHPExcel->getSheet(0);
// 读取第一個工作表
$highestRow = $sheet->getHighestRow();
// 取得总行数
$highestColumm = $sheet->getHighestColumn();
// 取得总列数
$db = new MyDB();
if (!$db) {
echo $db->lastErrorMsg();
} else {
}
$title = "";
$content = "";
$toUserId = 0;
$authorId = 0;
for ($row = 1; $row <= $highestRow; $row++) {
//行数是以第1行开始
for ($column = 'A'; $column <= $highestColumm; $column++) {
//列数是以A列开始
if ($row != 1) {
switch ($column) {
case 'A':
$title = $sheet->getCell($column . $row)->getValue();
break;
case 'B':
$content = $sheet->getCell($column . $row)->getValue();
break;
case 'C':
$toUserId = $sheet->getCell($column . $row)->getValue();
break;
case 'D':
$authorId = $sheet->getCell($column . $row)->getValue();
break;
}
}
}
if ($row != 1) {
$sql = <<<EOF
INSERT INTO Advice (title, content, toUserId, authorId)
VALUES ('{$title}', '{$content}', '{$toUserId}', '{$authorId}');
EOF;
$ret = $db->exec($sql);
if (!$ret) {
echo $db->lastErrorMsg();
} else {
}
}
}
$db->close();
header("Location: http://www.kmoving.com/user/advice.php");
}
示例8: advice_create
function advice_create($title, $content, $toUserId, $authorId)
{
$db = new MyDB();
if (!$db) {
echo $db->lastErrorMsg();
} else {
echo "Opened database successfully</br>";
}
$sql = <<<EOF
INSERT INTO Advice (title, content, toUserId, authorId)
VALUES ('{$title}', '{$content}', '{$toUserId}', '{$authorId}');
EOF;
$ret = $db->exec($sql);
if (!$ret) {
echo $db->lastErrorMsg();
} else {
$db->close();
header("Location: http://www.kmoving.com/user/advice_create.php?msg=success");
}
$db->close();
}
示例9: create_activity
function create_activity($title, $target, $content, $authorId)
{
$db = new MyDB();
if (!$db) {
echo $db->lastErrorMsg();
} else {
echo "Opened database successfully</br>";
}
$sql = <<<EOF
INSERT INTO Activity (title, target, content, authorId)
VALUES ('{$title}', '{$target}', '{$content}', '{$authorId}');
EOF;
$ret = $db->exec($sql);
if (!$ret) {
echo $db->lastErrorMsg();
} else {
$db->close();
header("Location: http://www.kmoving.com/user/groups/activity.php");
}
$db->close();
}
示例10: activity_refresh
function activity_refresh($id, $title, $target, $content)
{
$db = new MyDB();
if (!$db) {
echo $db->lastErrorMsg();
} else {
}
$sql = <<<EOF
UPDATE Activity SET title='{$title}',target='{$target}',content='{$content}' where id={$id};
EOF;
$ret = $db->exec($sql);
if (!$ret) {
echo $db->lastErrorMsg();
}
$db->close();
}
示例11: set_user_settings
function set_user_settings($gender, $height, $weight, $birth, $country, $city, $address)
{
$db = new MyDB();
if (!$db) {
echo $db->lastErrorMsg();
} else {
echo "Opened database successfully</br>";
}
$userName = $_COOKIE["username"];
$sql = <<<EOF
UPDATE User set gender='{$gender}', height='{$height}', weight='{$weight}', birth='{$birth}',country='{$country}',city='{$city}',address='{$address}' where name='{$userName}';
EOF;
$ret = $db->exec($sql);
if (!$ret) {
echo $db->lastErrorMsg();
} else {
header("Location: http://www.kmoving.com/server/user/settings.php");
}
$db->close();
}
示例12: addToDB
function addToDB($ip, $time, $session, $message)
{
$db = new MyDB();
if (!$db) {
echo $db->lastErrorMsg();
} else {
echo "Opened database successfully\n";
}
$sql = <<<EOF
INSERT INTO test (ip,time,session,message)
VALUES('{$ip}', '{$time}', '{$session}', '{$message}');
EOF;
$ret = $db->exec($sql);
if (!$ret) {
echo $db->lastErrorMsg();
} else {
echo "Records created successfully\n";
}
$db->close();
}
示例13: GetSearchCardName
function GetSearchCardName($message)
{
$attribute = array("0" => "", "1" => "Earth", "2" => "Water", "4" => "Fire", "8" => "Wind", "16" => "Light", "32" => "Dark", "64" => "Divine");
$race = array("1" => "Warrior", "2" => "Spellcaster", "4" => "Fairy", "16" => "Zombie", "8" => "Unterweltler", "32" => "Maschine", "64" => "Aqua", "128" => "Pyro", "256" => "Rock", "512" => "Winged Beast", "1024" => "Plant", "2048" => "Insect", "4096" => "Thunder", "8192" => "Dragon", "16384" => "Beast", "32768" => "Beast-Warrior", "65536" => "Dinosaur", "131072" => "Fish", "262144" => "Sea Searpent", "524288" => "Reptile", "1048576" => "Psychic", "2097152" => "flying Beast");
$message = substr($message, 1);
$db = new MyDB();
$abfrage = "\n SELECT\n texts.id, name, desc, datas.type, datas.attribute, datas.race, datas.level, datas.atk, datas.def\n FROM\n texts\n LEFT JOIN\n datas\n ON\n texts.id = datas.id\n WHERE\n texts.name LIKE '%{$message}%'\n LIMIT\n 1\n ";
$ergebnis = $db->query($abfrage) or die("Error in query: <span style='color:red;'>{$abfrage}</span>");
// Counter fuer array setzen
$result = '';
while ($row = $ergebnis->fetchArray()) {
//$result .= $row['id'];
//$result .= utf8_decode($row['name']);
$result .= 'attr: ' . $attribute[$row['attribute']] . ' | ';
$result .= 'race: ' . $race[$row['race']] . ' | ';
$result .= 'level: ' . $row['level'] . ' | ';
$result .= 'atk' . $row['atk'] . ' | ';
$result .= 'def: ' . $row['def'];
}
$db->close();
// $res = implode($result);
return $result;
}
示例14: convert
function convert()
{
global $tmp_path, $db_filename, $inpx_input;
$db = new MyDB($tmp_path . $db_filename);
if (!$db) {
die($db->lastErrorMsg());
}
$db->create();
// get the absolute path to $file
//$path = pathinfo(realpath($file), PATHINFO_DIRNAME);
$zip = new ZipArchive();
$res = $zip->open($inpx_input);
if ($res === TRUE) {
// extract it to the path we determined above
$zip->extractTo($tmp_path);
$zip->close();
echo "{$file} extracted to {$tmp_path}\n";
} else {
echo "Doh! I couldn't open {$inpx_input}\n";
}
$sep = chr(0x4);
foreach (glob($tmp_path . '*.inp') as $file) {
echo $file . "\n";
$records = explode("\n", file_get_contents($file));
foreach ($records as $rec) {
$array = explode($sep, $rec);
$authors_ids = array();
$authors = explode(':', $array[0]);
foreach ($authors as $author) {
if (!empty($author)) {
$author = trim(str_replace(',', ' ', $author), " -\t\r!@#\$%^&*()_=+|");
$author_id = $db->addAuthor($author);
//echo "$author_id -> $author\n";
if ($author_id) {
$authors_ids[] = $author_id;
}
}
}
$genres_ids = array();
$genres = explode(':', $array[1]);
foreach ($genres as $genre) {
if (!empty($genre)) {
$genre_id = $db->addGenre($genre);
//echo "$genre_id -> $genre\n";
if ($genre_id) {
$genres_ids[] = $genre_id;
}
}
}
$title = trim($array[2], " \t");
$title_id = $db->addTitle($title);
//echo "$title_id -> $title\n";
$file_name = trim($array[5], " \t");
$file_size = trim($array[6], " \t");
$file_ext = trim($array[9], " \t");
$date_add = trim($array[10], " \t");
$lang = trim($array[11], "' \t");
//echo "$file_name $file_ext\n";
$db->addFile($authors_ids, $genres_ids, $title_id, $file_name, $file_ext, $file_size, $lang, $date_add);
}
}
$db->close();
rename($tmp_path . $db_filename, './' . $db_filename);
// TODO: cleanup temporary directory
exit;
}
示例15: update_workouts
function update_workouts($title, $steps, $km, $calories, $time)
{
$db = new MyDB();
if (!$db) {
echo $db->lastErrorMsg();
} else {
}
$userName = $_COOKIE['username'];
$date = $_COOKIE['date'];
$sql = <<<EOF
SELECT * FROM User,Workouts WHERE User.name='{$userName}' and User.id=Workouts.userId and Workouts.createAt='{$date}';
EOF;
$ret = $db->query($sql);
if (!$ret) {
echo $db->lastErrorMsg();
} else {
if ($row = $ret->fetchArray(SQLITE3_ASSOC)) {
$userId = $row['userId'];
$sql = <<<EOF
UPDATE Workouts SET title='{$title}',steps='{$steps}',
distance='{$km}',calories='{$calories}',time='{$time}'
where userId={$userId} and createAt={$date};
EOF;
$ret = $db->exec($sql);
if (!$ret) {
echo $db->lastErrorMsg();
} else {
}
} else {
$userId = get_userId($userName);
$sql = <<<EOF
INSERT INTO Workouts (userId, title, steps, distance, calories, time, createAt)
VALUES ('{$userId}', '{$title}', '{$steps}', '{$km}', '{$calories}', '{$time}', '{$date}');
EOF;
$ret = $db->exec($sql);
if (!$ret) {
echo $db->lastErrorMsg();
} else {
}
}
}
$db->close();
}