當前位置: 首頁>>代碼示例>>PHP>>正文


PHP DatabaseConnection類代碼示例

本文整理匯總了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;
	} 
開發者ID:nathanfl,項目名稱:medtele,代碼行數:29,代碼來源:User.Class.php

示例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;
     }
 }
開發者ID:noccy80,項目名稱:lepton-ng,代碼行數:39,代碼來源:wiki.php

示例3: getUserList

 public function getUserList()
 {
     $dbconn = new DatabaseConnection('localhost', 'user', 'password');
     $results = $dbconn->query('select name from user');
     sort($results);
     return $results;
 }
開發者ID:hpazevedo,項目名稱:Teste-BDR,代碼行數:7,代碼來源:index.php

示例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));
 }
開發者ID:atriches,項目名稱:prova,代碼行數:7,代碼來源:questao3.php

示例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");
}
開發者ID:PumpkinSeed,項目名稱:beadando,代碼行數:7,代碼來源:test_data_subjects.php

示例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);
 }
開發者ID:makinacorpus,項目名稱:drupal-plusql,代碼行數:16,代碼來源:ConstraintRegistry.php

示例7: staticText

 function staticText($slug)
 {
     $db = new DatabaseConnection();
     $text = $db->getSingleRow("SELECT * FROM statictext WHERE slug=%s", $slug);
     if ($text) {
         return $text['content'];
     }
 }
開發者ID:noccy80,項目名稱:lepton-ng,代碼行數:8,代碼來源:content.php

示例8: showStart

 function showStart()
 {
     $this->loadTemplate();
     $controller = new DatabaseConnection();
     $controller->raw('CALL registraVisita()');
     $controller = null;
     include 'view/welcome.php';
 }
開發者ID:apexJCL,項目名稱:mvc,代碼行數:8,代碼來源:index.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;
}
開發者ID:PumpkinSeed,項目名稱:beadando,代碼行數:8,代碼來源:test_data_marks.php

示例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;
 }
開發者ID:rodrigopluz,項目名稱:provaTecnica-BDR,代碼行數:9,代碼來源:index-3.php

示例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);
 }
開發者ID:rogerchom,項目名稱:feedback_app,代碼行數:9,代碼來源:Locations.php

示例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);
 }
開發者ID:apexJCL,項目名稱:mvc,代碼行數:10,代碼來源:comment.php

示例13: __construct

 public function __construct()
 {
     $this->dbTable = 'product';
     $connection = new DatabaseConnection();
     try {
         $this->database = $connection->SetupDatabase();
     } catch (\Exception $e) {
         throw $e;
     }
 }
開發者ID:JuliaSivartsson,項目名稱:1dv608,代碼行數:10,代碼來源:ProductRepository.php

示例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);
 }
開發者ID:noccy80,項目名稱:lepton-ng,代碼行數:10,代碼來源:audit.php

示例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);
     }
 }
開發者ID:noccy80,項目名稱:lepton-ng,代碼行數:10,代碼來源:formcontroller.php


注:本文中的DatabaseConnection類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。