本文整理汇总了PHP中dbconnection类的典型用法代码示例。如果您正苦于以下问题:PHP dbconnection类的具体用法?PHP dbconnection怎么用?PHP dbconnection使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了dbconnection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getTweetsPostedBy
public static function getTweetsPostedBy($idUser)
{
$connection = new dbconnection();
$sql = "select * from jabaianb.tweet where emetteur='" . $idUser . "'";
$res = $connection->doQueryObject($sql, "tweet");
return $res === false ? false : $res;
}
示例2: getPostbyId
public static function getPostbyId($id)
{
$connection = new dbconnection();
$sql = "select * from jabaianb.post where id='" . $id . "'";
$res = $connection->doQueryObject($sql, "post");
return $res === false ? false : $res;
}
示例3: save
public function save()
{
$connection = new dbconnection();
if ($this->id) {
$sql = "update jabaianb." . get_class($this) . " set ";
$set = array();
foreach ($this->data as $att => $value) {
if ($att != 'id' && $value) {
$set[] = "{$att} = '" . $value . "'";
}
}
$sql .= implode(",", $set);
$sql .= " where id=" . $this->id;
} else {
$sql = "insert into jabaianb." . get_class($this) . " ";
$sql .= "(" . implode(",", array_keys($this->data)) . ") ";
$sql .= "values ('" . implode("','", array_values($this->data)) . "')";
}
$connection->doExec($sql);
/*
* Sans cette modiffication, on recevait une erreur après un UPDATE:
* Object not in prerequisite state: 7 ERROR: currval of sequence "post_id_seq" is not yet defined in this session
*/
if (!$this->id) {
$this->id = $connection->getLastInsertId("jabaianb." . get_class($this));
}
return $this->id == false ? NULL : $this->id;
}
示例4: getLike
public static function getLike($id)
{
$connection = new dbconnection();
$sql = "select count(*) from jabaianb.vote where tweet='" . $id . "'";
$res = $connection->doQuery($sql);
return $res === false ? false : $res;
}
示例5: getUsers
public static function getUsers()
{
$connection = new dbconnection();
$sql = "select * from jabaianb.utilisateur";
$res = $connection->doQueryObject($sql, "utilisateurTable");
return $res === false ? false : $res;
}
示例6: getCountLastTweets
public static function getCountLastTweets($startDate)
{
$connection = new dbconnection();
$sql = "SELECT COUNT(*) FROM jabaianb.tweet T\n\t\t INNER JOIN jabaianb.post P ON (T.post = P.id)\n\t\t WHERE P.date > '" . $startDate . "'";
$res = $connection->doQuery($sql);
if ($res === false) {
return null;
}
return $res[0]["count"];
}
示例7: getCountLikesById
public static function getCountLikesById($tweetId)
{
$connection = new dbconnection();
$sql = "SELECT COUNT(*) FROM jabaianb.vote WHERE message = " . $tweetId;
$res = $connection->doQuery($sql);
if ($res === false) {
return 0;
}
return $res[0]["count"];
}
示例8: getUsersWhoLikeTweetById
public static function getUsersWhoLikeTweetById($tweetId)
{
$connection = new dbconnection();
$sql = "SELECT U.* FROM jabaianb.utilisateur U\r\n\t\t\t\t\tINNER JOIN jabaianb.vote V ON (U.id = V.utilisateur)\r\n\t\t\t\tWHERE V.message = " . $tweetId;
$res = $connection->doQueryObject($sql, "utilisateur");
if ($res === false) {
return null;
}
return $res;
}
示例9: preload_lists
function preload_lists()
{
$db = new dbconnection();
$db->dbconnect();
$db->query = "select listid,listname from " . TABLE_LISTS . " where active=1";
$db->execute();
$rowcount = $db->rowcount();
if ($rowcount > 0) {
for ($x = 0; $x < $rowcount; $x++) {
$row = $db->fetchrow($x);
$list[$x] = $row;
}
}
return $list;
}
示例10: getColors
public static function getColors($pack)
{
$sql_colors = dbconnection::queryObject("SELECT * FROM colors WHERE colors_id = '{$pack->colors_id}' LIMIT 1");
if (!$sql_colors) {
return new return_package(2, NULL, "The colors you've requested do not exist");
}
return new return_package(0, colors::colorsObjectFromSQL($sql_colors));
}
示例11: getCategoryHints
public function getCategoryHints($q)
{
$query = "select categoryid,name from couponcategories where name LIKE '" . htmlspecialchars($q) . "%'" . " limit 1";
$dbinstance = dbconnection::getinstance();
$connhandle = $dbinstance->connhandle;
$result = $connhandle->query($query);
return $result;
}
示例12: getinstance
public static function getinstance()
{
if (!isset(self::$instance)) {
self::$instance = new dbconnection();
} else {
//echo "singleton construct not called";
}
return self::$instance;
}
示例13: removeEditorFromGame
public static function removeEditorFromGame($pack)
{
$pack->auth->game_id = $pack->game_id;
$pack->auth->permission = "read_write";
if (!editors::authenticateGameEditor($pack->auth)) {
return new return_package(6, NULL, "Failed Authentication");
}
//note $pack->user_id is DIFFERENT than $pack->auth->user_id
dbconnection::query("DELETE FROM user_games WHERE user_id = '{$pack->user_id}' AND game_id = '{$pack->game_id}'");
games::bumpGameVersion($pack);
return new return_package(0);
}
示例14: changepassword
function changepassword($userid, $oldpass, $newpass, $newpassrepeat)
{
if ($newpass == $newpassrepeat) {
$enc = new Encryption();
$db = new dbconnection();
$db->dbconnect();
//check oldpass, update password if ok, send message if not
$password = $enc->oneway_encode($oldpass);
$db->query = "select userid from " . TABLE_USERS . " where userid={$userid} and password='{$password}'";
$db->execute();
if ($db->rowcount() > 0) {
$newpass = $enc->oneway_encode($newpass);
$db->query = "update " . TABLE_USERS . " set password='{$newpass}' where userid={$userid}";
$db->execute();
$msg = 'Password updated.';
} else {
$msg = 'Incorrect old password.';
}
} else {
$msg = 'New password does not match.';
}
return $msg;
}
示例15: deleteGroup
public static function deleteGroup($pack)
{
$group = dbconnection::queryObject("SELECT * FROM groups WHERE group_id = '{$pack->group_id}'");
$pack->auth->game_id = $group->game_id;
$pack->auth->permission = "read_write";
if (!editors::authenticateGameEditor($pack->auth)) {
return new return_package(6, NULL, "Failed Authentication");
}
dbconnection::query("DELETE FROM groups WHERE group_id = '{$pack->group_id}' LIMIT 1");
//cleanup
dbconnection::query("UPDATE game_user_groups SET group_id = 0 WHERE game_id = '{$group->game_id}' AND group_id = '{$group->group_id}';");
games::bumpGameVersion($pack);
return new return_package(0);
}