本文整理汇总了PHP中MyDB类的典型用法代码示例。如果您正苦于以下问题:PHP MyDB类的具体用法?PHP MyDB怎么用?PHP MyDB使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MyDB类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: togglePost
public function togglePost($iId, $iVisible)
{
$dbh = new MyDB();
$oDb = $dbh->getDB();
$dbh = $oDb->prepare("UPDATE `posts` SET `hidde` = ? WHERE `post_id` = ?");
$dbh->execute(array($iVisible, $iId));
}
开发者ID:kuzik,项目名称:iThink,代码行数:7,代码来源:model_admin.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();
}
开发者ID:MelonGO,项目名称:KMoving,代码行数:29,代码来源:user_details.php
示例3: 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;
}
开发者ID:NiShuang,项目名称:HealthOne,代码行数:7,代码来源:activityService.class.php
示例4: 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
示例5: getUserList
public function getUserList()
{
$dbh = new MyDB();
$oDb = $dbh->getDB();
$dbh = $oDb->prepare('SELECT id, login, avatar, email, reg_date, u_status FROM user ORDER BY id');
$dbh->execute(array());
return $dbh->fetchAll();
}
开发者ID:kuzik,项目名称:iThink,代码行数:8,代码来源:model_users.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: registerUser
public function registerUser()
{
$error = '';
$username = trim($_POST['username']);
$email = trim($_POST['email']);
$pass = trim($_POST['passwordinput']);
if (empty($username)) {
$error .= '<li>Username</li>';
}
if (empty($email)) {
$error .= '<li>E-mail</li>';
}
if (empty($pass)) {
$error .= '<li>Password</li>';
}
if (strlen($pass) < 8) {
$error .= '<li>Пароль надто короткий</li>';
}
if (empty($error)) {
$dbh = new MyDB();
$oDb = $dbh->getDB();
$dbh = $oDb->prepare("SELECT `id` FROM `user` WHERE `login` = ? LIMIT 1");
$dbh->execute(array(mysql_real_escape_string(strip_tags($username))));
if ($dbh->fetchColumn()) {
$rez = "<h3> Користувач з таким імям вже існує </h3>";
} else {
//якщо помилки відсутні
$pass = md5($pass);
$pass = strrev($pass) . 'ZAQ!2wsx';
$reg_date = date("d-m-Y в H:i");
$dbh = new MyDB();
$oDb = $dbh->getDB();
$dbh = $oDb->prepare("INSERT INTO user(login, password, email, reg_date)VALUES(?, ?, ?, ?)");
$dbh->execute(array($username, $pass, $email, $reg_date));
$iUserId = $oDb->lastInsertId();
if ($iUserId > 0) {
$oMedia = new myMedia();
$avatar = $oMedia->imgUploader($iUserId);
$dbh = new MyDB();
$oDb = $dbh->getDB();
$dbh = $oDb->prepare("UPDATE `ithink_db`.`user` SET `avatar` = ? WHERE `user`.`id` = ?");
$dbh->execute(array($avatar, $iUserId));
$rez = "<h3>Реєстрація пройшла успішно</h3>";
$_SESSION['auth']['user']['username'] = $username;
$_SESSION['auth']['user']['avatar'] = $avatar;
$_SESSION['auth']['user']['user_id'] = $iUserId;
$_SESSION['auth']['user']['u_status'] = 1;
}
}
} else {
//вивід помилок на екран
$rez = "Усі поля не заповнені: <ul id='error-list'> {$error} </ul>";
}
return $rez;
}
开发者ID:kuzik,项目名称:iThink,代码行数:55,代码来源:model_reg.php
示例8: napoj_db
function napoj_db()
{
$db = new MyDB();
if (!$db) {
echo $db->lastErrorMsg();
return false;
} else {
//echo "Opened database successfully<br>"; ///////////////////////////////////
return $db;
}
}
开发者ID:TaxusTeam,项目名称:TIS-project,代码行数:11,代码来源:funkcie.php
示例9: 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
示例10: login
protected function login()
{
try {
if ($this->method == 'POST') {
$username = $this->request['username'];
$password = $this->request['password'];
if (isset($username) && isset($password)) {
if (isset($_SESSION['Token'])) {
return $_SESSION['Token'];
} else {
$user_authenticated = MyDB::getInstance()->authenticateUser($username, $password);
if ($user_authenticated) {
//$this->User->loadUser($username, $password);
$_SESSION['Token'] = uniqid();
return array('token' => $_SESSION['Token'], 'user_name' => $username);
} else {
throw new Exception('Invalid user credentials');
}
}
} else {
throw new Exception('Missing username or password');
}
} else {
throw new Exception('Wrong request type');
}
} catch (Exception $e) {
header('401 Not Authorized');
return $e->getMessage();
}
}
开发者ID:harjeet-singh,项目名称:backbone_tutorial,代码行数:30,代码来源:MyAPI.php
示例11: password
public function password($username)
{
echo 'password called';
// Return the password for the username
$res = MyDB::loginStudent($username);
return $res['pwHash'];
}
开发者ID:JovanRis,项目名称:Demola2,代码行数:7,代码来源:MyAuth.php
示例12: change_pwd
function change_pwd($oldpwd, $newpwd, $newpwd_r)
{
if ($newpwd != $newpwd_r) {
return 1;
}
return MyDB::getInstance()->change_passwd($_SESSION['u_login'], $oldpwd, $newpwd) == TRUE ? 0 : 1;
}
开发者ID:zcsevcik,项目名称:edu,代码行数:7,代码来源:admin.php
示例13: 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
示例14: get_token
protected function get_token()
{
if ($this->method == 'POST') {
$username = $this->request['username'];
$password = $this->request['password'];
if (isset($username) && isset($password)) {
if (isset($_SESSION[$username])) {
return $_SESSION[$username];
} else {
$user_authenticated = MyDB::getInstance()->authenticateUser($username, $password);
if ($user_authenticated) {
//$this->User->loadUser($username, $password);
$_SESSION[$username] = uniqid();
return $_SESSION[$username];
} else {
return 'Invalid user credentials';
}
}
} else {
return 'Missing username/password';
}
} else {
return "Only accepts POST requests";
}
}
开发者ID:harjeet-singh,项目名称:php_rest_api,代码行数:25,代码来源:MyAPI.php
示例15: 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
示例16: 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
示例17: 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
示例18: createPost
function createPost()
{
$error = '';
$title = trim($_POST['post_title']);
$full_text = trim($_POST['post_text']);
if (empty($title)) {
$error .= '<li>title</li>';
}
if (empty($full_text)) {
$error .= '<li>full_text</li>';
}
if (empty($error)) {
$author_id = $_SESSION['auth']['user']['user_id'];
if (strlen($title) > 50) {
$title = substr($title, 0, 50);
}
if (strlen($full_text) > 250) {
$description = substr($full_text, 0, 247);
$description .= '...';
} else {
$description = $full_text;
}
$cre_date = mktime();
$dbh = new MyDB();
$oDb = $dbh->getDB();
$dbh = $oDb->prepare("SELECT post_id FROM posts WHERE title = ? LIMIT 1");
$dbh->execute(array($title));
$iRow = $dbh->fetchColumn();
//var_dump($iRow);die();
if ($iRow) {
$rez = "<h3> Така думка вже була створена </h3>";
} else {
$dbh = new MyDB();
$oDb = $dbh->getDB();
$dbh = $oDb->prepare("INSERT INTO posts (author_id, title, description, full_text, cre_date)VALUES(?,?,?,?,?) ");
$dbh->execute(array($author_id, $title, $description, $full_text, $cre_date));
if ($oDb->lastInsertId()) {
$rez = "<h3>Запис успішно добавлено</h3>";
}
}
} else {
$rez = "Усі поля не заповнені: <ul id='error-list'> {$error} </ul>";
}
return $rez;
}
开发者ID:kuzik,项目名称:iThink,代码行数:45,代码来源:model_main.php
示例19: 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;
}
开发者ID:MelonGO,项目名称:KMoving,代码行数:18,代码来源:activity_data.php
示例20: getActiveProjects
public static function getActiveProjects($companyID)
{
$currentProjectIDs = MyDB::getCompanyProjects($companyID);
$currentProjects = array();
for ($i = 0; $i < count($currentProjectIDs); $i++) {
array_push($currentProjects, MyDB::getprojectByID($currentProjectIDs[$i]));
}
return $currentProjects;
}
开发者ID:JovanRis,项目名称:Demola2,代码行数:9,代码来源:Company.php
注:本文中的MyDB类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论