本文整理汇总了PHP中connectDb函数的典型用法代码示例。如果您正苦于以下问题:PHP connectDb函数的具体用法?PHP connectDb怎么用?PHP connectDb使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了connectDb函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: selectDb
function selectDb($config)
{
if (connectDb($config)) {
return mysql_selectdb($config['db']['dbname']);
}
return false;
}
示例2: insertComment
function insertComment($username, $text) {
// if were not connected, connect.
global $isConnected;
if (isset($isConnected) == false)
connectDb ();
//Escape all strings and use the strip_tags() to be more safe
$safe_strings = TRUE;
function safeString($string){
$string = mysql_real_escape_string(strip_tags($string));
return $string;
}
$username = safeString($username);
$text = safeString($text);
//$username = mysql_real_escape_string($username);
//$ $text = mysql_real_escape_string($text);
// date and time
$date = getCurrentDate();
//Inserts a comment dB.
mysql_query("INSERT INTO comment (`username`, `text`, `date`) VALUES ('$username' , '$text', '$date')")
or die("Something went wrong with the insert query" . mysql_error());
}
示例3: getDiaryData
function getDiaryData($person_id, $date = null)
{
$db = connectDb();
$sql_arg = array(":id" => $person_id);
$date_sql = null;
if ($date != null) {
$sql_arg[":date"] = sprintf("%04d", $date);
$date_sql = "AND DATE_FORMAT(a_diary.create_day, \"%Y%m%d\")= :date";
}
$sql = <<<SQL_END
SELECT
\ta_diary.create_day,
\tDATE_FORMAT(a_diary.create_day, "%Y%m%d") AS yyyymmdd,
\ta_diary.post,
\ta_person.name
FROM a_diary
LEFT JOIN a_person
\tON a_person.person_id = a_diary.person_id
WHERE a_diary.person_id = :id
{$date_sql}
ORDER BY a_diary.create_day
;
SQL_END;
$stmt = $db->prepare($sql);
$stmt->execute($sql_arg);
if ($date != null) {
return $stmt->fetch(PDO::FETCH_ASSOC);
}
return $stmt->fetchAll(PDO::FETCH_ASSOC);
}
示例4: insertNewExercise
function insertNewExercise($data)
{
$sql = "INSERT INTO exercises SET topic = \"{$data->topic}\", exercise = \"{$data->exercise}\", enable = \"{$data->enable}\"";
$mysqli = connectDb();
$mysqli->query($sql);
echo $mysqli->insert_id;
closeDb($mysqli);
}
示例5: insertSolution
function insertSolution($mysqli, $data)
{
$sql = "INSERT INTO solvings SET studentName = \"{$data->studentName}\", solving = \"{$data->solving}\", class = \"{$data->class}\", topic = \"{$data->topic}\", ip = \"{$_SERVER['REMOTE_ADDR']}\", exerciseId = \"{$data->exerciseId}\", teacherName = \"{$data->teacherName}\"";
$mysqli = connectDb();
//~ dblog($mysqli, "sql: $sql");
$mysqli->query($sql);
closeDb($mysqli);
}
示例6: __construct
public function __construct($db)
{
require_once 'bdd/gestion_bdd.php';
if (is_null($db)) {
$this->_db = connectDb();
} else {
$this->_db = $db;
}
}
示例7: getimage
function getimage($a)
{
$dbh = connectDb();
$sql = "select * from images where id = " . $a;
$stmt = $dbh->query($sql);
$stmt->execute;
$image = $stmt->fetch();
return $image;
}
示例8: loadView
function loadView()
{
global $app;
load_head();
$mysqli = connectDb();
$ids = getEnableds($mysqli);
$teacherNames = getTeacherNames($mysqli);
showStudentForm($ids, $teacherNames);
closeDb($mysqli);
load_foot();
}
示例9: loadDonView
function loadDonView()
{
global $app;
load_head();
echo $app["version"];
$mysqli = connectDb();
$ids = getEnableds($mysqli);
showTeacherForm($ids);
closeDb($mysqli);
load_foot();
}
示例10: getGenreName
function getGenreName($genre_id)
{
$name = "";
$pdo = connectDb();
$sql = "SELECT * FROM genre WHERE genre_id=?";
$stmt = $pdo->prepare($sql);
$stmt->bindValue(1, $genre_id, PDO::PARAM_INT);
$stmt->execute();
foreach ($stmt as $row) {
$name = $row["name"];
}
$pdo = null;
return $name;
}
示例11: initializeSystemSettings
function initializeSystemSettings()
{
global $dbHost, $dbUser, $dbUserPw, $dbName, $includeDumpJs;
global $gorumroll, $speedStopWatch, $gorumview, $jQueryLib;
$_GET = filterInput($_GET);
$_COOKIE = filterInput($_COOKIE);
$_SERVER = filterInput($_SERVER);
$_FILES = filterInput($_FILES);
if (class_exists("speedstat")) {
$speedStopWatch = new Stopwatch();
$speedStopWatch->start();
}
ini_set("session.use_cookies", 1);
ini_set("session.use_only_cookies", 1);
ini_set("session.use_trans_sid", 0);
if (!session_id()) {
session_start();
}
$this->kbfu = chr(103) . chr(111) . chr(114) . chr(117) . chr(109) . chr(117) . chr(115) . chr(101) . chr(114);
$this->kbfk = chr(105) . chr(115) . chr(65) . chr(100) . chr(109);
$this->kbfr = chr(103) . chr(111) . chr(114) . chr(117) . chr(109) . chr(114) . chr(101) . chr(99) . chr(111) . chr(103) . chr(110) . chr(105) . chr(115) . chr(101) . chr(100);
// http://hu.php.net/manual/en/reserved.variables.session.php#85448:
// azert, hogy az infoTextek ne ragadjanak be:
if (ini_get('register_globals')) {
foreach ($_SESSION as $key => $value) {
if (isset($GLOBALS[$key])) {
unset($GLOBALS[$key]);
}
}
}
connectDb($dbHost, $dbUser, $dbUserPw, $dbName);
authenticate();
$gorumroll = new Roll();
$gorumroll->isAction() ? include GORUM_DIR . "/gorum_action.php" : (include GORUM_DIR . "/gorum_view.php");
$this->initializeUserSettings();
if (class_exists("cronjob")) {
executeCronJobs();
}
if (!$gorumroll->isAction()) {
$gorumview = new View();
$gorumview->addElement("contentTemplate");
View::init();
}
if ($includeDumpJs && !$gorumroll->isAction()) {
JavaScript::addInclude(GORUM_JS_DIR . $jQueryLib);
JavaScript::addInclude(GORUM_JS_DIR . "/jquery/jquery.dump.js");
JavaScript::addInclude(GORUM_JS_DIR . "/dump.js");
}
$this->kbf();
}
示例12: getDiaryByPersonId
function getDiaryByPersonId($person_id)
{
$db = connectDb();
$sql = <<<END_SQL
SELECT
\ta_diary.create_day,
\tDATE_FORMAT(a_diary.create_day, "%Y%m%d") AS yyyymmdd,
\ta_person.name
FROM a_diary
LEFT JOIN a_person
\tON a_person.person_id = a_diary.person_id
WHERE a_diary.person_id = :id
ORDER BY create_day
;
END_SQL;
$stmt = $db->prepare($sql);
$stmt->execute(array(":id" => $person_id));
return $stmt->fetchAll(PDO::FETCH_ASSOC);
}
示例13: getDiaryByPersonIdAndDate
function getDiaryByPersonIdAndDate($id, $date)
{
$dbh = connectDb();
$sql = <<<SQL_END
SELECT
\ta_person.name,
\ta_diary.create_day,
\ta_diary.post
FROM a_diary
LEFT JOIN a_person
\tON a_person.person_id = a_diary.person_id
WHERE
\ta_person.person_id = :id
\tAND a_diary.create_day = :date
;
SQL_END;
$stmt = $dbh->prepare($sql);
$stmt->execute(array(':id' => $id, ':date' => $date));
return $stmt->fetch(PDO::FETCH_ASSOC);
}
示例14: create_user
function create_user($account, $password, $email)
{
connectDb();
# check if username is already exists
if (username_exists($account)) {
return false;
}
$password = md5($password);
# add new user
global $pdo;
$stmt = $pdo->prepare('
INSERT INTO user_table
(username, password,email)
values (:username, :password, :email)');
$stmt->execute(array(':username' => $account, ':password' => $password, ':email' => $email));
if ($pdo->lastInsertId()) {
header('Location:index.php');
} else {
return false;
}
}
示例15: getMovieInfo
function getMovieInfo($post)
{
$post = '\'' . $post . '\'';
$sql = '
SELECT
title AS title,
title_origin AS title_origin,
year AS year,
country AS country,
duration AS duration,
director AS director,
writer AS writer,
cast AS cast
FROM movie WHERE id=' . $post . ' LIMIT 0, 1
';
header('Content-Type/json: application/json');
// MySQLの返り値が null([]) でない場合に実行
if (json_encode(connectDb()->query($sql)->fetchAll(PDO::FETCH_ASSOC)) != '[]') {
echo "{movie: " . json_encode(connectDb()->query($sql)->fetchAll(PDO::FETCH_ASSOC)) . "}";
}
}