本文整理汇总了PHP中ORM::configure方法的典型用法代码示例。如果您正苦于以下问题:PHP ORM::configure方法的具体用法?PHP ORM::configure怎么用?PHP ORM::configure使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ORM
的用法示例。
在下文中一共展示了ORM::configure方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* When creating the model, the configs for database connection creation are needed
* @param $config
*/
public function __construct($config)
{
//ORM::configure('logging', true);
ORM::configure("mysql:host={$config['db_host']};dbname={$config['db_name']};port={$config['db_port']};charset=utf8");
ORM::configure('username', $config['db_user']);
ORM::configure('password', $config['db_pass']);
}
示例2: configureDb
/**
* Set the database name, username and password
*/
function configureDb($database, $username, $password)
{
\ORM::configure("mysql:host=localhost;dbname={$database};charset=utf8mb4");
\ORM::configure('username', $username);
\ORM::configure('password', $password);
$this->config->set("data.dbName", $database);
}
示例3: __construct
public function __construct()
{
require 'idiorm.php';
ORM::configure('mysql:host=localhost;dbname=etutor');
ORM::configure('username', 'root');
ORM::configure('password', 'pass');
}
示例4: dbInsert
function dbInsert($row, $user)
{
ORM::configure(array('connection_string' => 'mysql:host=localhost;dbname=qiita', 'username' => 'xxxx', 'password' => 'xxxx', 'driver_options', array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8'), 'error_mode', PDO::ERRMODE_WARNING, 'logging', true));
//記事登録
$items = ORM::for_table('items')->where_equal('item_id', $row['item_id'])->find_one();
if (!$items) {
//未登録の記事は登録
$items = ORM::for_table('items')->create();
$items->set($row);
$items->save();
}
//ユーザ情報登録
$users = ORM::for_table('users')->where_equal('user_id', $user['user_id'])->find_one();
print_r($user);
echo $user['user_id'];
if (!$users) {
//未登録のユーザは登録
$users = ORM::for_table('users')->create();
$users->set($user);
echo " 登録<br>";
} else {
//登録済のユーザは更新
$users->set($user);
echo " 更新<br>";
}
$users->save();
}
示例5: idiorm
private function idiorm($path)
{
if (!mapi_include_abs_path($path, 'lib')) {
return null;
}
if (!isset(MSettings::$db_host) || !strlen(MSettings::$db_host) > 0) {
return false;
}
if (!isset(MSettings::$db) || !strlen(MSettings::$db) > 0) {
return false;
}
if (!isset(MSettings::$db_user) || !strlen(MSettings::$db_user) > 0) {
return false;
}
if (!isset(MSettings::$db_pass) || !strlen(MSettings::$db_pass) > 0) {
return false;
}
try {
ORM::configure('mysql:host=' . MSettings::$db_host . ';dbname=' . MSettings::$db);
ORM::configure('username', MSettings::$db_user);
ORM::configure('password', MSettings::$db_pass);
ORM::configure('driver_options', array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8'));
$test = ORM::for_table('preferences')->create();
if ($test) {
return true;
} else {
return false;
}
} catch (PDOException $e) {
return false;
}
}
示例6: updateRowRoute
/**
* Create POST route for updating a row
*/
protected function updateRowRoute()
{
// Save Model
$this->app->post('/{table}/save', function ($request, $response, $args) {
$newResponse = $response->withHeader('Content-type', 'application/json');
try {
// Get primary key of table from response
$primary_key = $request->getParam('primary_key');
// Get primary key value of this model from response
$primary_key_value = $request->getParam('params')[$primary_key];
// Set table's primary key for saving model
ORM::configure('id_column_overrides', array($args['table'] => $primary_key));
// Create model from query, set new parameters, and save it
$model = ORM::for_table($args['table'])->where($primary_key, intval(6))->find_many()[0];
$model->set($request->getParam('params'));
$success = $model->save();
$response_body = array("success" => $success);
} catch (Exception $e) {
error_log(ORM::get_last_statement()->queryString);
error_log($e->getMessage());
$response_body = array("error" => $e->getMessage());
}
// Add data to response in JSON format
$newResponse->write(json_encode($response_body));
return $newResponse;
});
}
示例7: tearDown
public function tearDown()
{
ORM::configure('logging', false);
ORM::configure('logging', false, self::ALTERNATE);
ORM::set_db(null);
ORM::set_db(null, self::ALTERNATE);
}
示例8: __construct
public function __construct()
{
\ORM::configure('mysql:host=localhost;dbname=igorpronin_list');
\ORM::configure('username', 'igorpronin_list');
\ORM::configure('password', '');
//todo скрыть при размещении на github
}
示例9: connect
function connect()
{
ORM::configure('mysql:host=localhost;dbname=fake');
ORM::configure('username', 'root');
ORM::configure('password', 'root');
ORM::configure('error_mode', PDO::ERRMODE_WARNING);
}
示例10: __construct
public function __construct()
{
ORM::configure('mysql:host=localhost;dbname=loft_shop');
ORM::configure('username', 'root');
ORM::configure('password', '');
ORM::configure('driver_options', array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8'));
ORM::configure('id_column_overrides', array('user_group' => array('id_user', 'id_group')));
}
示例11: connect
function connect()
{
ORM::configure('mysql:host=localhost;dbname=crm');
ORM::configure('username', 'root');
ORM::configure('password', 'MOTDEPASSE');
ORM::configure('error_mode', PDO::ERRMODE_WARNING);
ORM::configure('return_result_sets', true);
}
示例12: database
function database()
{
ORM::configure('mysql:host=localhost;dbname=fake');
ORM::configure('username', 'root');
ORM::configure('password', 'root');
ORM::configure('error_mode', PDO::ERRMODE_WARNING);
ORM::configure('return_result_sets', true);
}
示例13: connect
protected function connect()
{
ORM::configure('mysql:host=' . $this->config["db"]["host"] . ";dbname=" . $this->config["db"]["dbname"]);
ORM::configure('username', $this->config["db"]["username"]);
ORM::configure('password', $this->config["db"]["password"]);
ORM::configure('error_mode', PDO::ERRMODE_WARNING);
ORM::configure('return_result_sets', true);
}
示例14: run
public function run()
{
$spider_name = isset($_REQUEST['spider']) ? $_REQUEST['spider'] : '';
$action = isset($_REQUEST['action']) ? $_REQUEST['action'] : '';
$title = 'Spider';
$spider = $this->get_spider($spider_name);
if ($spider) {
$title = $spider->get_title();
// DB
$dbpath = $spider->get_db_path();
$empty_database = false;
if (!is_file($dbpath)) {
touch($dbpath);
$empty_database = true;
}
$dbpath = realpath($dbpath);
ORM::configure('sqlite:' . $dbpath);
if ($empty_database) {
$spider->create_database();
}
}
// header
include '_header.php';
// loaded with bootstrap
// process
?>
<ul class="nav nav-tabs">
<?php
$this->print_menu('Fakku');
?>
<?php
$this->print_menu('Hbrowse');
?>
<?php
$this->print_menu('HentaiMangaOnline');
?>
<?php
$this->print_menu('FreeHManga');
?>
</ul>
<div class="container">
<?php
if ($spider) {
$method = 'action_' . $action;
if (method_exists($spider, $method)) {
$spider->{$method}();
} else {
echo 'Choose something';
}
} else {
echo 'Select Spider';
}
?>
</div>
<?php
// footer
include '_footer.php';
}
示例15: setUp
public function setUp()
{
// Enable logging
ORM::configure('logging', true);
ORM::configure('caching', false);
// Set up the dummy database connection
$db = new DummyPDO('sqlite::memory:');
ORM::setDatabase($db);
}