本文整理汇总了PHP中ezcDbInstance::get方法的典型用法代码示例。如果您正苦于以下问题:PHP ezcDbInstance::get方法的具体用法?PHP ezcDbInstance::get怎么用?PHP ezcDbInstance::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ezcDbInstance
的用法示例。
在下文中一共展示了ezcDbInstance::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: doDebug
public function doDebug()
{
$res = new ezcMvcResult();
$q = ezcDbInstance::get()->query("SELECT * FROM user");
//var_dump( $q );
//$s = $q->prepare();
$q->execute();
$r = $q->fetchAll();
$res->variables['debugMessage'] = $r;
$res->variables['type'] = $this->type;
return $res;
$q = ezcDbInstance::get()->createSelectQuery();
$q->select('*')->from('message')->innerJoin('user', 'message.user_id', 'user.id')->where($q->expr->eq('message.id', $this->id))->orderBy('date', ezcQuerySelect::DESC)->limit(25);
$s = $q->prepare();
$s->execute();
$r = $s->fetchAll();
if ($_SESSION['ezcAuth_id'] == $r[0]['user_id']) {
$q = ezcDbInstance::get()->createDeleteQuery();
$q->deleteFrom('message')->where($q->expr->eq('id', $q->bindValue($this->id)));
$s = $q->prepare();
$s->execute();
$q = ezcDbInstance::get()->createDeleteQuery();
$q->deleteFrom('message_tag')->where($q->expr->eq('message_id', $q->bindValue($this->id)));
$s = $q->prepare();
$s->execute();
die("OK");
}
die("FAIL");
}
示例2: hasGeometry
function hasGeometry($sql, $id)
{
$db = ezcDbInstance::get();
$stmt = $db->prepare($sql);
$stmt->execute(array($id));
return $stmt->fetchColumn();
}
示例3: validateRequest
public static function validateRequest()
{
$headers = self::getHeaders();
if (isset($headers['Authorization'])) {
$dataAuthorisation = explode(' ', $headers['Authorization']);
$apiData = explode(':', base64_decode($dataAuthorisation[1]));
if (count($apiData) != 2) {
throw new Exception(erTranslationClassLhTranslation::getInstance()->getTranslation('lhrestapi/validation', 'Authorization failed!'));
}
$apiKey = erLhAbstractModelRestAPIKey::findOne(array('enable_sql_cache' => true, 'filter' => array('active' => 1, 'api_key' => $apiData[1])));
if (!$apiKey instanceof erLhAbstractModelRestAPIKey) {
throw new Exception(erTranslationClassLhTranslation::getInstance()->getTranslation('lhrestapi/validation', 'Authorization failed!'));
}
if ($apiKey->user->username != $apiData[0]) {
throw new Exception(erTranslationClassLhTranslation::getInstance()->getTranslation('lhrestapi/validation', 'Authorization failed!'));
}
// API Key
self::$apiKey = $apiKey;
if (isset($_GET['update_activity'])) {
$db = ezcDbInstance::get();
$stmt = $db->prepare('UPDATE lh_userdep SET last_activity = :last_activity WHERE user_id = :user_id');
$stmt->bindValue(':last_activity', time(), PDO::PARAM_INT);
$stmt->bindValue(':user_id', self::$apiKey->user->id, PDO::PARAM_INT);
$stmt->execute();
}
} else {
throw new Exception(erTranslationClassLhTranslation::getInstance()->getTranslation('lhrestapi/validation', 'Authorization header is missing!'));
}
}
示例4: removeThis
public function removeThis()
{
$q = ezcDbInstance::get()->createDeleteQuery();
// Messages
$q->deleteFrom('lh_msg')->where($q->expr->eq('chat_id', $this->id));
$stmt = $q->prepare();
$stmt->execute();
// Transfered chats
$q->deleteFrom('lh_transfer')->where($q->expr->eq('chat_id', $this->id));
$stmt = $q->prepare();
$stmt->execute();
// Delete user footprint
$q->deleteFrom('lh_chat_online_user_footprint')->where($q->expr->eq('chat_id', $this->id));
$stmt = $q->prepare();
$stmt->execute();
// Delete screen sharing
$q->deleteFrom('lh_cobrowse')->where($q->expr->eq('chat_id', $this->id));
$stmt = $q->prepare();
$stmt->execute();
// Delete speech settings
$q->deleteFrom('lh_speech_chat_language')->where($q->expr->eq('chat_id', $this->id));
$stmt = $q->prepare();
$stmt->execute();
erLhcoreClassModelChatFile::deleteByChatId($this->id);
erLhcoreClassChat::getSession()->delete($this);
erLhcoreClassChat::updateActiveChats($this->user_id);
}
示例5: createDB
public static function createDB($client_id)
{
$cfg = erConfigClassLhConfig::getInstance();
self::deleteDB($client_id);
$db = ezcDbInstance::get();
$db->query('CREATE DATABASE ' . $cfg->getSetting('db', 'database_user_prefix') . $client_id . ';');
}
示例6: cleanup
public static function cleanup()
{
$db = ezcDbInstance::get();
$stmt = $db->prepare('DELETE FROM lh_chat_accept WHERE ctime < :ctime');
$stmt->bindValue(':ctime', (int) (time() - 24 * 3600), PDO::PARAM_INT);
$stmt->execute();
}
示例7: setUp
protected function setUp()
{
try {
$this->db = ezcDbInstance::get();
} catch (Exception $e) {
$this->markTestSkipped();
}
$this->q = $this->db->createSelectQuery();
$this->e = $this->q->expr;
$this->assertNotNull($this->db, 'Database instance is not initialized.');
try {
$this->db->exec('DROP TABLE query_test');
$this->db->exec('DROP TABLE query_test2');
} catch (Exception $e) {
}
// eat
// insert some data
$this->db->exec('CREATE TABLE query_test ( id int, company VARCHAR(255), section VARCHAR(255), employees int NULL )');
$this->db->exec("INSERT INTO query_test VALUES ( 1, 'eZ systems', 'Norway', 20 )");
$this->db->exec("INSERT INTO query_test VALUES ( 2, 'IBM', 'Norway', 500 )");
$this->db->exec("INSERT INTO query_test VALUES ( 3, 'eZ systems', 'Ukraine', 10 )");
$this->db->exec("INSERT INTO query_test VALUES ( 4, 'IBM', 'Germany', null )");
// insert some data
$this->db->exec('CREATE TABLE query_test2 ( id int, company VARCHAR(255), section VARCHAR(255), employees int NULL )');
$this->db->exec("INSERT INTO query_test2 VALUES ( 1, 'eZ systems', 'Norway', 20 )");
$this->db->exec("INSERT INTO query_test2 VALUES ( 2, 'IBM', 'Norway', 500 )");
$this->db->exec("INSERT INTO query_test2 VALUES ( 3, 'eZ systems', 'Ukraine', 10 )");
$this->db->exec("INSERT INTO query_test2 VALUES ( 4, 'IBM', 'Germany', null )");
}
示例8: setUp
protected function setUp()
{
try {
$this->db = ezcDbInstance::get();
} catch (Exception $e) {
$this->markTestSkipped("No Database connection available");
}
if ($this->db->getName() !== 'oracle') {
$this->markTestSkipped("Skipping tests for Oracle");
}
if (!$this->db instanceof ezcDbHandlerOracle) {
$this->markTestSkipped();
}
$this->testFilesDir = dirname(__FILE__) . '/testfiles/';
$this->tempDir = $this->createTempDir('ezcDatabaseOracleTest');
$tables = $this->db->query("SELECT table_name FROM user_tables")->fetchAll();
array_walk($tables, create_function('&$item,$key', '$item = $item[0];'));
foreach ($tables as $tableName) {
$this->db->query("DROP TABLE \"{$tableName}\"");
}
$sequences = $this->db->query("SELECT sequence_name FROM user_sequences")->fetchAll();
array_walk($sequences, create_function('&$item,$key', '$item = $item[0];'));
foreach ($sequences as $sequenceName) {
$this->db->query("DROP SEQUENCE \"{$sequenceName}\"");
}
}
示例9: doLogin
public function doLogin()
{
// obtain credentials from POST
$user = isset($_POST['user']) ? $_POST['user'] : null;
$password = isset($_POST['password']) ? $_POST['password'] : null;
$redirUrl = isset($_POST['redirUrl']) ? $_POST['redirUrl'] : '/';
$database = new ezcAuthenticationDatabaseInfo(ezcDbInstance::get(), 'user', array('id', 'password'));
$databaseFilter = new ezcAuthenticationDatabaseFilter($database);
$options = new ezcAuthenticationSessionOptions();
$options->validity = 86400;
$session = new ezcAuthenticationSession($options);
$session->start();
// use the options object when creating a new Session object
$credentials = new ezcAuthenticationPasswordCredentials($user, md5($password));
$authentication = new ezcAuthentication($credentials);
$authentication->session = $session;
$authentication->addFilter($databaseFilter);
if (!$authentication->run()) {
$request = clone $this->request;
$status = $authentication->getStatus();
$request->variables['redirUrl'] = $redirUrl;
$request->variables['reasons'] = $status;
$request->uri = '/login-required';
return new ezcMvcInternalRedirect($request);
}
$res = new ezcMvcResult();
$res->status = new ezcMvcExternalRedirect($redirUrl);
return $res;
}
示例10: getSession
public static function getSession()
{
if (!isset(self::$persistentSession)) {
self::$persistentSession = new ezcPersistentSession(ezcDbInstance::get(), new ezcPersistentCodeManager('./pos/lhfaq'));
}
return self::$persistentSession;
}
示例11: setUp
protected function setUp()
{
try {
$this->db = ezcDbInstance::get();
} catch (Exception $e) {
$this->markTestSkipped();
}
$this->q = $this->db->createSelectQuery();
$this->e = $this->db->createExpression();
$this->assertNotNull($this->db, 'Database instance is not initialized.');
try {
$this->db->exec('DROP TABLE query_test');
} catch (Exception $e) {
}
// eat
// insert some data
if ($this->db->getName() === 'mssql') {
$this->db->exec('CREATE TABLE query_test ( id int, company VARCHAR(255), section VARCHAR(255), employees int NULL, somedate DATETIME NULL )');
} else {
$this->db->exec('CREATE TABLE query_test ( id int, company VARCHAR(255), section VARCHAR(255), employees int NULL, somedate TIMESTAMP )');
}
if ($this->db->getName() === 'oracle') {
$this->db->exec("ALTER SESSION SET NLS_TIMESTAMP_FORMAT = 'YYYY-MM-DD HH24:MI:SS'");
// set the timestamp format
}
$this->db->exec("INSERT INTO query_test VALUES ( 1, 'eZ systems', 'Norway', 20, '2007-05-03 11:54:17' )");
$this->db->exec("INSERT INTO query_test VALUES ( 2, 'IBM', 'Norway', 500, null )");
$this->db->exec("INSERT INTO query_test VALUES ( 3, 'eZ systems', 'Ukraine', 10, null )");
$this->db->exec("INSERT INTO query_test VALUES ( 4, 'IBM', 'Germany', null, null )");
}
示例12: setUp
protected function setUp()
{
try {
$this->db = ezcDbInstance::get();
} catch (Exception $e) {
$this->markTestSkipped();
}
}
示例13: deleteHash
public static function deleteHash($id)
{
$db = ezcDbInstance::get();
$stmt = $db->prepare('DELETE FROM lh_forgotpasswordhash WHERE id =:id LIMIT 1');
$stmt->bindValue(':id', $id);
$stmt->setFetchMode(PDO::FETCH_ASSOC);
$stmt->execute();
}
示例14: setUp
public function setUp()
{
try {
$this->db = ezcDbInstance::get();
} catch (Exception $e) {
$this->markTestSkipped('There was no database configured');
}
}
示例15: cleanup
public static function cleanup()
{
$db = ezcDbInstance::get();
$db->exec("DROP TABLE " . $db->quoteIdentifier("PO_test") . ";");
if ($db->getName() == 'pgsql') {
$db->exec("DROP SEQUENCE " . $db->quoteIdentifier("PO_test_seq") . ";");
}
}