当前位置: 首页>>代码示例>>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;未经允许,请勿转载。