本文整理汇总了PHP中MyDB::query方法的典型用法代码示例。如果您正苦于以下问题:PHP MyDB::query方法的具体用法?PHP MyDB::query怎么用?PHP MyDB::query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MyDB
的用法示例。
在下文中一共展示了MyDB::query方法的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: isIn
public static function isIn($username, $id)
{
$db = new MyDB();
$sql = "SELECT * FROM `JOIN` WHERE USERNAME = '{$username}' AND ACTIVITY={$id}";
$res = $db->query($sql);
return $res;
}
示例3: get_user_settings
function get_user_settings()
{
$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"];
$birth = $row["birth"];
$country = $row["country"];
$city = $row["city"];
$address = $row["address"];
$url = "http://www.kmoving.com/user/info/settings.php?name={$name}&gender={$gender}&height={$height}&weight={$weight}&birth={$birth}&country={$country}&city={$city}&address={$address}";
header("Location: {$url}");
}
}
$db->close();
}
示例4: 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");
}
}
}
示例5: 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();
}
示例6: update_meals
function update_meals($title, $calories, $fat, $protein, $calcium, $carbohydrate, $sugar, $cholesterol, $vitamin_c, $vitamin_a)
{
$db = new MyDB();
if (!$db) {
echo $db->lastErrorMsg();
} else {
}
$userName = $_COOKIE['username'];
$date = $_COOKIE['date'];
$sql = <<<EOF
SELECT * FROM User,Meals WHERE User.name='{$userName}' and User.id=Meals.userId and Meals.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 Meals
SET title='{$title}',calories='{$calories}',fat='{$fat}',
protein='{$protein}',calcium='{$calcium}',carbohydrate='{$carbohydrate}',
vitamin_c='{$vitamin_c}',vitamin_a='{$vitamin_a}'
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 Meals (userId, title, calories, fat, protein, calcium, carbohydrate, sugar, cholesterol, vitamin_c, vitamin_a, createAt)
VALUES ('{$userId}', '{$title}', '{$calories}', '{$fat}', '{$protein}', '{$calcium}', '{$carbohydrate}', '{$sugar}', '{$cholesterol}', '{$vitamin_c}', '{$vitamin_a}', '{$date}');
EOF;
$ret = $db->exec($sql);
if (!$ret) {
echo $db->lastErrorMsg();
} else {
}
}
}
$db->close();
}
示例7: update_moves
function update_moves($active_time, $inactive_time, $calories, $wo_calories, $bg_calories, $bmr_day, $steps, $km)
{
$db = new MyDB();
if (!$db) {
echo $db->lastErrorMsg();
} else {
}
$userName = $_COOKIE['username'];
$date = $_COOKIE['date'];
$sql = <<<EOF
SELECT * FROM User,Moves WHERE User.name='{$userName}' and User.id=Moves.userId and Moves.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 Moves
SET active='{$active_time}',free='{$inactive_time}',
total_calories='{$calories}',workouts_calories='{$wo_calories}',
static_calories='{$bg_calories}',daixie='{$bmr_day}',steps='{$steps}',distance='{$km}'
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 Moves (userId, active, free, total_calories, workouts_calories, static_calories, daixie, steps, distance, createAt)
VALUES ('{$userId}', '{$active_time}', '{$inactive_time}', '{$calories}', '{$wo_calories}', '{$bg_calories}', '{$bmr_day}', '{$steps}', '{$km}' , '{$date}');
EOF;
$ret = $db->exec($sql);
if (!$ret) {
echo $db->lastErrorMsg();
} else {
}
}
}
$db->close();
}
示例8: get_total_len
function get_total_len()
{
$db = new MyDB();
if (!$db) {
echo $db->lastErrorMsg();
} else {
}
$sql = <<<EOF
SELECT count(*) AS length FROM Activity;
EOF;
$ret = $db->query($sql);
if ($row = $ret->fetchArray(SQLITE3_ASSOC)) {
$db->close();
return $row['length'];
}
$db->close();
return null;
}
示例9: update_sleeps
function update_sleeps($asleep_time, $awakenings, $awake, $light, $deep, $duration)
{
$db = new MyDB();
if (!$db) {
echo $db->lastErrorMsg();
} else {
}
$userName = $_COOKIE['username'];
$date = $_COOKIE['date'];
$sql = <<<EOF
SELECT * FROM User,Sleeps WHERE User.name='{$userName}' and User.id=Sleeps.userId and Sleeps.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 Sleeps
SET asleep='{$asleep_time}',wake_up_time='{$awakenings}',
sober='{$awake}',light='{$light}',deep='{$deep}',total='{$duration}'
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 Sleeps (userId, asleep, wake_up_time, sober, light, deep, total, createAt)
VALUES ('{$userId}', '{$asleep_time}', '{$awakenings}', '{$awake}', '{$light}', '{$deep}', '{$duration}', '{$date}');
EOF;
$ret = $db->exec($sql);
if (!$ret) {
echo $db->lastErrorMsg();
} else {
}
}
}
$db->close();
}
示例10: 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();
}
示例11: update_mood
function update_mood($mood_image)
{
$db = new MyDB();
if (!$db) {
echo $db->lastErrorMsg();
} else {
}
$userName = $_COOKIE['username'];
$date = $_COOKIE['date'];
$sql = <<<EOF
SELECT * FROM User,Mood WHERE User.name='{$userName}' and User.id=Mood.userId and Mood.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 Mood
SET mood='{$mood_image}'
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 Mood (userId, mood, createAt)
VALUES ('{$userId}', '{$mood_image}', '{$date}');
EOF;
$ret = $db->exec($sql);
if (!$ret) {
echo $db->lastErrorMsg();
} else {
}
}
}
$db->close();
}
示例12: get_authorId
function get_authorId()
{
$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}' and doctor='on';
EOF;
$ret = $db->query($sql);
if ($row = $ret->fetchArray(SQLITE3_ASSOC)) {
$authorId = $row['id'];
$db->close();
return $authorId;
}
$db->close();
}
示例13: is_Author
function is_Author($delete_ID)
{
$db = new MyDB();
if (!$db) {
echo $db->lastErrorMsg();
} else {
}
$userName = $_COOKIE["username"];
$sql = <<<EOF
SELECT * from Activity,User where User.id=Activity.authorId and User.name='{$userName}' and Activity.id={$delete_ID};
EOF;
$ret = $db->query($sql);
if ($row = $ret->fetchArray(SQLITE3_ASSOC)) {
$db->close();
return true;
} else {
$db->close();
return false;
}
}
示例14: dbGetUrl
/**
* get short url from db
*
* @param unknown_type $url
* @return unknown
*/
public function dbGetUrl($url)
{
$this->debug(sprintf('GETTING: %s FROM DB', $url));
require_once dirname(__FILE__) . '/MyDb.php';
$dbh = new MyDB();
$sql = "SELECT `short_url` FROM `short_urls` WHERE `long_url` = '%s' LIMIT 1 ";
$select_sql = sprintf($sql, $url);
$result = $dbh->query($select_sql);
$data = $result->fetch();
return $data['short_url'];
}
示例15: exit
<?php
include "database/MyDB.php";
if (!isset($_POST['submit'])) {
exit('非法访问!');
}
$id = $_POST['del_id'];
//auth access info
$appauthname = $_POST['appauthname'];
$appauthpwd = $_POST['appauthpwd'];
if ($appauthname != "yarlung") {
die("授权帐号出错! <br/>");
}
if ($appauthpwd != "yarlung01") {
die("授权密码不正确! <br/>");
}
if (empty($id)) {
die("没有选中要删除的应用!<br/>");
}
$dblink = new MyDB();
foreach ($id as $ide) {
echo "删除UID为 " . $ide . " 的应用!<br/>";
$qry = "DELETE FROM appinfo WHERE uid ={$ide}";
$dblink->query($qry);
}
$dblink->close();