当前位置: 首页>>代码示例>>PHP>>正文


PHP R::getDatabaseAdapter方法代码示例

本文整理汇总了PHP中R::getDatabaseAdapter方法的典型用法代码示例。如果您正苦于以下问题:PHP R::getDatabaseAdapter方法的具体用法?PHP R::getDatabaseAdapter怎么用?PHP R::getDatabaseAdapter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在R的用法示例。


在下文中一共展示了R::getDatabaseAdapter方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: startTestSuite

 public function startTestSuite(PHPUnit_Framework_TestSuite $suite)
 {
     $dbAdapter = \R::getDatabaseAdapter();
     if (null == $dbAdapter) {
         \R::setup();
     }
 }
开发者ID:dazmiller,项目名称:red4,代码行数:7,代码来源:RedBeanListener.php

示例2: testDebugCustomLogger

 /**
  * Test debugging with custom logger.
  * 
  * @return void
  */
 public function testDebugCustomLogger()
 {
     testpack('Test debug mode with custom logger');
     $pdoDriver = new RedBean_Driver_PDO(R::getDatabaseAdapter()->getDatabase()->getPDO());
     $customLogger = new CustomLogger();
     $pdoDriver->setDebugMode(TRUE, $customLogger);
     $pdoDriver->Execute('SELECT 123');
     asrt(count($customLogger->getLogMessage()), 1);
     $pdoDriver->setDebugMode(TRUE, NULL);
     asrt($pdoDriver->getLogger() instanceof RedBean_Logger_Default, TRUE);
     testpack('Test bean->getProperties method');
     $bean = R::dispense('bean');
     $bean->property = 'hello';
     $props = $bean->getProperties();
     asrt(isset($props['property']), TRUE);
     asrt($props['property'], 'hello');
     testpack('Test snake_case vs CamelCase with Query Builder');
     list($sql, $params) = R::$f->begin()->camelCase()->getQuery();
     asrt(trim($sql), 'camel case');
     list($sql, $params) = R::$f->begin()->personASTeacher()->getQuery();
     asrt(trim($sql), 'person as teacher');
     list($sql, $params) = R::$f->begin()->JOIN()->getQuery();
     asrt(trim($sql), 'join');
     RedBean_SQLHelper::useCamelCase(FALSE);
     list($sql, $params) = R::$f->begin()->camelCase()->getQuery();
     asrt(trim($sql), 'camelCase');
 }
开发者ID:daviddeutsch,项目名称:redbean-adaptive,代码行数:32,代码来源:Misc.php

示例3: setup

 public static function setup()
 {
     self::init();
     self::$dbh = new PDO('mysql:host=' . self::$server . ';dbname=' . self::$databasename . ';', self::$username, self::$password);
     self::$dbh->query('SET NAMES utf8');
     R::setup(self::$dbh);
     R::debug(true, 1);
     R::freeze(true);
     // self::$logsrv = new SystemlogsService();
     self::$queryLogger = R::getDatabaseAdapter()->getDatabase()->getLogger();
 }
开发者ID:limweb,项目名称:webappservice,代码行数:11,代码来源:Pdoconfig.php

示例4: __construct

 public function __construct()
 {
     if (!\R::getDatabaseAdapter()) {
         $dbConfig = (require_once __DIR__ . '/cnf.php');
         static::$_host = $dbConfig['host'];
         static::$_dbname = $dbConfig['dbname'];
         static::$_user = $dbConfig['user'];
         static::$_password = $dbConfig['password'];
         \R::setup('mysql:host=' . static::$_host . ';dbname=' . static::$_dbname, static::$_user, static::$_password, true);
         //for both mysql or mariaDB
     }
     $this->_redbeans = \R::getToolBox()->getRedBean();
     $this->_rbToolbox = \R::getToolBox();
 }
开发者ID:samiksha-singla,项目名称:Api-Framework,代码行数:14,代码来源:BaseModel.php

示例5: get_uniques_for_type

