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


PHP DibiConnection類代碼示例

本文整理匯總了PHP中DibiConnection的典型用法代碼示例。如果您正苦於以下問題:PHP DibiConnection類的具體用法?PHP DibiConnection怎麽用?PHP DibiConnection使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了DibiConnection類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: __construct

 public function __construct(\DibiConnection $db)
 {
     //static roles
     $this->addRole('guest');
     $this->addRole('authenticated', 'guest');
     $this->addRole('manager', 'authenticated');
     $this->addRole('administrator', 'manager');
     $this->addRole('student', 'authenticated');
     $this->addRole('teacher', 'authenticated');
     //dynamic roles
     $groups = $db->query("SELECT * FROM `group`")->fetchAll();
     foreach ($groups as $group) {
         if (!$this->hasRole($group->role_name)) {
             $this->addRole($group->role_name, 'authenticated');
         }
     }
     // resources
     $this->addResource('Front:Homepage');
     $this->addResource('Front:Files');
     $this->addResource('Service:Sign');
     $this->addResource('Service:Error');
     $this->addResource('Dashboard:Homepage');
     $this->addResource('Dashboard:Users');
     $this->addResource('Dashboard:Groups');
     $this->addResource('Dashboard:My');
     $this->addResource('Dashboard:Files');
     $this->addResource('Works:Homepage');
     $this->addResource('Works:Sets');
     $this->addResource('Works:Ideas');
     $this->addResource('Works:Assignments');
     $this->addResource('School:Homepage');
     $this->addResource('School:Classes');
     $this->addResource('School:Students');
     $this->addResource('School:Teachers');
     $this->addResource('School:Subjects');
     $this->addResource('School:Groups');
     $this->addResource('School:Import');
     $this->addResource('Delivery:Homepage');
     $this->addResource('Practice:Homepage');
     $this->addResource('Activity:Homepage');
     // privileges
     $this->allow('guest', array('Front:Homepage', 'Service:Sign', "Service:Error"), Permission::ALL);
     $this->allow('authenticated', array('Dashboard:My'), Permission::ALL);
     $this->allow('authenticated', array('Dashboard:Groups'), Permission::ALL);
     $this->allow('authenticated', array('Dashboard:Files'), Permission::ALL);
     $this->allow('authenticated', array('Dashboard:Homepage'), array('default'));
     $this->allow('student', array('Works:Homepage'), array('default'));
     $this->allow('teacher', array('Works:Homepage'), Permission::ALL);
     $this->allow('student', array('Works:Ideas'), array('default', 'add', 'id', 'edit', 'delete', 'clone'));
     $this->allow('teacher', array('Works:Ideas'), Permission::ALL);
     $this->allow('student', array('Works:Assignments'), array('default', 'application'));
     $this->allow('teacher', array('Works:Assignments'), array('default', 'add', 'id', 'edit', 'delete', 'print'));
     $this->allow('teacher', array('School:Homepage', 'School:Teachers', 'School:Classes', 'School:Students', 'School:Subjects', 'School:Groups'), Permission::ALL);
     $this->allow('administrator', Permission::ALL, Permission::ALL);
 }
開發者ID:hajek-raven,項目名稱:agenda,代碼行數:55,代碼來源:acl.php

示例2: createConnection

 public static function createConnection(DI\Container $container)
 {
     $dibiConnection = new \DibiConnection($container->params['database']);
     $dibiConnection->query('SET NAMES UTF8');
     $substitutions = array('core' => 'cms_', 'vd' => 'cms_vd_', 'c' => 'cgf_', 'media' => 'media_');
     foreach ($substitutions as $sub => $prefix) {
         $dibiConnection->getSubstitutes()->{$sub} = $prefix;
     }
     //        $profiler = new \DibiProfiler();
     //        $dibiConnection->setProfiler($profiler);
     //        $dibiConnection->setFile(APP_DIR.'/../log/dibi.log');
     return $dibiConnection;
 }
開發者ID:jurasm2,項目名稱:bubo,代碼行數:13,代碼來源:DibiFactory.php

示例3: connect

 /**
  * Connects to a database.
  * @return void
  * @throws DibiException
  */
 public function connect(array &$config)
 {
     DibiConnection::alias($config, 'username', 'user');
     DibiConnection::alias($config, 'password', 'pass');
     if (isset($config['resource'])) {
         $this->connection = $config['resource'];
     } else {
         // default values
         if (!isset($config['username'])) {
             $config['username'] = ini_get('odbc.default_user');
         }
         if (!isset($config['password'])) {
             $config['password'] = ini_get('odbc.default_pw');
         }
         if (!isset($config['dsn'])) {
             $config['dsn'] = ini_get('odbc.default_db');
         }
         if (empty($config['persistent'])) {
             $this->connection = @odbc_connect($config['dsn'], $config['username'], $config['password']);
             // intentionally @
         } else {
             $this->connection = @odbc_pconnect($config['dsn'], $config['username'], $config['password']);
             // intentionally @
         }
     }
     if (!is_resource($this->connection)) {
         throw new DibiDriverException(odbc_errormsg() . ' ' . odbc_error());
     }
 }
