コード例 #1
0
ファイル: Context.class.php プロジェクト: nebtrx/stratos
 protected function initialize()
 {
     $this->config = ConfigManager::bind();
     // setting limit time
     set_time_limit($this->config['webbot']['time_limit']);
     $this->container = new Pimple();
     // initializing persistence
     $config = $this->config;
     if ($config['general']['persistence']['use_database']) {
         if (!isset($config['general']['persistence']['connections'])) {
             throw new ConfigurationAccessException(101);
         }
         if (!is_array($config['general']['persistence']['connections']) || count($config['general']['persistence']['connections']) < 1) {
             throw new ConfigurationAccessException(102);
         }
         $connections = $config['general']['persistence']['connections'];
         // initializing ActiveRecord
         ActiveRecord\Config::initialize(function ($cfg) use($connections, $config) {
             $cfg->set_model_directory($config->getBaseDir() . '/' . $config['general']['persistence']['models_dir']);
             $cfg->set_connections($connections);
             // assigning as default conection the first one
             $default_con_index = array_shift(array_keys($connections));
             $cfg->set_default_connection($default_con_index);
         });
     }
     $this->loadStartups();
 }
コード例 #2
0
ファイル: fphanoit.php プロジェクト: yohitan12/fphanoit
 /**
  * Abre la conexion teniendo en cuenta los parametros de application/config/config.php
  */
 private function openDatabaseConnection()
 {
     ActiveRecord\Config::initialize(function ($cfg) {
         $cfg->set_model_directory('application/models');
         $cfg->set_connections(array('development' => DB_TYPE . '://' . DB_USER . ':' . DB_PASS . '@' . DB_HOST . '/' . DB_NAME));
     });
 }
コード例 #3
0
ファイル: BaseController.php プロジェクト: ar-perficient/mvc
 /**
  * Initalize the ORM
  * @return \Config_Framework_BaseController
  */
 protected function initORM()
 {
     ActiveRecord\Config::initialize(function ($cfg) {
         $cfg->set_model_directory($this->getClassDir());
         $cfg->set_connections(array('development' => 'mysql://*****:*****@127.0.0.1/mvc'));
     });
     return $this;
 }
コード例 #4
0
 function __construct() {
     
     $this->exhibitSettings();
     
     ActiveRecord\Config::initialize(function($cfg){
         $cfg->set_model_directory('model');
         $cfg->set_connections(array('development' => 'mysql://*****:*****@localhost/prokatvros'));
     });
 }
コード例 #5
0
ファイル: services.php プロジェクト: jobinpankajan/WeGive
 function __construct()
 {
     // This closure is the winner in "because we can" category.
     ActiveRecord\Config::initialize(function ($cfg) {
         $conn = array('development' => Services::ARURL);
         $cfg->set_model_directory('models');
         $cfg->set_connections($conn);
         $cfg->set_default_connection('development');
     });
 }
コード例 #6
0
 public function registerSupportLibraries()
 {
     include_once SUPPORT_DIRECTORY . '/parsedown/Parsedown.php';
     include_once SUPPORT_DIRECTORY . '/php-activerecord/ActiveRecord.php';
     ActiveRecord\Config::initialize(function ($cfg) {
         /** @var ActiveRecord\Config $cfg */
         $cfg->set_model_directory(APPLICATION_DIRECTORY . '/models/');
         $cfg->set_connections(array('development' => sprintf('mysql://%s:%s@%s/%s', $this->configuration->database->username, $this->configuration->database->password, $this->configuration->database->host, $this->configuration->database->databaseName)));
     });
 }
コード例 #7
0
 /**
  * @access public
  *      * 
  * @importante metodo @Core contem include as principais class dos sistema
  * 
  * @param array() $main
  * 
  * 
  */
 public static function begin($main)
 {
     define('DSN', $main['config']['db']['dsn']);
     ActiveRecord\Config::initialize(function ($cfg) {
         // $cfg->set_model_directory(MODEL);
         $cfg->set_connections(array('development' => DSN));
     });
     date_default_timezone_set($main['config']['timezone']);
     Controller::begin($main)->load();
 }
