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


PHP DBUtils类代码示例

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


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

示例1: add

 public static function add($param)
 {
     $pdo = new DBUtils();
     $key_str = "";
     $val_str = "";
     $sql = "";
     if (isset($param['type'])) {
         $key_str .= "type,";
         $val_str .= "'{$param['type']}',";
     }
     if (isset($param['studentName'])) {
         $key_str .= "studentName,";
         $val_str .= "'{$param['studentName']}',";
     }
     if (isset($param['num'])) {
         $key_str .= "num" . ",";
         $val_str .= "'{$param['num']}',";
     }
     $now = time();
     $key_str .= "time" . ",";
     $val_str .= "'{$now}',";
     $key_str .= "course" . ",";
     $val_str .= "'{$GLOBALS['STUDENT_COURSE_TYPE'][0]}',";
     $key_str = substr($key_str, 0, strlen($key_str) - 1);
     $val_str = substr($val_str, 0, strlen($val_str) - 1);
     $sql = "insert into student_news (" . $key_str . ")";
     $sql .= " VALUES (" . $val_str . ")";
     $articleId = $pdo->insert($sql);
     return $articleId;
 }
开发者ID:zcmyworld,项目名称:nothing,代码行数:30,代码来源:mod_thanks.php

示例2: getIndex

 public static function getIndex()
 {
     $pdo = new DBUtils();
     $sql = "select * from homepage";
     $rs = $pdo->query($sql);
     return $rs;
 }
开发者ID:zcmyworld,项目名称:nothing,代码行数:7,代码来源:mod_index.php

示例3: updatePhoto

 public static function updatePhoto($param)
 {
     $pdo = new DBUtils();
     $sql = "update homepage set photoUrl = '" . $param['photoUrl'] . "' where id  = '{$param['id']}'";
     $rs = $pdo->update($sql);
     return $rs;
 }
开发者ID:zcmyworld,项目名称:nothing,代码行数:7,代码来源:mod_index.php

示例4: delNav

 public static function delNav($snavId)
 {
     $pdo = new DBUtils();
     $sql = "delete from second_nav where snavId = '{$snavId}'";
     //        print_r($sql);
     //        exit;
     $rs = $pdo->delete($sql);
     return $rs;
 }
开发者ID:zcmyworld,项目名称:nothing,代码行数:9,代码来源:mod_nav.php

示例5: getOne

 public static function getOne($courseId)
 {
     $pdo = new DBUtils();
     $sql = "select * from course where courseId = {$courseId}";
     $course = $pdo->getOne($sql);
     $sql = "select * from courseType where courseId = {$courseId}";
     $courseType = $pdo->query($sql);
     return array("course" => $course, "courseType" => $courseType);
 }
开发者ID:zcmyworld,项目名称:nothing,代码行数:9,代码来源:mod_course.php

示例6: verifyUser

 public function verifyUser()
 {
     $dbUtil = new DBUtils();
     $value = $dbUtil->verifyUser($this->username, $this->password);
     if ($value) {
         $_SESSION["id"] = $this->username;
         return "Logged in sucessfully";
     } else {
         return "Log in failed. Please try with proper user.";
     }
     return $value;
 }
开发者ID:ricsr,项目名称:hello-world,代码行数:12,代码来源:UserModel.php

示例7: log

 public function log()
 {
     $log = KLogger::instance(KLOGGER_PATH . "processors/", KLogger::DEBUG);
     $log->logInfo("userxplog > log > start userId : " . $this->userId . " xp : " . $this->xp . " type : " . $this->type . " time : " . $this->time . " gameId : " . $this->gameId . " result : " . $this->result . " opponentId : " . $this->opponentId);
     if (!empty($this->userId)) {
         $userXPLog = new GameUserXpLog();
         $userXPLog->setUserId($this->userId);
         $userXPLog->setXp($this->xp);
         $userXPLog->setTime($this->time);
         $userXPLog->setType($this->type);
         $userXPLog->setGameId($this->gameId);
         $userXPLog->setResult($this->result);
         $userXPLog->setOpponentId($this->opponentId);
         try {
             $user = GameUsers::getGameUserById($this->userId);
             if (!empty($user)) {
                 $userXPLog->setUserLevel($user->userLevelNumber);
                 $userXPLog->setUserCoin($user->coins);
                 //$userCoinLog->setUserSpentCoin($user->opponentId);
             }
         } catch (Exception $exc) {
             $log->logError("userxplog > log > User Error : " . $exc->getTraceAsString());
         }
         try {
             $userXPLog->insertIntoDatabase(DBUtils::getConnection());
             $log->logInfo("userxplog > log > Success");
         } catch (Exception $exc) {
             $log->logError("userxplog > log > Error : " . $exc->getTraceAsString());
         }
     } else {
         $log->logError("userxplog > log > user Id is empty ");
     }
 }
开发者ID:bsormagec,项目名称:tavlamania-php,代码行数:33,代码来源:userxplog.class.php