開發者ID:jakubkulhan,項目名稱:shopaholic,代碼行數:34,代碼來源:odbc.php

示例4: connect

 /**
  * Connects to a database.
  * @return void
  * @throws DibiException
  */
 public function connect(array &$config)
 {
     DibiConnection::alias($config, 'database', 'file');
     $this->fmtDate = isset($config['formatDate']) ? $config['formatDate'] : 'U';
     $this->fmtDateTime = isset($config['formatDateTime']) ? $config['formatDateTime'] : 'U';
     if (isset($config['resource']) && $config['resource'] instanceof SQLite3) {
         $this->connection = $config['resource'];
     } else {
         try {
             $this->connection = new SQLite3($config['database']);
         } catch (Exception $e) {
             throw new DibiDriverException($e->getMessage(), $e->getCode());
         }
     }
     $this->dbcharset = empty($config['dbcharset']) ? 'UTF-8' : $config['dbcharset'];
     $this->charset = empty($config['charset']) ? 'UTF-8' : $config['charset'];
     if (strcasecmp($this->dbcharset, $this->charset) === 0) {
         $this->dbcharset = $this->charset = NULL;
     }
     // enable foreign keys support (defaultly disabled; if disabled then foreign key constraints are not enforced)
     $version = SQLite3::version();
     if ($version['versionNumber'] >= '3006019') {
         $this->query("PRAGMA foreign_keys = ON");
     }
 }
開發者ID:romcok,項目名稱:treeview,代碼行數:30,代碼來源:sqlite3.php

示例5: connect

 /**
  * Connects to a database.
  * @return void
  * @throws DibiException
  */
 public function connect(array &$config)
 {
     DibiConnection::alias($config, 'database', 'file');
     $this->fmtDate = isset($config['formatDate']) ? $config['formatDate'] : 'U';
     $this->fmtDateTime = isset($config['formatDateTime']) ? $config['formatDateTime'] : 'U';
     $errorMsg = '';
     if (isset($config['resource'])) {
         $this->connection = $config['resource'];
     } elseif (empty($config['persistent'])) {
         $this->connection = @sqlite_open($config['database'], 0666, $errorMsg);
         // intentionally @
     } else {
         $this->connection = @sqlite_popen($config['database'], 0666, $errorMsg);
         // intentionally @
     }
     if (!$this->connection) {
         throw new DibiDriverException($errorMsg);
     }
     $this->buffered = empty($config['unbuffered']);
     $this->dbcharset = empty($config['dbcharset']) ? 'UTF-8' : $config['dbcharset'];
     $this->charset = empty($config['charset']) ? 'UTF-8' : $config['charset'];
     if (strcasecmp($this->dbcharset, $this->charset) === 0) {
         $this->dbcharset = $this->charset = NULL;
     }
 }
開發者ID:Scrik,項目名稱:Need-For-Speed-World-Statistics-Website,代碼行數:30,代碼來源:sqlite.php

示例6: connect

 /**
  * Connects to a database.
  * @return void
  * @throws DibiException
  */
 public function connect(array &$config)
 {
     DibiConnection::alias($config, 'options');
     DibiConnection::alias($config, 'database');
     if (isset($config['resource'])) {
         $this->connection = $config['resource'];
     } else {
         // default values
         if (!isset($config['username'])) {
             $config['username'] = ini_get('mysqli.default_user');
         }
         if (!isset($config['password'])) {
             $config['password'] = ini_get('mysqli.default_pw');
         }
         if (!isset($config['socket'])) {
             $config['socket'] = ini_get('mysqli.default_socket');
         }
         if (!isset($config['port'])) {
             $config['port'] = NULL;
         }
         if (!isset($config['host'])) {
             $host = ini_get('mysqli.default_host');
             if ($host) {
                 $config['host'] = $host;
                 $config['port'] = ini_get('mysqli.default_port');
             } else {
                 $config['host'] = NULL;
                 $config['port'] = NULL;
             }
         }
         $this->connection = mysqli_init();
         @mysqli_real_connect($this->connection, $config['host'], $config['username'], $config['password'], $config['database'], $config['port'], $config['socket'], $config['options']);
         // intentionally @
         if ($errno = mysqli_connect_errno()) {
             throw new DibiDriverException(mysqli_connect_error(), $errno);
         }
     }
     if (isset($config['charset'])) {
         $ok = FALSE;
         if (version_compare(PHP_VERSION, '5.1.5', '>=')) {
             // affects the character set used by mysql_real_escape_string() (was added in MySQL 5.0.7 and PHP 5.0.5, fixed in PHP 5.1.5)
             $ok = @mysqli_set_charset($this->connection, $config['charset']);
             // intentionally @
         }
         if (!$ok) {
             $ok = @mysqli_query($this->connection, "SET NAMES '{$config['charset']}'");
             // intentionally @
             if (!$ok) {
                 throw new DibiDriverException(mysqli_error($this->connection), mysqli_errno($this->connection));
             }
         }
     }
     if (isset($config['sqlmode'])) {
         if (!@mysqli_query($this->connection, "SET sql_mode='{$config['sqlmode']}'")) {
             // intentionally @
             throw new DibiDriverException(mysqli_error($this->connection), mysqli_errno($this->connection));
         }
     }
     $this->buffered = empty($config['unbuffered']);
 }