コード例 #8
0
function connect_to_db()
{
    require_once dirname(__FILE__) . '/php-activerecord/ActiveRecord.php';
    $connections = array('development' => 'mysql://*****:*****@apochroma.ch/debitorenbuchhaltung?charset=utf8');
    #'production' => '');
    ActiveRecord\Config::initialize(function ($cfg) use($connections) {
        $cfg->set_model_directory(dirname(__FILE__) . '/models');
        $cfg->set_connections($connections);
        $cfg->set_default_connection('development');
        #$cfg->set_default_connection('production');
    });
}
コード例 #9
0
ファイル: Bootstrap.php プロジェクト: xinson/yafPlus
 public function _initDatabase()
 {
     if (!defined('PHP_VERSION_ID') || PHP_VERSION_ID < 50300) {
         die('PHP ActiveRecord requires PHP 5.3 or higher');
     }
     ActiveRecord\Config::initialize(function ($cfg) {
         $mysqlConfig = $this->config->get("database.mysql");
         $cfg->set_model_directory(APP_PATH . '/app/models');
         $cfg->set_connections(array('production' => 'mysql://' . $mysqlConfig->user . ':' . $mysqlConfig->password . '@' . $mysqlConfig->host . '/' . $mysqlConfig->database, 'development' => 'mysql://' . $mysqlConfig->user . ':' . $mysqlConfig->password . '@' . $mysqlConfig->host . '/' . $mysqlConfig->database));
         $cfg->set_default_connection('production');
     });
 }
コード例 #10
0
ファイル: class.base.php プロジェクト: 469306621/Languages
	public static function loadActiveRecord() {
		$connections = array(
			'development' => 'mysql://'.MY_DB_USER.':'.MY_DB_PASS.'@'.MY_DB_SERVER.'/'.MY_DB_NAME
		);

		// initialize ActiveRecord
		ActiveRecord\Config::initialize(function($cfg) use ($connections)
		{
		    $cfg->set_model_directory(APP_PATH . '/models');
		    $cfg->set_connections($connections);
		});
	}
コード例 #11
0
 public function __construct()
 {
     // Set a path to the spark root that we can reference
     $spark_path = dirname(__DIR__) . '/';
     // Include the CodeIgniter database config file
     // Is the config file in the environment folder?
     if (!defined('ENVIRONMENT') or !file_exists($file_path = APPPATH . 'config/' . ENVIRONMENT . '/database.php')) {
         if (!file_exists($file_path = APPPATH . 'config/database.php')) {
             show_error('PHPActiveRecord: The configuration file database.php does not exist.');
         }
     }
     require $file_path;
     // Include the ActiveRecord bootstrapper
     require_once $spark_path . 'vendor/php-activerecord/ActiveRecord.php';
     // PHPActiveRecord allows multiple connections.
     $connections = array();
     if ($db && $active_group) {
         foreach ($db as $conn_name => $conn) {
             // Build the DSN string for each connection
             $connections[$conn_name] = $conn['dbdriver'] . '://' . $conn['username'] . ':' . $conn['password'] . '@' . $conn['hostname'] . '/' . $conn['database'] . '?charset=' . $conn['char_set'];
         }
         // Initialize PHPActiveRecord
         ActiveRecord\Config::initialize(function ($cfg) use($connections, $active_group) {
             $cfg->set_model_directories(APPPATH . 'models/core/', APPPATH . 'models/', APPPATH . 'models/delete/');
             // $cfg->set_model_directory(APPPATH.'models/');
             $cfg->set_connections($connections);
             // This connection is the default for all models
             $cfg->set_default_connection($active_group);
             // To enable logging and profiling, install the Log library
             // from pear, create phpar.log inside of your application/logs
             // directory, then uncomment the following block:
             if (is_writable(APPPATH . 'logs/query.log')) {
                 $log_file = APPPATH . 'logs/query.log';
                 include_once BASEPATH . 'log/log.php';
                 $logger = Log::singleton('file', $log_file, 'ident', array('mode' => 0664, 'timeFormat' => '%Y-%m-%d %H:%M:%S'));
                 $cfg->set_logging(true);
                 $cfg->set_logger($logger);
             }
             /*
             $log_file = $_SERVER['DOCUMENT_ROOT'].'/application/logs/phpar.log';
             
             if (file_exists($log_file) and is_writable($log_file)) {
                 include 'Log.php';
                 $logger = Log::singleton('file', $log_file ,'ident',array('mode' => 0664, 'timeFormat' =>  '%Y-%m-%d %H:%M:%S'));
                 $cfg->set_logging(true);
                 $cfg->set_logger($logger);
             } else {
                 log_message('warning', 'Cannot initialize logger. Log file does not exist or is not writeable');
             }
             */
         });
     }
 }
