本文整理汇总了PHP中getDb函数的典型用法代码示例。如果您正苦于以下问题:PHP getDb函数的具体用法?PHP getDb怎么用?PHP getDb使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了getDb函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
开发者ID:Orion24,项目名称:m151admin_nbe,代码行数:7,代码来源:function_read_db.php
示例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');
}
开发者ID:nicolargo,项目名称:frontend,代码行数:37,代码来源:PhotoController.php
示例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'];
}
开发者ID:omusico,项目名称:jianli,代码行数:25,代码来源:function.php
示例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')");
}
开发者ID:acyuta,项目名称:simple_php_api_net,代码行数:29,代码来源:setupDB.php
示例5: getPersons
function getPersons()
{
$db = getDb();
$query = $db->prepare('SELECT DISTINCT person FROM photo2person ORDER BY person ASC');
$query->execute();
return $query->fetchAll();
}
开发者ID:dattn,项目名称:wedding-gallery,代码行数:7,代码来源:init.php
示例6: __construct
public function __construct()
{
$this->config = getConfig()->get();
$this->db = getDb();
$this->utility = new Utility();
$this->user = new User();
}
开发者ID:hfiguiere,项目名称:frontend,代码行数:7,代码来源:LoginSelf.php
示例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());
}
开发者ID:CarlTaylor1989,项目名称:sap-intel-vrst,代码行数:33,代码来源:register.php
示例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);
}
开发者ID:Orion24,项目名称:AWebTheFestival,代码行数:7,代码来源:function_db_select.php
示例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);
}
开发者ID:roseblumentopf,项目名称:mywatchlst,代码行数:8,代码来源:movie_data.php
示例10: getUserRow
function getUserRow($name)
{
$db = getDb();
$sqlStr = 'SELECT * FROM user WHERE name = ?';
$sqlOperation = $db->prepare($sqlStr);
$sqlOperation->execute(array($name));
return $sqlOperation->fetchAll();
}
开发者ID:JoshuaRichards,项目名称:php-todo,代码行数:8,代码来源:db.php
示例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();
}
开发者ID:Orion24,项目名称:AWebTheFestival,代码行数:9,代码来源:function_db_insert.php
示例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);
}
}
开发者ID:gg1977,项目名称:frontend,代码行数:10,代码来源:ApiOAuthController.php
示例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;
}
}
开发者ID:alexzhxin,项目名称:erp.librairielabourse,代码行数:10,代码来源:Access.class.php
示例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));
}
开发者ID:gg1977,项目名称:frontend,代码行数:16,代码来源:ApiController.php
示例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;
}
}
开发者ID:alexzhxin,项目名称:erp.librairielabourse,代码行数:11,代码来源:Magasin.class.php
示例16: reportNewSpeakersPerCon
function reportNewSpeakersPerCon()
{
$conn = getDb();
$sql = "SELECT event.start_date, event.name, talks_count, num_speakers, new_speakers, FORMAT((new_speakers/event.num_speakers)*100, 1) AS percent_new\n FROM event\n WHERE start_date >= '2010-01-01'\n ORDER BY start_date";
$stmt = $conn->executeQuery($sql);
$rows = $stmt->fetchAll();
$header = ['Date', 'Event', 'Total sessions', 'Speakers', 'New speakers', 'Percent new'];
$stmt = $conn->executeQuery("SELECT 'N/A', 'Average', FORMAT(AVG(talks_count), 1), FORMAT(AVG(num_speakers), 1), FORMAT(AVG(new_speakers), 1), FORMAT(AVG(percent_new), 1) FROM ({$sql}) AS stuff");
$averages = $stmt->fetch();
return makeHtmlTable('First time speakers', $header, $rows, $averages);
}
开发者ID:heiglandreas,项目名称:joindinaudit,代码行数:11,代码来源:report.php
示例17: execute
private function execute($sql, indirizzi $indirizzi)
{
$statement = $this->getDb()->prepare($sql);
$this->executeStatement($statement, $this->getParams($indirizzi));
if (!$indirizzi->getID()) {
return $this->findById($this - getDb()->lastInsertId());
}
if (!$statement->rowCount()) {
throw new NotFoundException('indirizzi with ID "' . $indirizzi->getID() . ' "does not exist.');
}
return $indirizzi;
}
开发者ID:blackvalmiki,项目名称:bee-friend,代码行数:12,代码来源:DAOIndirizzi.php
示例18: makeFirstAppearanceIndex
function makeFirstAppearanceIndex()
{
$conn = getDb();
$conn->transactional(function (Connection $conn) {
$conn->executeQuery("DELETE FROM first_appearance");
$result = $conn->executeQuery("SELECT DISTINCT speaker FROM talk");
$stmt = $conn->prepare("INSERT INTO first_appearance\n SELECT talk.speaker as speaker, event.uri as event_uri, event.start_date as event_date, event.name as event_name\n FROM event\n INNER JOIN talk ON event.uri = talk.event_uri\n WHERE talk.speaker = :name\n ORDER BY event.start_date\n LIMIT 1");
foreach ($result as $record) {
$stmt->execute(['name' => $record['speaker']]);
}
});
}
开发者ID:heiglandreas,项目名称:joindinaudit,代码行数:12,代码来源:derive.php
示例19: delete
function delete($delete_no)
{
try {
$db = getDb();
$stt = $db->prepare("delete from bbs_data where no = :delete_no and user_id = :user_id");
$stt->bindValue(':delete_no', $delete_no);
$stt->bindValue(':user_id', $_SESSION['user_id']);
$stt->execute();
} catch (Exception $e) {
die("エラーメッセージ:{$e->getMessage()}");
}
}
开发者ID:ryu23896,项目名称:bbs,代码行数:12,代码来源:delete.php
示例20: getNbProduits
public function getNbProduits()
{
if (!isset($this->nbProduits[$this->magasin][$this->date])) {
$query = getDb()->prepare("SELECT COUNT(*) FROM produits_encaisses\n\t\t\t\tWHERE date = ? AND magasin = ?");
$query->execute(array($this->date, $this->magasin));
$res = $query->fetch();
$this->nbProduits[$this->magasin][$this->date] = $res["COUNT(*)"];
return $res["COUNT(*)"];
} else {
return $this->nbProduits[$this->magasin][$this->date];
}
}
开发者ID:alexzhxin,项目名称:erp.librairielabourse,代码行数:12,代码来源:Viewer.class.php
注:本文中的getDb函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论