開發者ID:vlki,項目名稱:dibi,代碼行數:65,代碼來源:mysqli.php

示例7: createComponentGrid

 protected function createComponentGrid($name)
 {
     $grid = new Grid($this, $name);
     $fluent = $this->database->select('u.*, c.title AS country')->from('[user] u')->join('[country] c')->on('u.country_code = c.code');
     $grid->model = $fluent;
     $grid->addColumnText('firstname', 'Firstname')->setFilterText()->setSuggestion();
     $grid->addColumnText('surname', 'Surname')->setSortable()->setFilterText()->setSuggestion();
     $grid->addColumnText('gender', 'Gender')->setSortable()->cellPrototype->class[] = 'center';
     $grid->addColumnDate('birthday', 'Birthday', \Grido\Components\Columns\Date::FORMAT_TEXT)->setSortable()->setFilterDate()->setCondition($grid->birthdayFilterCondition);
     $grid->getColumn('birthday')->cellPrototype->class[] = 'center';
     $customRender = function ($item) {
         $baseUri = $this->getBaseUri();
         $img = Html::el('img')->src("{$baseUri}/img/flags/{$item->country_code}.gif");
         return "{$img} {$item->country}";
     };
     $grid->addColumnText('country', 'Country')->setSortable()->setCustomRender($customRender)->setFilterText()->setColumn('c.title')->setSuggestion('title');
     $grid->addColumnText('card', 'Card')->setSortable()->setColumn('cctype')->setReplacement(array('MasterCard' => Html::el('b')->setText('MasterCard')))->cellPrototype->class[] = 'center';
     $grid->addColumnEmail('emailaddress', 'Email')->setSortable()->setFilterText();
     $grid->getColumn('emailaddress')->cellPrototype->class[] = 'center';
     $grid->addColumnText('centimeters', 'Height')->setSortable()->setFilterNumber();
     $grid->getColumn('centimeters')->cellPrototype->class[] = 'center';
     $grid->addFilterSelect('gender', 'Gender', array('' => '', 'female' => 'female', 'male' => 'male'));
     $grid->addFilterSelect('card', 'Card', array('' => '', 'MasterCard' => 'MasterCard', 'Visa' => 'Visa'))->setColumn('cctype');
     $grid->addFilterCheck('preferred', 'Only preferred girls :)')->setCondition(array(TRUE => array(array('gender', 'AND', 'centimeters'), array('= ?', '>= ?'), array('female', 170))));
     $grid->addActionHref('edit', 'Edit')->setIcon('pencil');
     $grid->addActionHref('delete', 'Delete')->setIcon('trash')->setConfirm(function ($item) {
         return "Are you sure you want to delete {$item->firstname} {$item->surname}?";
     });
     $operation = array('print' => 'Print', 'delete' => 'Delete');
     $grid->setOperation($operation, $this->handleOperations)->setConfirm('delete', 'Are you sure you want to delete %i items?');
     $grid->filterRenderType = $this->filterRenderType;
     $grid->setExport();
     return $grid;
 }
開發者ID:o5,項目名稱:grido-examples,代碼行數:34,代碼來源:DibiPresenter.php

示例8: testLazyHasValue

 public function testLazyHasValue()
 {
     $id = $this->db->select("max(id)")->from("pages")->fetchSingle();
     $page = new Page($id);
     $this->assertTrue($page->hasValue("name"));
     $this->assertFalse($page->hasValue("nesmysl"));
 }
開發者ID:janmarek,項目名稱:Ormion,代碼行數:7,代碼來源:RecordTest.php