コード例 #12
0
ファイル: db.php プロジェクト: p-mob2015/idea19
function includeDB($path2home = "", $connectionString)
{
    /*
    Initialize a database
    PARAM:
    # path2home - relative path of home dir to referer file
    RESULT:
    # none
    */
    include_once $path2home . 'config/dir.php';
    require_once $path2home . _DIR_LIB_ARECORD . 'ActiveRecord.php';
    define('_TMP_DIR_MODEL_DYNAMIC', $path2home . _DIR_MODEL);
    define('_TMP_DB_CNCT_STRING', $connectionString);
    ActiveRecord\Config::initialize(function ($cfg) {
        $cfg->set_model_directory(_TMP_DIR_MODEL_DYNAMIC);
        $cfg->set_connections(array('development' => _TMP_DB_CNCT_STRING));
    });
}
コード例 #13
0
ファイル: database.php プロジェクト: boulama/DreamVids
 public static function connect()
 {
     ActiveRecord\Config::initialize(function ($cfg) {
         $dbHost = Config::getValue_('dbHost');
         $dbUser = Config::getValue_('dbUser');
         $dbPass = Config::getValue_('dbPass');
         $dbName = Config::getValue_('dbName');
         $cfg->set_model_directory(MODEL);
         $cfg->set_connections(array('development' => 'mysql://' . $dbUser . ':' . $dbPass . '@' . $dbHost . '/' . $dbName));
         try {
             ConnectionManager::get_connection("development");
         } catch (Exception $e) {
             $response = Utils::getInternalServerErrorResponse(true);
             $response->send();
             die;
         }
     });
 }
コード例 #14
0
ファイル: Activerecord.php プロジェクト: git-ecorise/ctshop
 function __construct()
 {
     global $config;
     // Load database configuration from CodeIgniter
     include APPPATH . '/config/site_config.php';
     // Get connections from database.php
     $dsn = array();
     if ($config["db"]) {
         // Convert to dsn format
         $dsn["default"] = $config["db"]['dbdriver'] . '://' . $config["db"]['username'] . ':' . $config["db"]['password'] . '@' . $config["db"]['hostname'] . '/' . $config["db"]['database'];
     }
     $active_group = "default";
     // Initialize ActiveRecord
     ActiveRecord\Config::initialize(function ($cfg) use($dsn, $active_group) {
         $cfg->set_model_directory(APPPATH . '/models');
         $cfg->set_connections($dsn);
         $cfg->set_default_connection($active_group);
     });
 }
コード例 #15
0
 function __construct()
 {
     // Load database configuration from CodeIgniter
     include APPPATH . '/config/database.php';
     // Get connections from database.php
     $dsn = array();
     if ($db) {
         foreach ($db as $name => $db_values) {
             // Convert to dsn format
             $dsn[$name] = $db[$name]['dbdriver'] . '://' . $db[$name]['username'] . ':' . $db[$name]['password'] . '@' . $db[$name]['hostname'] . '/' . $db[$name]['database'];
         }
     }
     // Initialize ActiveRecord
     ActiveRecord\Config::initialize(function ($cfg) use($dsn, $active_group) {
         $cfg->set_model_directory(APPPATH . '/models');
         $cfg->set_connections($dsn);
         $cfg->set_default_connection($active_group);
     });
 }
コード例 #16
0
 /**
  * @access public
  *      * 
  * @importante metodo @Core contem include as principais class dos sistema
  * 
  * @param array() $main
  * 
  * 
  */
 public static function run($main)
 {
     set_include_path(get_include_path() . PATH_SEPARATOR . Kanda_CORE);
     define('DSN', $main['db']['dsn']);
     define('THEME', $main['app']['view'][1][0]);
     define('MODEL', WWW_ROOT . $main['app']['model']);
     define('VIEW', $main['app']['view'][0]);
     define('CONTROLLER', $main['app']['controller']);
     if (isset($main['app']['diralias'])) {
         define('ALIAS', $main['app']['diralias']);
     } else {
         define('ALIAS', '');
     }
     ActiveRecord\Config::initialize(function ($cfg) {
         $cfg->set_model_directory(MODEL);
         $cfg->set_connections(array('development' => DSN));
     });
     date_default_timezone_set($main['app']['timezone']);
     $controller = new Controller();
     $controller->setController($main['app']['view'][1]);
 }
