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


PHP ORM::set_db方法代码示例

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


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

示例1: tearDown

 public function tearDown()
 {
     ORM::configure('logging', false);
     ORM::configure('logging', false, self::ALTERNATE);
     ORM::set_db(null);
     ORM::set_db(null, self::ALTERNATE);
 }
开发者ID:arunkapil,项目名称:Granada,代码行数:7,代码来源:MultipleConnectionsTest.php

示例2: setup_db

 public function setup_db()
 {
     $settings = $this->get_setting("db");
     if (isset($settings['socket']) && strlen($settings['socket']) > 2) {
         $dsn = "{$settings['type']}:unix_socket={$settings['socket']};dbname={$settings['name']}";
     } else {
         $dsn = "{$settings['type']}:host={$settings['host']};port={$settings['port']};dbname={$settings['name']}";
     }
     $driver_command = array(\PDO::MYSQL_ATTR_INIT_COMMAND => "SET SESSION sql_mode='TRADITIONAL'");
     $db = new \PDO($dsn, $settings["username"], $settings["password"], $driver_command);
     $db->setAttribute(\PDO::ATTR_ERRMODE, \PDO::ERRMODE_EXCEPTION);
     self::$db = $db;
     if (isset($settings['table'])) {
         $this->table = $settings['table'];
     }
     if (isset($settings['primary_key'])) {
         $this->primary_key = $settings['primary_key'];
     }
     $query["logging"] = true;
     Query::set_db($db);
     Query::configure($query);
 }
开发者ID:phpwax,项目名称:db,代码行数:22,代码来源:SQLBackend.php

示例3: dirname

 * Basic testing for Dakota.
 *
 * We deliberately don't test the query API - that's Idiorm's job.
 * We just test Paris-specific functionality.
 *
 * Checks that the generated SQL is correct
 *
 */
require_once dirname(__FILE__) . "/idiorm.php";
require_once dirname(__FILE__) . "/../dakota.php";
require_once dirname(__FILE__) . "/test_classes.php";
// Enable logging
ORM::configure('logging', true);
// Set up the dummy database connection
$db = new DummyPDO('sqlite::memory:');
ORM::set_db($db);
class Simple extends Model
{
}
Model::factory('Simple')->find_many();
$expected = 'SELECT * FROM `simple`';
Tester::check_query("Simple auto table name", $expected);
class ComplexModelClassName extends Model
{
}
Model::factory('ComplexModelClassName')->find_many();
$expected = 'SELECT * FROM `complex_model_class_name`';
Tester::check_query("Complex auto table name", $expected);
class ModelWithCustomTable extends Model
{
    public static $_table = 'custom_table';
开发者ID:powerpak,项目名称:dakota,代码行数:31,代码来源:test_queries.php

示例4: tearDown

 public function tearDown()
 {
     ORM::configure('logging', false);
     ORM::set_db(null);
     Model::$auto_prefix_models = null;
 }
开发者ID:arunkapil,项目名称:Granada,代码行数:6,代码来源:ModelPrefixingTest.php

示例5: tearDown

 public function tearDown()
 {
     ORM::configure('logging', false);
     ORM::set_db(null);
 }
开发者ID:arunkapil,项目名称:sudzy,代码行数:5,代码来源:SudzyTest.php

示例6: Exception

<?php

// composer
$composer_autoload_file = __DIR__ . '/vendor/autoload.php';
if (!file_exists($composer_autoload_file)) {
    throw new Exception('You need to run "composer install"!');
}
require_once __DIR__ . '/vendor/autoload.php';
// models
require_once __DIR__ . '/models.php';
// db & sess
$pdo = new PDO('mysql:host=localhost;dbname=crudexample;charset=utf8', 'root', 'root');
ORM::set_db($pdo);
session_start();
开发者ID:cal127,项目名称:phpcrud,代码行数:14,代码来源:boot.php


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