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


PHP MyDB::exec方法代码示例

本文整理汇总了PHP中MyDB::exec方法的典型用法代码示例。如果您正苦于以下问题:PHP MyDB::exec方法的具体用法?PHP MyDB::exec怎么用?PHP MyDB::exec使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MyDB的用法示例。


在下文中一共展示了MyDB::exec方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: 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

示例2: addSleep

 public static function addSleep($username, $createday, $deep, $shallow, $clear, $total)
 {
     $db = new MyDB();
     $sql = "SELECT * FROM SLEEP WHERE USERNAME='{$username}' AND CREATEDAY='{$createday}' ";
     $res = $db->query($sql);
     if ($item = $res->fetchArray(SQLITE3_ASSOC)) {
         $sql1 = "UPDATE SLEEP SET DEEP='{$deep}',SHALLOW='{$shallow}',CLEAR='{$clear}',TOTAL='{$total}' WHERE USERNAME='{$username}' AND CREATEDAY='{$createday}' ";
         return $db->exec($sql1);
     } else {
         $sql1 = "INSERT INTO SLEEP(USERNAME ,CREATEDAY,DEEP,SHALLOW,CLEAR,TOTAL) VALUES('{$username}','{$createday}','{$deep}','{$shallow}','{$clear}','{$total}')";
     }
     return $db->exec($sql1);
 }
开发者ID:NiShuang,项目名称:HealthOne,代码行数:13,代码来源:healthService.class.php

示例3: quit

 public static function quit($username, $id)
 {
     $db = new MyDB();
     $sql = "DELETE FROM `JOIN` WHERE USERNAME = '{$username}' AND ACTIVITY = '{$id}'";
     $res = $db->exec($sql);
     return $res;
 }
开发者ID:NiShuang,项目名称:HealthOne,代码行数:7,代码来源:activityService.class.php

示例4: 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

示例5: 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

示例6: 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

示例7: 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

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

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

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

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

示例12: 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

示例13: 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

示例14: 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

示例15: 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


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