コード例 #17
0
ファイル: base.php プロジェクト: BaylorRae/Borealis
 /**
  * Get the DB connection info, and connect the the database using PHP ActiveRecord
  * Can use (mysql, sqlite, postgresql, oracle)
  *
  * @return void
  * @author Baylor Rae'
  */
 public function load_db()
 {
     $DB = array();
     $db_info = null;
     include_once BASE_PATH . '/config/database.php';
     // Check for environment db connection info
     if (isset($DB[ENVIRONMENT])) {
         if (isset($DB['defaults'])) {
             $db_info = (object) array_merge($DB['defaults'], $DB[ENVIRONMENT]);
         } else {
             $db_info = (object) $DB[ENVIRONMENT];
         }
         if (isset($db_info->type) && in_array($db_info->type, array('mysql', 'sqlite', 'postgresql', 'oracle'))) {
             $connection = null;
             switch ($db_info->type) {
                 case 'mysql':
                     $connection = array('development' => 'mysql://' . $db_info->username . ':' . $db_info->password . '@' . $db_info->host . '/' . $db_info->name);
                     break;
                 case 'sqlite':
                     $connection = array('development' => 'sqlite://' . BASE_PATH . '/system/db/' . $db_info->file);
                     break;
                 case 'postgresql':
                     $connection = array('development' => 'pgsql://' . $db_info->username . ':' . $db_info->password . '@' . $db_info->host . '/' . $db_info->name);
                     break;
                 case 'oracle':
                     $connection = array('development' => 'oci://' . $db_info->username . ':' . $db_info->password . '@' . $db_info->host . '/' . $db_info->name);
                     break;
             }
             ActiveRecord\Config::initialize(function ($cfg) use($connection) {
                 $cfg->set_model_directory(BASE_PATH . '/system/models');
                 $cfg->set_connections($connection);
             });
         } else {
             die('<br />Make sure you have set a database type in <code>config/database.php</code> (mysql, sqlite, postgresql, oracle)');
         }
     } else {
         die('<br />Make sure you have set your environment in <code>config/config.php</code> and your database information in <code>config/database.php</code>');
     }
 }
コード例 #18
0
ファイル: Autoload.php プロジェクト: dalinhuang/yike
/**
 * 自动加载类函数
 * @param string $className
 */
function loadClassFile($className)
{
    // 延迟加载 ActiveRecord,使得
    if ($className == "ActiveRecord\\Model") {
        require_once LIBPATH . 'PHPActiveRecord' . DIRECTORY_SEPARATOR . 'ActiveRecord.php';
        ActiveRecord\Config::initialize(function ($cfg) {
            $cfg->set_model_directory($GLOBALS['config']['moddir']);
            $cfg->set_connections($GLOBALS['config']['dbconfig']);
            $cfg->set_default_connection(!isset($_SERVER['HTTP_APPNAME']) ? 'local' : 'sae');
        });
        return;
    }
    $file = str_replace('\\', DIRECTORY_SEPARATOR, $className);
    $dirs = getSubDir(SYSPATH);
    //加载 sytem 下的所有目录作为候选目录
    foreach ($dirs as $dir) {
        $filename = SYSPATH . $dir . DIRECTORY_SEPARATOR . $file . '.php';
        if (file_exists($filename)) {
            require_once $filename;
            return;
        }
    }
}
コード例 #19
0
ファイル: inc.config.php プロジェクト: jakemdunn/node-player
 public function Config()
 {
     global $config;
     $config = $this;
     $host = getenv('HTTP_HOST');
     if (php_sapi_name() == 'cli') {
         $host = 'localhost';
     }
     foreach ($this->options as $urls => $option) {
         if (preg_match('#' . $urls . '#', $host)) {
             $this->config = $option;
             break;
         }
     }
     $this->checkConfig();
     $this->defineConfig();
     ActiveRecord\Config::initialize(function ($cfg) {
         global $config;
         $url = sprintf('mysql://%1$s:%2$s@%3$s/%4$s', $config->db_user, $config->db_pass, $config->db_host, $config->db_name);
         $cfg->set_model_directory(DOC_ROOT . '/models');
         $cfg->set_connections(array('development' => $url));
     });
 }