示例8: getGameCategoryItemWithLanguage

 public static function getGameCategoryItemWithLanguage()
 {
     $SQL = "SELECT categories.*,lang.language AS langCode,lang.text AS langText FROM " . TBL_GAME_ITEM_CATEGORY . " AS categories," . TBL_GAME_ITEM_CATEGORY_LANGUAGE . " AS lang WHERE categories.active=1 AND categories.categoryCode=lang.categoryCode ORDER BY id ASC";
     $query = mysql_query($SQL, DBUtils::getManualConnection());
     if (!empty($query)) {
         $list = array();
         $ids = array();
         $i = 0;
         while ($db_field = mysql_fetch_assoc($query)) {
             $cat = GameItemCategory::createFromSQLWithLanguage($db_field);
             if (!empty($cat)) {
                 $catId = $cat->getId();
                 if (!empty($catId)) {
                     if (isset($ids[$catId]) && isset($list[$ids[$catId]])) {
                         $oldItem = $list[$ids[$catId]];
                         $oldItem->languages = array_merge($oldItem->languages, $cat->languages);
                     } else {
                         array_push($list, $cat);
                         $ids[$catId] = $i;
                         $i++;
                     }
                 }
             }
         }
         unset($ids);
         return $list;
     }
     return array();
 }
开发者ID:bsormagec,项目名称:tavlamania-php,代码行数:29,代码来源:GameItemCategory.class.php

示例9: gameResult

 public static function gameResult(GameUsers $user, GameUsers $opponent, $roomGroupId, $action, $gameId = null, $double = 0, $normal = true, $type = null, $time = null)
 {
     $result = new FunctionResult();
     $result->success = false;
     if (!empty($user) && !empty($action)) {
         if (empty($action) || !empty($action) && $action != GameUtils::$GAME_RESULT_ACTION_WIN && $action != GameUtils::$GAME_RESULT_ACTION_LOST) {
             $result->result = "Unknown Action";
             return $result;
         }
         GameUtils::updateXP($user, $opponent, $roomGroupId, $action, $gameId, $double, $normal, $type, $time);
         GameUtils::updateCoin($user, $opponent, $roomGroupId, $action, $gameId, $double, $normal, $type, $time);
         GameUtils::updateCounts($user, $opponent, $roomGroupId, $action, $gameId, $double, $normal, $type, $time);
         if ($action == GameUtils::$GAME_RESULT_ACTION_WIN && ($type == GameUtils::$GAME_RESULT_ACTION_TYPE_LEFT || $type == GameUtils::$GAME_RESULT_ACTION_TYPE_TIMESUP) && !empty($opponent)) {
             if (empty($time)) {
                 $time = time();
             }
             Queue::userLostConnLost($opponent->userId, $user->userId, $roomGroupId, GameUtils::$GAME_RESULT_ACTION_LOST, $gameId, $double, $normal, $type, $time);
         }
         try {
             $user->updateToDatabase(DBUtils::getConnection());
             $result->success = true;
             $result->result = new stdClass();
             $result->result->user = $user;
         } catch (Exception $exc) {
             $result->success = true;
             $result->result = $exc->getTraceAsString();
         }
         return $result;
     } else {
         $result->result = "User not found";
         return $result;
     }
 }
开发者ID:bsormagec,项目名称:tavlamania-php,代码行数:33,代码来源:GameFunctions.php

示例10: setConstant

 public static function setConstant($key, $value = null)
 {
     if (!empty($key)) {
         GameConstantUtil::setCacheConstant($key, $value);
         $setting = GameConstants::findByExample(DBUtils::getConnection(), GameConstants::create()->setKey_($key));
         if (!empty($setting)) {
             if (sizeof($setting) > 0) {
                 $setting = $setting[0];
                 $k = $setting->getKey_();
                 if (empty($k)) {
                     $setting = null;
                 }
             } else {
                 $setting = null;
             }
         }
         if (!empty($setting)) {
             $setting->setValue_($value);
         } else {
             $setting = GameConstants::create();
             $setting->setKey_($key);
             $setting->setValue_($value);
         }
         $setting->updateInsertToDatabase(DBUtils::getConnection());
     }
     return false;
 }
开发者ID:bsormagec,项目名称:tavlamania-php,代码行数:27,代码来源:GameConstantFunctions.php

示例11: getNav

function getNav()
{
    $pdo = new DBUtils();
    $sql = "select * from nav";
    $nav = $pdo->query($sql);
    $header = array();
    foreach ($nav as $key => $val) {
        $header[$val['navId']] = array("navName" => $val['navName'], "navId" => $val['navId'], "second" => array());
    }
    $sql = "select * from second_nav";
    $second = $pdo->query($sql);
    foreach ($second as $key => $val) {
        $header[$val['navId']]['second'][$val['snavId']] = array("snavName" => $val['snavName'], "snavId" => $val['snavId'], "link" => $val['snavName']);
    }
    return $header;
}
开发者ID:zcmyworld,项目名称:nothing,代码行数:16,代码来源:index.php

