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