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


PHP MyDB::close方法代码示例

本文整理汇总了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();
}
开发者ID:MelonGO,项目名称:KMoving,代码行数:34,代码来源:register_server.php

示例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");
        }
    }
}
开发者ID:MelonGO,项目名称:KMoving,代码行数:30,代码来源:activity_add_member.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");
        }
    }
}
开发者ID:MelonGO,项目名称:KMoving,代码行数:26,代码来源:activity_delete.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();
}
开发者ID:MelonGO,项目名称:KMoving,代码行数:29,代码来源:user_details.php

示例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;
}
开发者ID:radhikahganesh,项目名称:DemoTimeZonePHP,代码行数:33,代码来源:upload.php

示例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;
}
开发者ID:MelonGO,项目名称:KMoving,代码行数:18,代码来源:user_list.php

示例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");
}
开发者ID:MelonGO,项目名称:KMoving,代码行数:56,代码来源:advice_excel.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();
}
开发者ID:MelonGO,项目名称:KMoving,代码行数:21,代码来源:advice_create.php

示例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();
}
开发者ID:MelonGO,项目名称:KMoving,代码行数:21,代码来源:activity_create.php

示例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();
}
开发者ID:MelonGO,项目名称:KMoving,代码行数:16,代码来源:activity_refresh.php

示例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();
}
开发者ID:MelonGO,项目名称:KMoving,代码行数:20,代码来源:settings.php

示例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();
}
开发者ID:sc222as,项目名称:1DV608_sc222as,代码行数:21,代码来源:addtodb.php

示例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;
 }
开发者ID:benblub,项目名称:devpro-chatbot,代码行数:23,代码来源:FilterCardsearch.php

示例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;
}
开发者ID:xnynx,项目名称:inpx2opds,代码行数:66,代码来源:index.php

示例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();
}
开发者ID:MelonGO,项目名称:KMoving,代码行数:43,代码来源:workouts.php


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