function get_uniques_for_type($type)
{
    $list = array();
    $writer = R::getWriter();
    $adapter = R::getDatabaseAdapter();
    global $currentDriver;
    switch ($currentDriver) {
        case 'mysql':
            $table = $writer->esc($type, TRUE);
            $columns = $adapter->get('
				SELECT
				information_schema.key_column_usage.constraint_name,
				information_schema.key_column_usage.column_name
				FROM
				information_schema.table_constraints
				INNER JOIN information_schema.key_column_usage
				ON (
				information_schema.table_constraints.constraint_name = information_schema.key_column_usage.constraint_name
				AND information_schema.table_constraints.constraint_schema = information_schema.key_column_usage.constraint_schema
				AND information_schema.table_constraints.constraint_catalog = information_schema.key_column_usage.constraint_catalog
				)
				WHERE
				information_schema.table_constraints.table_schema IN (SELECT DATABASE())
				AND information_schema.table_constraints.table_name = ?
				AND information_schema.table_constraints.constraint_type = \'UNIQUE\'
			', array($table));
            $uniques = array();
            foreach ($columns as $column) {
                if (!isset($uniques[$column['constraint_name']])) {
                    $uniques[$column['constraint_name']] = array();
                }
                $uniques[$column['constraint_name']][] = $column['column_name'];
            }
            $list = $uniques;
            break;
        case 'pgsql':
            $table = $writer->esc($type, TRUE);
            $columns = $adapter->get('
				SELECT
				information_schema.key_column_usage.constraint_name,
				information_schema.key_column_usage.column_name
				FROM
				information_schema.table_constraints
				INNER JOIN information_schema.key_column_usage
				ON (
				information_schema.table_constraints.constraint_name = information_schema.key_column_usage.constraint_name
				AND information_schema.table_constraints.constraint_schema = information_schema.key_column_usage.constraint_schema
				AND information_schema.table_constraints.constraint_catalog = information_schema.key_column_usage.constraint_catalog
				)
				WHERE
				information_schema.table_constraints.table_catalog = current_database()
				AND information_schema.key_column_usage.table_schema = ANY( current_schemas( FALSE ) )
				AND information_schema.table_constraints.table_name = ?
				AND information_schema.table_constraints.constraint_type = \'UNIQUE\'
				', array($table));
            $uniques = array();
            foreach ($columns as $column) {
                if (!isset($uniques[$column['constraint_name']])) {
                    $uniques[$column['constraint_name']] = array();
                }
                $uniques[$column['constraint_name']][] = $column['column_name'];
            }
            $list = $uniques;
            break;
        case 'sqlite':
            $uniques = array();
            $table = $writer->esc($type, TRUE);
            $indexes = $adapter->get("PRAGMA index_list({$table})");
            foreach ($indexes as $index) {
                if ($index['unique'] == 1) {
                    $info = $adapter->get("PRAGMA index_info({$index['name']})");
                    if (!isset($uniques[$index['name']])) {
                        $uniques[$index['name']] = array();
                    }
                    foreach ($info as $piece) {
                        $uniques[$index['name']][] = $piece['name'];
                    }
                }
            }
            $list = $uniques;
            break;
        case 'CUBRID':
            try {
                $sqlCode = $adapter->get("SHOW CREATE TABLE `{$type}`");
            } catch (\Exception $e) {
                $sqlCode = '';
            }
            if (!isset($sqlCode[0])) {
                return array();
            }
            $matches = array();
            preg_match_all('/CONSTRAINT\\s+\\[([\\w_]+)\\]\\s+UNIQUE\\s+KEY\\s+\\(([^\\)]+)\\)/', $sqlCode[0]['CREATE TABLE'], $matches);
            $list = array();
            if (!isset($matches[0])) {
                return $list;
            }
            $max = count($matches[0]);
            for ($i = 0; $i < $max; $i++) {
                $columns = explode(',', $matches[2][$i]);
                foreach ($columns as $key => $column) {
//.........这里部分代码省略.........
开发者ID:AntonyAntonio,项目名称:phpback,代码行数:101,代码来源:functions.php

示例6: save

 function save()
 {
     $modified = false;
     foreach ($this->_oldValues as $key => $value) {
         if ($value !== $this->{$key}) {
             $modified = true;
         }
     }
     if (!$this->_canSave || !$modified) {
         return;
     }
     $class = get_called_class();
     $table = self::$tables[$class];
     $primaryKey = self::$keys[$class];
     list($saveType, $columns, $params, $id) = $this->getSaveSQL();
     if ($saveType == 1) {
         // insert
         $values = array();
         foreach ($params as $v) {
             $values[] = '?';
         }
         $sql = "insert into `{$table}` (";
         $sql .= implode(',', $columns);
         $sql .= ") values (";
         $sql .= implode(',', $values);
         $sql .= ")";
         R::exec($sql, $params);
         $this->{$primaryKey} = R::getDatabaseAdapter()->getInsertID();
     } elseif ($saveType == 2) {
         $sql = "update `{$table}` set ";
         $sql .= implode(', ', $columns);
         $sql .= " where `{$primaryKey}` = ?";
         $params[] = $id;
         R::exec($sql, $params);
         # $this->$primaryKey = R::getDatabaseAdapter()->getInsertID();
     }
 }
开发者ID:xJakub,项目名称:LCE,代码行数:37,代码来源:Model.php

示例7: getLog

 public static function getLog()
 {
     $log = R::getDatabaseAdapter()->getDatabase()->getLogger();
     return $log->getLogs();
 }
开发者ID:limweb,项目名称:webappservice,代码行数:5,代码来源:AMFUtil.php

示例8: testDatabaseProperties

 /**
  * Test reflectional functions of database.
  * 
  * @return void
  */
 public function testDatabaseProperties()
 {
     testpack('Testing Database Properties');
     $adapter = R::getDatabaseAdapter();
     if (method_exists(R::$adapter->getDatabase(), 'getPDO')) {
         asrt($adapter->getDatabase()->getPDO() instanceof PDO, TRUE);
     }
     asrt(strlen($adapter->getDatabase()->getDatabaseVersion()) > 0, TRUE);
     asrt(strlen($adapter->getDatabase()->getDatabaseType()) > 0, TRUE);
 }
开发者ID:daviddeutsch,项目名称:redbean-adaptive,代码行数:15,代码来源:Misc.php


注:本文中的R::getDatabaseAdapter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。