本文整理汇总了PHP中DatabaseConnection类的典型用法代码示例。如果您正苦于以下问题:PHP DatabaseConnection类的具体用法?PHP DatabaseConnection怎么用?PHP DatabaseConnection使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DatabaseConnection类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: setUpPool
/**
* Testcase Constructor.
*
* @return void
*/
public function setUpPool()
{
$this->pool = $this->getMockBuilder('Lunr\\Gravity\\Database\\DatabaseConnectionPool')->disableOriginalConstructor()->getMock();
$this->logger = $this->getMock('Psr\\Log\\LoggerInterface');
$this->db = $this->getMockBuilder('Lunr\\Gravity\\Database\\MySQL\\MySQLConnection')->disableOriginalConstructor()->getMock();
$escaper = $this->getMockBuilder('Lunr\\Gravity\\Database\\MySQL\\MySQLQueryEscaper')->disableOriginalConstructor()->getMock();
$this->db->expects($this->once())->method('get_query_escaper_object')->will($this->returnValue($escaper));
$this->dao = $this->getMockBuilder('Lunr\\Gravity\\Database\\DatabaseAccessObject')->setConstructorArgs(array($this->db, $this->logger, $this->pool))->getMockForAbstractClass();
$this->reflection_dao = new ReflectionClass('Lunr\\Gravity\\Database\\DatabaseAccessObject');
}
开发者ID:rubendgr,项目名称:lunr,代码行数:15,代码来源:DatabaseAccessObjectTest.php
示例17: openConnection
protected static final function openConnection($driver)
{
$adapter = 'Adapter' . $driver;
include_once dirname(__FILE__) . '/adapter/' . $adapter . '.php';
$connection = new DatabaseConnection(new $adapter());
$cfg = self::getConnectionConf();
$connection->connect($cfg['engine'], $cfg['hostname'], $cfg['database'], $cfg['username'], $cfg['password']);
return $connection;
// end function
}
开发者ID:dlehmann,项目名称:DevCE,代码行数:10,代码来源:Database.php
示例18: testLastID
public function testLastID()
{
require __DIR__ . '/config/database_test.php';
$db = new DatabaseConnection($host, $database, $user, $password);
$insert_result = $db->query("INSERT INTO characters (id, name, description, type, dead, stage, hp) \r\n\t\t\tVALUES ('9999', 'Carla', 'The swordmaster of Melee Island', 'pirate', 'false', '4', '87');");
$actual = $db->lastID();
$expected = '9999';
$delete_result = $db->query("DELETE FROM characters WHERE id = '9999'");
$this->assertNotEmpty($actual, 'Function LastID returning empty value. Check TestDatabaseConnection::lastID()');
$this->assertEquals($expected, $actual, 'Function LastID not returning expected value. Check TestDatabaseConnection::lastID()');
}
开发者ID:rafamalaga86,项目名称:gamerest,代码行数:11,代码来源:TestDatabaseConnection.php
示例19: getAllPosts
function getAllPosts()
{
// Acquire a handle to the database.
$db = new DatabaseConnection();
// Query the posts and assign the result to a postcollection.
$rs = $db->getRows("SELECT * FROM blogposts ORDER BY pubdate DESC");
$coll = array();
foreach ($rs as $post) {
$coll[] = new BlogPost($post);
}
// Finally return it
return $coll;
}
开发者ID:noccy80,项目名称:lepton-ng,代码行数:13,代码来源:blogposts.php
示例20: __construct
function __construct(DatabaseConnection $parent)
{
//echo "Opening Connection\n";
if ($parent->is_transaction()) {
$this->using_savepoints = true;
$this->savepoint_name = 'transaction_' . uniqid();
$parent->query('SAVEPOINT ' . pg_escape_identifier($this->savepoint_name));
} else {
$this->using_savepoints = false;
$parent->query("START TRANSACTION");
}
$this->parent_connection = $parent;
}
开发者ID:sandyman,项目名称:postgres-dbal,代码行数:13,代码来源:DatabaseTransaction.php
注:本文中的DatabaseConnection类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论