本文整理匯總了PHP中MyDB::lastErrorMsg方法的典型用法代碼示例。如果您正苦於以下問題:PHP MyDB::lastErrorMsg方法的具體用法?PHP MyDB::lastErrorMsg怎麽用?PHP MyDB::lastErrorMsg使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類MyDB
的用法示例。
在下文中一共展示了MyDB::lastErrorMsg方法的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");
}
}
}
示例2: 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();
}
示例3: 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();
}
示例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: 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");
}
示例6: 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;
}
示例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();
}
示例8: 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();
}
示例9: 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();
}
示例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();
}
示例11: 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();
}
示例12: 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();
}
示例13: napoj_db
function napoj_db()
{
$db = new MyDB();
if (!$db) {
echo $db->lastErrorMsg();
return false;
} else {
//echo "Opened database successfully<br>"; ///////////////////////////////////
return $db;
}
}
示例14: 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();
}
示例15: 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();
}