本文整理汇总了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);
}
示例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);
}
示例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';
示例4: tearDown
public function tearDown()
{
ORM::configure('logging', false);
ORM::set_db(null);
Model::$auto_prefix_models = null;
}
示例5: tearDown
public function tearDown()
{
ORM::configure('logging', false);
ORM::set_db(null);
}
示例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();