本文整理汇总了PHP中DatabaseConnection类的典型用法代码示例。如果您正苦于以下问题:PHP DatabaseConnection类的具体用法?PHP DatabaseConnection怎么用?PHP DatabaseConnection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DatabaseConnection类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: restoreUserFromUsername
public function restoreUserFromUsername( DatabaseConnection $connection ) {
if(!isset($connection) || !isset($this->username)) {
$this->isAuthenticated = false;
return$this->isAuthenticated;
}
if( !$connection->isConnected ) {
if( !$connection->Connect() ){
return $this->isAuthenticated;
}
}
$query = "select userId, username, userLevel, ipaddress, isLoggedIn, lastLogin from users where username='{$this->username}';";
if( !$connection->query( $query ) ) {
return $this->isAuthenticated;
}
if( 1 > $connection->getNumRows() ) {
//echo "user {$query}";
//print_r($connection->getObject());
return $this->isAuthenticated;
}
$user = $connection->getObject();
$this->userLevel = $user->userLevel;
$this->lastLogin = $user->lastLogin;
$this->ipaddress = $user->ipaddress;
$this->isAuthenticated = $user->isLoggedIn;
}
示例2: loadWikiPage
/**
* @brief Loads a wiki page
*
* Will attempt to load a wiki page from the database. If revision is not
* specified, the latest revision will be loaded.
*
* @param String $page
* @param Int $revision
* @return Boolean True on success, false otherwise
*/
function loadWikiPage($page, $revision = null)
{
$db = new DatabaseConnection();
list($ns, $name) = $this->splitUri($page, 'wiki');
if (!$revision) {
$pd = $db->getSingleRow("SELECT * FROM wikipages WHERE pagens=%s AND pagename=%s " . "ORDER BY revision DESC LIMIT 1;", $ns, $name);
} else {
$pd = $db->getSingleRow("SELECT * FROM wikipages WHERE pagens=%s AND pagename=%s AND " . "revision<%d ORDER BY revision DESC LIMIT 1;", $ns, $name, $revision);
}
if ($pd) {
$revs = $db->getSingleRow("SELECT revision FROM wikipages WHERE pagens=%s AND pagename=%s", $ns, $name);
foreach ($revs as $rev) {
$this->revisions[] = $rev['revision'];
}
if ($pd['format'] != NULL) {
$this->markup = $pd['markuptype'];
$this->parser = markup::factory($this->markup);
}
$this->content = $pd['content'];
$this->pagerevision = $pd['revision'];
$this->modified = false;
$this->pagens = $pd['pagens'];
$this->pagename = $pd['pagename'];
$this->pagetitle = $pd['pagetitle'];
return true;
} else {
return false;
}
}
示例3: getUserList
public function getUserList()
{
$dbconn = new DatabaseConnection('localhost', 'user', 'password');
$results = $dbconn->query('select name from user');
sort($results);
return $results;
}
示例4: refreshUserList
public function refreshUserList()
{
//assim evitamos a necessidade de consultar o banco a cada requisição de lista
$dbconn = new DatabaseConnection('localhost', 'user', 'password');
$results = $dbconn->query('select name from user');
$this->setUserList(sort($results));
}
示例5: addSubjects
function addSubjects($name)
{
$sql = "INSERT INTO subjects VALUES ('', ?)";
$string = array($name);
$db = new DatabaseConnection("localhost", "adminuser", "asd12345", "school");
$db->queryWithoutResult($sql, $string, true, "s");
}
示例6: get
/**
* Get constraint type handler for driver
*
* @param \DatabaseConnection $connection
* @param string $type
*
* @return ConstraintInterface
*/
public function get(\DatabaseConnection $connection, $type)
{
$driver = $connection->driver();
if (isset($this->instances[$driver][$type])) {
return $this->instances[$driver][$type];
}
return $this->instances[$driver][$type] = $this->createInstance($connection, $type);
}
示例7: staticText
function staticText($slug)
{
$db = new DatabaseConnection();
$text = $db->getSingleRow("SELECT * FROM statictext WHERE slug=%s", $slug);
if ($text) {
return $text['content'];
}
}
示例8: showStart
function showStart()
{
$this->loadTemplate();
$controller = new DatabaseConnection();
$controller->raw('CALL registraVisita()');
$controller = null;
include 'view/welcome.php';
}
示例9: getStudentIds
function getStudentIds()
{
$db = new DatabaseConnection("localhost", "adminuser", "asd12345", "school");
$sql = "SELECT id FROM students";
$string = array();
$res = $db->select($sql, $string, false, '');
return $res;
}
示例10: getListaUsuario
public function getListaUsuario($dbconn = null)
{
if (!isset($dbconn) || !$dbconn instanceof DatabaseConnection) {
$dbconn = new DatabaseConnection('localhost', 'root', '');
}
$results = $dbconn->query('SELECT name FROM users');
sort($results);
return $results;
}
示例11: deleteLocation
public function deleteLocation($id)
{
$db = new DatabaseConnection();
$conn = $db->connectToDB();
$result = $db->updateDatabase("DELETE FROM location where id = {$id}");
$db->closeDBConnection($conn);
header("Content-Type: application/json");
echo json_encode($result);
}
示例12: submitComment
public function submitComment()
{
$conn = new DatabaseConnection();
if (!isset($_GET['replyid'])) {
$sentence = 'CALL addComment(' . $_SESSION['bookid'] . ',' . $_SESSION['id'] . ",'" . $_POST['comment'] . "')";
} else {
$sentence = 'CALL addReply(' . $_SESSION['bookid'] . ',' . $_SESSION['id'] . ',' . $conn->quote($_POST['reply']) . ',' . $_GET['replyid'] . ')';
}
$conn->query($sentence);
}
示例13: __construct
public function __construct()
{
$this->dbTable = 'product';
$connection = new DatabaseConnection();
try {
$this->database = $connection->SetupDatabase();
} catch (\Exception $e) {
throw $e;
}
}
示例14: addEvent
public function addEvent(AuditEvent $event)
{
$event->setComponent($this->_component);
$cn = get_class($event);
$sev = serialize($event);
// Shove into DB -- echo $sev;
echo $cn . "\n\n" . $sev . "\n";
$db = new DatabaseConnection();
$db->insertRow("INSERT INTO auditlog " . "eventclass,component,severity,eventdate,data) " . "VALUES (%s,%s,%d,%d,NOW(),%s)", $cn, $event->getComponent(), $event->getSeverity(), $event->getAssociatedUserId(), $sev);
}
示例15: savepost
function savepost()
{
$post = new WebForm($this->gbform);
if (!$post->isValid()) {
// Form is invalid, post it back to the user to allow correction
} else {
$db = new DatabaseConnection();
$db->insertRow("INSERT INTO guestbook (name,email,website,message) VALUES (%s,%s,%s,%s)", $post->name, $post->email, $post->website, $post->message);
}
}