示例12: autoLogin

 public static function autoLogin($rememberme = true)
 {
     if (isset($_SESSION["userId"])) {
         $userId = $_SESSION["userId"];
         $user = GameUsers::getGameUserById($userId);
         if (!empty($user)) {
             UtilFunctions::storeSessionUser($user, $rememberme);
             return $user;
         }
     }
     if (isset($_COOKIE["auth"]) && false) {
         $cookie = $_COOKIE["auth"];
         $arr = explode('&', $cookie);
         $userName = substr($arr[0], 4);
         $hash = substr($arr[1], 5);
         $user = GameUsers::getGameUserByUserName($userName);
         if (!empty($user)) {
             if ($hash == md5($user->getPassword())) {
                 $user->setLastLoginDate(time());
                 $user->setLoginCount($user->getLoginCount() + 1);
                 $user->updateToDatabase(DBUtils::getConnection());
                 Queue::checkUserFriends($user->userId);
                 UtilFunctions::storeSessionUser($user, $rememberme);
                 return $user;
             } else {
                 UtilFunctions::forgetMe();
             }
         }
     }
     return false;
 }
开发者ID:bsormagec,项目名称:tavlamania-php,代码行数:31,代码来源:Functions.php

示例13: saveInDatabase

    /**
     * save data in plenty_countries_of_delivery
     * 
     * @param PlentySoapObject_GetCountriesOfDelivery $countryOfDelivery
     */
    private function saveInDatabase($countryOfDelivery)
    {
        $query = 'REPLACE INTO `plenty_countries_of_delivery` 
						' . DBUtils::buildInsert(array('country_id' => $countryOfDelivery->CountryID, 'active' => $countryOfDelivery->CountryActive, 'country_name' => $countryOfDelivery->CountryName, 'iso_code_2' => $countryOfDelivery->CountryISO2));
        $this->getLogger()->debug(__FUNCTION__ . ' save country ' . $countryOfDelivery->CountryISO2 . ' ' . $countryOfDelivery->CountryName);
        DBQuery::getInstance()->replace($query);
    }
开发者ID:PhDasen,项目名称:php_soap_client_mu,代码行数:12,代码来源:Adapter_GetCountriesOfDelivery.class.php

示例14: find_by_account

 function find_by_account($account, $limit = null)
 {
     $db =& DBUtils::connect();
     $sql = 'SELECT f.id, f.url AS url FROM foaf f
         JOIN member m ON f.member_id = m.id
         WHERE m.account = ?';
     $result = $db->getAll($sql, array($account));
     if (DB::isError($result)) {
         trigger_error(__CLASS__ . '::' . __FUNCTION__ . '(): ' . $result->toString(), E_USER_ERROR);
         return null;
     }
     $parser =& new FOAFParser(true, CACHE_LITE_DIR, 60 * 60 * 24 * 1);
     $foafs = array();
     foreach ($result as $foaf) {
         if (@$parser->parse($foaf['url']) === false) {
             continue;
         }
         $people = $parser->getKnowsPerson();
         foreach ($people as $index => $person) {
             $people[$index]['foaf_id'] = $foaf['foaf_id'];
             $people[$index]['foaf_url'] = $foaf['url'];
             $p =& new FOAFParser(true, CACHE_LITE_DIR, 60 * 60 * 24 * 1);
             if ($p->parse($person['seeAlso'])) {
                 $person['img'] = $p->getImg();
             }
             $foafs[$person['seeAlso']] = $person;
         }
     }
     $res = array();
     foreach ($foafs as $foaf) {
         $res[] = $foaf;
     }
     return $res;
 }
开发者ID:komagata,项目名称:plnet,代码行数:34,代码来源:FriendUtils.php

示例15: find_with_content_category_by_account

 function find_with_content_category_by_account($account)
 {
     $db =& DBUtils::connect();
     $sql = 'SELECT cc.id AS category_id, cc.name AS category_name, mcf.feed_id
         FROM member_to_content_category_to_feed mcf
         JOIN member m ON mcf.member_id = m.id
         JOIN content_category cc ON mcf.content_category_id = cc.id
         WHERE m.account = ?';
     $result = $db->getAll($sql, array($account));
     if (DB::isError($result)) {
         trigger_error(__CLASS__ . '::' . __FUNCTION__ . '(): ' . $result->toString(), E_USER_ERROR);
         return false;
     }
     $mcfs = $result;
     $other = ContentCategoryUtils::get(PLNET_OTHER_CATEGORY_ID);
     $feeds = FeedUtils::get_feeds_by_account($account);
     $feeds_with_category = array();
     foreach ($feeds as $key => $feed) {
         foreach ($mcfs as $i => $mcf) {
             if ($feed['id'] == $mcf['feed_id']) {
                 $feed['category_id'] = $mcf['category_id'];
                 $feed['category_name'] = $mcf['category_name'];
             }
         }
         if (!isset($feed['category_id'])) {
             $feed['category_id'] = $other['id'];
             $feed['category_name'] = $other['name'];
         }
         $feeds_with_category[] = $feed;
     }
     return $feeds_with_category;
 }
开发者ID:komagata,项目名称:plnet,代码行数:32,代码来源:FeedUtils.php


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