コード例 #20
0
 public function __construct()
 {
     // Set a path to the spark root that we can reference
     $spark_path = dirname(__DIR__) . '/';
     // Include the CodeIgniter Database File
     require_once APPPATH . 'config/database' . EXT;
     // Include the ActiveRecord bootstrapper
     require_once $spark_path . 'vendor/php-activerecord/ActiveRecord.php';
     // PHPActiveRecord allows multiple connections.
     $connections = array();
     if ($db && $active_group) {
         foreach ($db as $conn_name => $conn) {
             // Build the DSN string for each connection
             $connections[$conn_name] = $conn['dbdriver'] . '://' . $conn['username'] . ':' . $conn['password'] . '@' . $conn['hostname'] . '/' . $conn['database'];
         }
         // Initialize PHPActiveRecord
         ActiveRecord\Config::initialize(function ($cfg) use($connections, $active_group) {
             $cfg->set_model_directory(APPPATH . 'models/');
             $cfg->set_connections($connections);
             // This connection is the default for all models
             $cfg->set_default_connection($active_group);
         });
     }
 }
コード例 #21
0
ファイル: server.php プロジェクト: Vinz93/WS-ECommerce
<?php

require_once "vendor/nuSOAP/nusoap.php";
require_once 'vendor/php-activerecord/ActiveRecord.php';
ActiveRecord\Config::initialize(function ($cfg) {
    $cfg->set_model_directory('models');
    $cfg->set_connections(array('development' => 'mysql://*****:*****@127.0.0.1/banco'));
    $cfg->set_default_connection("development");
});
// Funcion que recibe por parámetro el nombre del componente y la disponibilidad.
function pago($nro_tarjeta, $cod_seg, $fecha_exp, $monto, $ci, $nro_afiliado)
{
    $client = Cliente::first('all', array('conditions' => array(' ci = ?', $ci)));
    $tarjeta = Tarjeta::first('all', array('conditions' => array(' nro_tarjeta = ?', $nro_tarjeta)));
    $banco = Cuenta::first('all', array('conditions' => array(' nro_afiliado = ?', $nro_afiliado)));
    // var_dump($client->nombre);
    if ($client != NULL && $tarjeta != NULL && $banco != NULL) {
        $cuentaCliente = Cuenta::first('all', array('conditions' => array(' ci_cliente = ?', $ci)));
        if ($cuentaCliente->nro_afiliado == $tarjeta->nro_afiliado && $cod_seg == $tarjeta->cod_seg) {
            if ($monto <= $cuentaCliente->saldo) {
                $cuentaCliente->saldo = $cuentaCliente->saldo - $monto;
                $cuentaCliente->save();
                $banco->saldo = $banco->saldo + $monto;
                $banco->save();
                Transaccion::create(array('nro_tarjeta' => $nro_tarjeta, 'ci' => $ci, 'fecha_transaccion' => date("Y-m-d H:i:s"), 'monto' => $monto, "nro_afiliado_adquiriente" => $nro_afiliado, 'cod' => "00"));
                return "00";
            } else {
                Transaccion::create(array('nro_tarjeta' => $nro_tarjeta, 'ci' => $ci, 'fecha_transaccion' => date("Y-m-d H:i:s"), 'monto' => $monto, "nro_afiliado_adquiriente" => $nro_afiliado, 'cod' => "01"));
                return "01";
            }
        } else {
コード例 #22
0
<?php

/**
 * Modules dependencies.
 */
require './vendors/Slim/Slim.php';
require './vendors/php-activerecord/ActiveRecord.php';
require './controllers/TodoController.php';
require './controllers/HomeController.php';
require './api/TodoApiController.php';
/**
 * Initialize Active record.
 */
ActiveRecord\Config::initialize(function ($cfg) {
    $cfg->set_model_directory('./models');
    $cfg->set_connections(array('development' => 'mysql://*****:*****@localhost/phptodo'));
});
/**
 * Configuring slim application.
 */
\Slim\Slim::registerAutoloader();
$app = new \Slim\Slim();
$app->config(array('debug' => true, 'templates.path' => './views'));
/**
 * run controller
 */
$todoController = new TodoController($app);
$homeController = new HomeController($app);
/**
 * run api
 */
コード例 #23
0
<?php

/*LanOps Manager - CONFIG*/
$ERRORLOG = 0;
//DATABASE CONENCTION
require_once 'ActiveRecord.php';
ActiveRecord\Config::initialize(function ($cfg) {
    $cfg->set_model_directory($_SERVER['DOCUMENT_ROOT'] . '/includes/libs/models');
    $cfg->set_connections(array('development' => 'mysql://*****:*****@localhost/manager'));
});
// EMAIL SETTINGS
コード例 #24
0
ファイル: database.php プロジェクト: solidet/somrak
<?php

require_once '../vendor/php-activerecord/php-activerecord/ActiveRecord.php';
ActiveRecord\Config::initialize(function ($cfg) {
    $cfg->set_model_directory('../app/models');
    $cfg->set_connections(array('development' => 'mysql://*****:*****@localhost/somrak'));
});
コード例 #25
0
ファイル: 006_db.conf.php プロジェクト: orguin/slimkeleton
        $GLOBALS['SK']['DB']['HOST'] = '';
        $GLOBALS['SK']['DB']['USER'] = '';
        $GLOBALS['SK']['DB']['PASS'] = '';
        break;
    case 'production':
    default:
        $GLOBALS['SK']['DB']['DRIVER'] = 'sqlite';
        // mongodb, mysql, pgsql, oci, sqlite
        $GLOBALS['SK']['DB']['FILE'] = 'test.db';
        // only sqlite
        $GLOBALS['SK']['DB']['NAME'] = '';
        $GLOBALS['SK']['DB']['HOST'] = '';
        $GLOBALS['SK']['DB']['USER'] = '';
        $GLOBALS['SK']['DB']['PASS'] = '';
        break;
}
if ('mongodb' === $GLOBALS['SK']['DB']['DRIVER']) {
    BaseMongoRecord::$connection = new Mongo('mongodb://' . $GLOBALS['SK']['DB']['USER'] . ':' . $GLOBALS['SK']['DB']['PASS'] . '@' . $GLOBALS['SK']['DB']['HOST'] . '/' . $GLOBALS['SK']['DB']['NAME']);
    BaseMongoRecord::$database = $GLOBALS['SK']['DB']['NAME'];
} else {
    $dbcfg = ActiveRecord\Config::instance();
    $dbcfg->set_model_directory(path('app.model'));
    if ('sqlite' === $GLOBALS['SK']['DB']['DRIVER']) {
        $dbcfg->set_connections(array(env() => 'sqlite:' . path('storage.database', true) . $GLOBALS['SK']['DB']['FILE']));
    } else {
        $dbcfg->set_connections(array(env() => $GLOBALS['SK']['DB']['DRIVER'] . '://' . $GLOBALS['SK']['DB']['USER'] . ':' . $GLOBALS['SK']['DB']['PASS'] . '@' . $GLOBALS['SK']['DB']['HOST'] . '/' . $GLOBALS['SK']['DB']['NAME']));
    }
    ActiveRecord\Config::initialize(function ($dbcfg) {
        $dbcfg->set_default_connection(env());
    });
}
コード例 #26
0
<?php

bu::lib('php-activerecord/ActiveRecord');
ActiveRecord\Config::initialize(function ($cfg) {
    $dbs = bu::config('db');
    $connections = array();
    foreach ($dbs as $k => $v) {
        $connections[$k] = sprintf('%s://%s:%s@%s/%s', $v['driver'], $v['user'], $v['password'], $v['host'], $v['database']);
    }
    $cfg->set_connections($connections);
    $cfg->set_default_connection('default');
});
コード例 #27
0
ファイル: config.php プロジェクト: EFreezen/M2_CMS
<?php

session_start();
require_once __DIR__ . '/vendor/autoload.php';
ActiveRecord\Config::initialize(function ($cfg) {
    $cfg->set_connections(array('development' => 'mysql://root@localhost/user_login'));
});
コード例 #28
0
ファイル: config.php プロジェクト: visavi/phpactiverecord
}
ActiveRecord\Config::initialize(function ($cfg) {
    $cfg->set_model_directory(realpath(__DIR__ . '/../models'));
    $cfg->set_connections(array('mysql' => getenv('PHPAR_MYSQL') ?: 'mysql://*****:*****@127.0.0.1/test', 'pgsql' => getenv('PHPAR_PGSQL') ?: 'pgsql://*****:*****@127.0.0.1/test', 'oci' => getenv('PHPAR_OCI') ?: 'oci://*****:*****@127.0.0.1/dev', 'sqlite' => getenv('PHPAR_SQLITE') ?: 'sqlite://test.db'));
    $cfg->set_default_connection('mysql');
    for ($i = 0; $i < count($GLOBALS['argv']); ++$i) {
        if ($GLOBALS['argv'][$i] == '--adapter') {
            $cfg->set_default_connection($GLOBALS['argv'][$i + 1]);
        } elseif ($GLOBALS['argv'][$i] == '--slow-tests') {
            $GLOBALS['slow_tests'] = true;
        }
    }
    if (class_exists('Log_file')) {
        $logger = new Log_file(dirname(__FILE__) . '/../log/query.log', 'ident', array('mode' => 0664, 'timeFormat' => '%Y-%m-%d %H:%M:%S'));
        $cfg->set_logging(true);
        $cfg->set_logger($logger);
    } else {
        if ($GLOBALS['show_warnings'] && !isset($GLOBALS['show_warnings_done'])) {
            echo "(Logging SQL queries disabled, PEAR::Log not found.)\n";
        }
        DatabaseTest::$log = false;
    }
    if ($GLOBALS['show_warnings'] && !isset($GLOBALS['show_warnings_done'])) {
        if (!extension_loaded('memcache')) {
            echo "(Cache Tests will be skipped, Memcache not found.)\n";
        }
    }
    date_default_timezone_set('UTC');
    $GLOBALS['show_warnings_done'] = true;
});
error_reporting(E_ALL | E_STRICT);
コード例 #29
0
ファイル: orders.php プロジェクト: visavi/phpactiverecord
<?php

require_once __DIR__ . '/../../ActiveRecord.php';
// initialize ActiveRecord
ActiveRecord\Config::initialize(function ($cfg) {
    $cfg->set_model_directory(__DIR__ . '/models');
    $cfg->set_connections(array('development' => 'mysql://*****:*****@127.0.0.1/orders_test'));
    // you can change the default connection with the below
    //$cfg->set_default_connection('production');
});
// create some people
$jax = new Person(array('name' => 'Jax', 'state' => 'CA'));
$jax->save();
// compact way to create and save a model
$tito = Person::create(array('name' => 'Tito', 'state' => 'VA'));
// place orders. tax is automatically applied in a callback
// create_orders will automatically place the created model into $tito->orders
// even if it failed validation
$pokemon = $tito->create_orders(array('item_name' => 'Live Pokemon', 'price' => 6999.99));
$coal = $tito->create_orders(array('item_name' => 'Lump of Coal', 'price' => 100.0));
$freebie = $tito->create_orders(array('item_name' => 'Freebie', 'price' => -100.99));
if (count($freebie->errors) > 0) {
    echo "[FAILED] saving order {$freebie->item_name}: " . join(', ', $freebie->errors->full_messages()) . "\n\n";
}
// payments
$pokemon->create_payments(array('amount' => 1.99, 'person_id' => $tito->id));
$pokemon->create_payments(array('amount' => 4999.5, 'person_id' => $tito->id));
$pokemon->create_payments(array('amount' => 2.5, 'person_id' => $jax->id));
// reload since we don't want the freebie to show up (because it failed validation)
$tito->reload();
echo "{$tito->name} has " . count($tito->orders) . " orders for: " . join(', ', ActiveRecord\collect($tito->orders, 'item_name')) . "\n\n";
コード例 #30
0
ファイル: load.php プロジェクト: AlexeyBN/w.gregfurlong.ie
<?php

require_once "core/Common.php";
require_once "config.php";
require_once 'includes/plugins/php-activerecord/ActiveRecord.php';
//require_once 'core/B_Model.php';
ActiveRecord\Config::initialize(function ($cfg) {
    $cfg->set_model_directory(ABSPATH . 'models');
    $cfg->set_connections(array('development' => 'mysql://' . DB_USER . ':' . DB_PASSWORD . '@' . DB_HOST . '/' . DB_NAME));
});
require_once dirname(__FILE__) . "/core/Loader.php";
require_once dirname(__FILE__) . "/core/Controller.php";