示例9: count

    /**
     * @return int
     */
    public function count()
    {
        if ($this->count === NULL) {
            $this->count = $this->connection->query('
				SELECT COUNT(*) FROM', $this->sql)->fetchSingle();
        }
        return $this->count;
    }
開發者ID:laiello,項目名稱:webuntucms,代碼行數:11,代碼來源:DibiDataSource.php

示例10: createDatabase

 /**
  * @param string $username
  * @param string $password
  * @param string $databaseName
  */
 public function createDatabase($username, $password, $databaseName)
 {
     //exit(var_dump('GRANT ALL PRIVILEGES ON '.$databaseName.'.* TO "'.$username.'"@"%" IDENTIFIED BY "'.$password.'" WITH GRANT OPTION'));
     $this->connection->nativeQuery('GRANT ALL PRIVILEGES ON *.* TO "' . $username . '"@"%" IDENTIFIED BY "' . $password . '" WITH GRANT OPTION');
     $this->connection->nativeQuery('CREATE DATABASE ' . $databaseName);
     $this->connection->nativeQuery("GRANT ALL PRIVILEGES ON " . $databaseName . ".* TO '" . $username . "'@'%' IDENTIFIED BY '" . $password . "' WITH GRANT OPTION");
     //TODO use $this->connection->driver->escape()
 }
開發者ID:kizi,項目名稱:easyminer-easyminercenter,代碼行數:13,代碼來源:DatabaseManager.php

示例11: getValidRefreshToken

 /**
  * Get valid refresh token
  * @param string $refreshToken
  * @return IRefreshToken|NULL
  */
 public function getValidRefreshToken($refreshToken)
 {
     $row = $this->context->select('*')->from($this->getTable())->where('refresh_token = %s', $refreshToken)->where('TIMEDIFF(expires_at, NOW()) >= 0')->fetch();
     if (!$row) {
         return NULL;
     }
     return new RefreshToken($row['refresh_token'], new \DateTime($row['expires_at']), $row['client_id'], $row['user_id']);
 }
開發者ID:drahak,項目名稱:oauth2,代碼行數:13,代碼來源:RefreshTokenStorage.php

示例12: canUseGrantType

    /**
     * Can client use given grant type
     * @param string $clientId
     * @param string $grantType
     * @return bool
     */
    public function canUseGrantType($clientId, $grantType)
    {
        $result = $this->context->query('
			SELECT g.name
			FROM oauth_client_grant AS cg
			RIGHT JOIN oauth_grant AS g ON cg.grant_id = cg.grant_id AND g.name = %s
			WHERE cg.client_id = %i
		', $grantType, $clientId);
        return (bool) $result->fetch();
    }
開發者ID:drahak,項目名稱:oauth2,代碼行數:16,代碼來源:ClientStorage.php

示例13: getValidAuthorizationCode

 /**
  * Validate authorization code
  * @param string $authorizationCode
  * @return IAuthorizationCode
  */
 public function getValidAuthorizationCode($authorizationCode)
 {
     /** @var ActiveRow $row */
     $row = $this->context->select('*')->from($this->getTable())->where('authorization_code = %s', $authorizationCode)->where('TIMEDIFF(expires_at, NOW()) >= 0')->fetch();
     if (!$row) {
         return NULL;
     }
     $scopes = $this->context->select('*')->from($this->getScopeTable())->where('authorization_code = %s', $authorizationCode)->fetchPairs('scope_name');
     return new AuthorizationCode($row['authorization_code'], new \DateTime($row['expires_at']), $row['client_id'], $row['user_id'], array_keys($scopes));
 }
開發者ID:drahak,項目名稱:oauth2,代碼行數:15,代碼來源:AuthorizationCodeStorage.php

示例14: testInsert

 public function testInsert()
 {
     $page = new Page(array("name" => "Insert test", "description" => "Insert record", "text" => "Insert record into database"));
     $page->allowed = true;
     $this->assertEquals(Ormion\Record::STATE_NEW, $page->getState());
     $this->object->insert($page);
     $this->assertEquals(Ormion\Record::STATE_EXISTING, $page->getState());
     $this->assertType("int", $page->id);
     $res = $this->db->select("*")->from("pages")->where("id = %i", $page->id)->fetch();
     $this->assertEquals("Insert test", $res->name);
     $this->assertEquals("Insert record", $res->description);
     $this->assertEquals(array(), $page->getModified());
 }
開發者ID:janmarek,項目名稱:Ormion,代碼行數:13,代碼來源:MapperTest.php

示例15: setup

 protected function setup()
 {
     parent::setup();
     // Load from DB
     $rules = $this->db->query("SELECT * FROM %n", $this->tableName);
     foreach ($rules as $rule) {
         // If querying the compound name, ensure it exists
         if ($rule->type == 'allow') {
             $this->allow($rule->role, $rule->resource, $rule->privilege);
         } else {
             $this->deny($rule->role, $rule->resource, $rule->privilege);
         }
     }
 }
開發者ID:vbuilder,項目名稱:framework,代碼行數:14,代碼來源:DatabaseAclAuthorizator.php


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