本文整理汇总了PHP中getDb函数的典型用法代码示例。如果您正苦于以下问题:PHP getDb函数的具体用法?PHP getDb怎么用?PHP getDb使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getDb函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getIfSportIsEnabled
function getIfSportIsEnabled($sport)
{
$request = getDb()->prepare("SELECT actif FROM sport WHERE nom = :sport");
$request->bindParam(':sport', $sport, PDO::PARAM_STR);
$request->execute();
return $request->fetchAll(PDO::FETCH_ASSOC);
}
示例2: create
/**
* Create a new version of the photo with ID $id as specified by $width, $height and $options.
*
* @param string $id ID of the photo to create a new version of.
* @param string $hash Hash to validate this request before creating photo.
* @param int $width The width of the photo to which this URL points.
* @param int $height The height of the photo to which this URL points.
* @param int $options The options of the photo wo which this URL points.
* @return string HTML
*/
public function create($id, $hash, $width, $height, $options = null)
{
$fragment = $this->photo->generateFragment($width, $height, $options);
// We cannot call the API since this may not be authenticated.
// Rely on the hash to confirm it was a valid request
$db = getDb();
$photo = $db->getPhoto($id);
if ($photo) {
}
// check if this size exists
if (isset($photo["path{$fragment}"]) && stristr($photo["path{$fragment}"], "/{$hash}/") === false) {
$url = $this->photo->generateUrlPublic($photo, $width, $height, $options);
$this->route->redirect($url, 301, true);
return;
} else {
// TODO, this should call a method in the API
$photo = $this->photo->generate($id, $hash, $width, $height, $options);
// TODO return 404 graphic
if ($photo) {
header('Content-Type: image/jpeg');
readfile($photo);
unlink($photo);
return;
}
}
$this->route->run('/error/500');
}
示例3: checkSession
function checkSession()
{
$oDb = getDb();
$key = $_COOKIE['SN_KEY'];
if (empty($key)) {
return false;
}
$data = $oDb->fetchFirstArray("SELECT * FROM tb_session WHERE `key` = '{$key}'");
//$data = $this->where(array('key'=>$key))->find();
if (empty($data)) {
return false;
}
//超过2小时过期
if ($data['expire'] + 7200 < time()) {
return false;
}
//ip变化
if (get_client_ip() != $data['ip']) {
return false;
}
//更新有效期
$oDb->update('tb_session', array('expire' => time() + 7200), "id = " . $data['id']);
//$this->where(array('id'=>$data['id']))->data(array('expire' => time() + 7200))->save();
return $data['uid'];
}
示例4: setupAdmin
function setupAdmin($config)
{
checkDbAccess($config);
$user_sql = "CREATE TABLE `users` ( `id` INT UNSIGNED NOT NULL AUTO_INCREMENT ,\n`name` VARCHAR(32) NOT NULL ,\n`password` TEXT NOT NULL ,\n`auth_key` TEXT NOT NULL ,\n`created` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP,\nPRIMARY KEY (`id`),\nUNIQUE (`name`)\n) ENGINE = InnoDB;";
$group_sql = "CREATE TABLE `groups` ( `id` INT UNSIGNED NOT NULL AUTO_INCREMENT , `name` VARCHAR(64) NOT NULL , `created` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP , PRIMARY KEY (`id`), UNIQUE (`name`)) ENGINE = InnoDB;";
$agent_group = "CREATE TABLE `agent_group` (`agent_id` INT UNSIGNED NOT NULL, `group_id` INT UNSIGNED NOT NULL, UNIQUE (`agent_id`, `group_id`)) ENGINE = InnoDB;";
$task_group = "CREATE TABLE `task_group` (`task_id` INT UNSIGNED NOT NULL, `group_id` INT UNSIGNED NOT NULL, UNIQUE (`task_id`, `group_id`)) ENGINE = InnoDB;";
$task_types = "CREATE TABLE `task_types` (`id` INT UNSIGNED NOT NULL AUTO_INCREMENT , `name` VARCHAR(64) NOT NULL , PRIMARY KEY (`id`), UNIQUE (`name`)) ENGINE = InnoDB";
$fk_group_id = "ALTER TABLE `task_group` ADD CONSTRAINT `fk_task_group_id` FOREIGN KEY (`group_id`) REFERENCES `groups`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;";
$fk_task_id = "ALTER TABLE `task_group` ADD CONSTRAINT `fk_task_task_id` FOREIGN KEY (`task_id`) REFERENCES `task`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;";
$fk_agent_group_id = "ALTER TABLE `agent_group` ADD CONSTRAINT `fk_agent_group_id` FOREIGN KEY (`group_id`) REFERENCES `groups`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;";
$fk_agent_agent_id = "ALTER TABLE `agent_group` ADD CONSTRAINT `fk_agent_agent_id` FOREIGN KEY (`agent_id`) REFERENCES `agent`(`id`) ON DELETE CASCADE ON UPDATE CASCADE;";
$default_task_types = "INSERT INTO task_types (`name`) VALUES ('DOWNLOADFILE'),('SELFDESTRUCTION')";
$db = getDb($config);
$t = $db->beginTransaction();
if (!$t) {
die("cannot create DB transaction");
}
execSql($db, $user_sql, "create user table");
execSql($db, $group_sql, "create groups table");
execSql($db, $task_types, "create task types table");
execSql($db, $default_task_types, "add default task types");
execSql($db, $agent_group, "create agent-group table");
execSql($db, $task_group, "create task-group table");
execSql($db, $fk_group_id, "make foreign key on task_group ('group_id')");
execSql($db, $fk_task_id, "make foreign key on task_group ('task_id')");
execSql($db, $fk_agent_agent_id, "make foreign key on agent_group ('agent_id')");
execSql($db, $fk_agent_group_id, "make foreign key on agent_group ('group_id')");
}
示例5: getPersons
function getPersons()
{
$db = getDb();
$query = $db->prepare('SELECT DISTINCT person FROM photo2person ORDER BY person ASC');
$query->execute();
return $query->fetchAll();
}
示例6: __construct
public function __construct()
{
$this->config = getConfig()->get();
$this->db = getDb();
$this->utility = new Utility();
$this->user = new User();
}
示例7: addUser
function addUser($email, $first_name, $last_name, $phone, $address, $town, $organization, $country, $zip, $october6, $october7, $october8, $october9, $october10, $msg_email, $msg_phone)
{
$db = getDb();
//$db->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION );
try {
$stmt = $db->prepare('INSERT INTO users (email, first_name, last_name, phone, address, town, organization, country, zip, october6, october7, october8, october9, october10, msg_email, msg_phone)
VALUES ("' . $email . '", "' . $first_name . '", "' . $last_name . '", "' . $phone . '", "' . $address . '", "' . $town . '", "' . $organization . '", "' . $country . '", "' . $zip . '", ' . $october6 . ', ' . $october7 . ', ' . $october8 . ', ' . $october9 . ', ' . $october10 . ', ' . $msg_email . ', ' . $msg_phone . ')');
// $stmt = $db->prepare('INSERT INTO users (email, first_name, last_name, phone, address, town, organization, country, zip, october6, october7, october8, october9, october10, msg_email, msg_phone)
// VALUES ("' . $email .'", "' . $first_name .'", "' . $last_name .'", "' . $phone .'", "' . $address .'", "' . $town .'", "' . $organization .'", "' . $country .'", "' . $zip .'", true, false, true, true, false, true, true)');
/*$stmt->bindValue(':email', $email, PDO::PARAM_STR);
$stmt->bindValue(':first_name', $first_name, PDO::PARAM_STR);
$stmt->bindValue(':last_name', $last_name, PDO::PARAM_STR);
$stmt->bindValue(':phone', $phone, PDO::PARAM_STR);
$stmt->bindValue(':address', $address, PDO::PARAM_STR);
$stmt->bindValue(':town', $town, PDO::PARAM_STR);
$stmt->bindValue(':organization', $organization, PDO::PARAM_STR);
$stmt->bindValue(':country', $country, PDO::PARAM_STR);
$stmt->bindValue(':zip', $zip, PDO::PARAM_STR);
$stmt->bindValue(':october6', $october6, PDO::PARAM_BOOL);
$stmt->bindValue(':october7', $october7, PDO::PARAM_BOOL);
$stmt->bindValue(':october8', $october8, PDO::PARAM_BOOL);
$stmt->bindValue(':october9', $october9, PDO::PARAM_BOOL);
$stmt->bindValue(':october10', $october10, PDO::PARAM_STR);
$stmt->bindValue(':msg_email', $msg_email, PDO::PARAM_BOOL);
$stmt->bindValue(':msg_phone', $msg_phone, PDO::PARAM_BOOL); */
$stmt->execute();
// TODO: This does not work, please fix
} catch (PDOException $e) {
// echo $e->getMessage();
}
sendEmail($first_name, $last_name, $october6, $october7, $october8, $october9, $october10, $email);
// print_r($db->errorInfo());
}
示例8: get_name_artist
function get_name_artist($limit)
{
$request = getDb()->prepare('SELECT nameArtist FROM artists LIMIT :limitArtist');
$request->bindParam(':limitArtist', $limit, PDO::PARAM_INT);
$request->execute();
return $request->fetchAll(PDO::FETCH_ASSOC);
}
示例9: getRow
function getRow()
{
$test = getId();
$server = getDb();
$sql = "SELECT id, imdb_id, adult, backdrop_path, genres, original_title, overview, popularity, poster_path, runtime, release_date, vote_average, vote_count, director, cast, trailer FROM tmdb_movies WHERE id='{$test}' LIMIT 1";
$query = mysqli_query($server, $sql);
return $row = mysqli_fetch_row($query);
}
示例10: getUserRow
function getUserRow($name)
{
$db = getDb();
$sqlStr = 'SELECT * FROM user WHERE name = ?';
$sqlOperation = $db->prepare($sqlStr);
$sqlOperation->execute(array($name));
return $sqlOperation->fetchAll();
}
示例11: insert_comment_schedule
function insert_comment_schedule($idUser, $idSchedule, $content)
{
$request = getDb()->prepare("INSERT INTO `festival`.`comment` (`idComment`, `idUser`, `idSchedule`, `idArtist`, `dateCommentaire`, `content`, `isArtist`) VALUES (NULL, :idUser, :idSchedule, 0, :date, :content, 0);");
$request->bindParam(':content', $content, PDO::PARAM_STR, 200);
$request->bindParam(':idSchedule', $idSchedule, PDO::PARAM_INT);
$request->bindParam(':idUser', $idUser, PDO::PARAM_INT);
$request->bindParam(':date', date("Y-m-j"), PDO::PARAM_STR);
$request->execute();
}
示例12: list_
public function list_()
{
getAuthentication()->requireAuthentication();
$res = getDb()->getCredentials();
if ($res !== false) {
return $this->success('Oauth Credentials', $res);
} else {
return $this->error('Could not retrieve credentials', false);
}
}
示例13: isAllowed
public function isAllowed()
{
$query = getDb()->prepare("SELECT id FROM module_allowed WHERE module_name = ? AND username = ?");
$query->execute(array($this->module, $this->username));
if ($query->rowCount() > 0) {
return true;
} else {
return false;
}
}
示例14: version
/**
* API to get versions of the source, filesystem and database
*
* @return string Standard JSON envelope
*/
public function version()
{
getAuthentication()->requireAuthentication();
$apiVersion = Request::getLatestApiVersion();
$systemVersion = getConfig()->get('site')->lastCodeVersion;
$databaseVersion = getDb()->version();
$databaseType = getDb()->identity();
$filesystemVersion = '0.0.0';
$filesystemType = getFs()->identity();
return $this->success('System versions', array('api' => $apiVersion, 'system' => $systemVersion, 'database' => $databaseVersion, 'databaseType' => $databaseType, 'filesystem' => $filesystemVersion, 'filesystemType' => $filesystemType));
}
示例15: isAlive
public function isAlive()
{
$query = getDb()->prepare("SELECT timestamp FROM alive WHERE localisation = ?");
$query->execute(array($this->nom));
$row = $query->fetch();
if ($row['timestamp'] / 1000 > time() - 15000) {
return true;
} else {
return false;
}
}