本文整理汇总了PHP中ConnectionManager类的典型用法代码示例。如果您正苦于以下问题:PHP ConnectionManager类的具体用法?PHP ConnectionManager怎么用?PHP ConnectionManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ConnectionManager类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: truncate
function truncate()
{
$ConnectionManager = new ConnectionManager();
$conn = $ConnectionManager->getConnection();
$stmt = $conn->prepare("TRUNCATE TABLE free_delivery_price");
$stmt->execute();
$ConnectionManager->closeConnection($stmt, $conn);
}
开发者ID:jackyFeng,项目名称:unisol,代码行数:8,代码来源:FdpManager.php
示例2: insertarTareaUsuario
public function insertarTareaUsuario($tareaUsuario)
{
$manager = new ConnectionManager();
$tareaUsuarioDAO = $manager->getTareaUsuarioDAO();
try {
return $tareaUsuarioDAO->insertar($tareaUsuario);
} finally {
$manager->close();
}
}
开发者ID:seirius,项目名称:AplicacionPHP_-Gestarea-,代码行数:10,代码来源:ServiceTareaUsuario.php
示例3: buscarTarea
public function buscarTarea($buscar)
{
$manager = new ConnectionManager();
$tareaDAO = $manager->getTareaDAO();
try {
$list = $tareaDAO->buscarTareas($buscar);
return $list;
} finally {
$manager->close();
}
}
开发者ID:seirius,项目名称:AplicacionPHP_-Gestarea-,代码行数:11,代码来源:ServiceTarea.php
示例4: getPostalCode
function getPostalCode($customer_id, $address_no)
{
$ConnectionManager = new ConnectionManager();
$conn = $ConnectionManager->getConnection();
$stmt = $conn->prepare("SELECT postal_code FROM address WHERE customer_id=? AND address_no=?");
$stmt->bind_param("si", $customer_id, $address_no);
$stmt->execute();
$stmt->bind_result($postal_code);
$postalcode = '';
while ($stmt->fetch()) {
$postalcode = $postal_code;
}
$ConnectionManager->closeConnection($stmt, $conn);
return $postalcode;
}
开发者ID:jackyFeng,项目名称:unisol,代码行数:15,代码来源:AddressManager.php
示例5: run
/**
* Run
*
* @return void
*/
public function run()
{
$null = null;
$this->db = ConnectionManager::getDataSource($this->connection);
$this->db->cacheSources = false;
$this->db->begin($null);
if (!isset($this->args[0]) || !in_array($this->args[0], array('insert', 'remove'))) {
$this->out(__d('SoftDelete', 'Invalid option'));
return $this->_displayHelp(null);
}
if (!isset($this->args[1])) {
$this->out(__d('SoftDelete', 'You missed field name.'));
return $this->_displayHelp(null);
}
try {
$this->_run($this->args[0], $this->args[1]);
$this->_clearCache();
} catch (Exception $e) {
$this->db->rollback($null);
throw $e;
}
$this->out(__d('SoftDelete', 'All tables are updated.'));
$this->out('');
return $this->db->commit($null);
}
开发者ID:radig,项目名称:SoftDelete,代码行数:30,代码来源:SoftDeleteShell.php
示例6: getConnection
/**
* Get current connection
*
* @return \Doctrine\DBAL\Driver\Connection|\Doctrine\DBAL\Connection|\Blast\Orm\Connection
*/
public function getConnection()
{
if (null === $this->connection) {
$this->connection = ConnectionManager::getInstance()->get();
}
return $this->connection;
}
开发者ID:phpthinktank,项目名称:blast-orm,代码行数:12,代码来源:ConnectionAwareTrait.php
示例7: load
public function load()
{
if (Cache::read('qe.dbconfig_' . hash("md5", "qe_dbconfig"), QEResp::QUICK_EMAILER_CACHE)) {
return true;
}
if (Configure::check('qe.dbconfig')) {
if (!file_exists(APP . 'Config' . DS . 'database.php')) {
return QEResp::RESPOND(QEResp::ERROR, QuickEmailerErrorDefinitions::NO_DATABASE_CONFIGURED());
}
try {
$datasource = ConnectionManager::getDataSource(Configure::read('qe.dbconfig'));
if ($datasource->connected) {
$this->CheckTables($datasource);
Cache::write('qe.dbconfig_' . hash("md5", "qe_dbconfig"), true, QEResp::QUICK_EMAILER_CACHE);
return true;
}
return QEResp::RESPOND(QEResp::ERROR, QuickEmailerErrorDefinitions::NO_DATABASE_CONFIGURED());
} catch (Exception $e) {
$excep_message = QuickEmailerResponseHandler::AddExceptionInfo(QuickEmailerErrorDefinitions::NO_DATABASE_CONFIGURED(), $e);
//TODO: Log errors
return QEResp::RESPOND(QEResp::ERROR, $excep_message);
}
} else {
return QEResp::RESPOND(QEResp::ERROR, QuickEmailerErrorDefinitions::NO_DATABASE_CONFIGURED());
}
}
开发者ID:walisc,项目名称:CakephpQuickEmailer,代码行数:26,代码来源:DALComponent.php
示例8: delete
/**
* Override Model::delete, because it would block deleting when
* useTable = false and no records exists
*
* @param <type> $id
* @param <type> $cascade
* @return <type>
*/
function delete($id = null, $cascade = true)
{
if (!empty($id)) {
$this->id = $id;
}
$id = $this->id;
if ($this->beforeDelete($cascade)) {
$db =& ConnectionManager::getDataSource($this->useDbConfig);
if (!$this->Behaviors->trigger($this, 'beforeDelete', array($cascade), array('break' => true, 'breakOn' => false))) {
return false;
}
$this->_deleteDependent($id, $cascade);
$this->_deleteLinks($id);
$this->id = $id;
if (!empty($this->belongsTo)) {
$keys = $this->find('first', array('fields' => $this->__collectForeignKeys()));
}
if ($db->delete($this)) {
if (!empty($this->belongsTo)) {
$this->updateCounterCache($keys[$this->alias]);
}
$this->Behaviors->trigger($this, 'afterDelete');
$this->afterDelete();
$this->_clearCache();
$this->id = false;
$this->__exists = null;
return true;
}
}
return false;
}
开发者ID:robwilkerson,项目名称:CakePHP-Mailchimp-datasource,代码行数:39,代码来源:MailchimpSubscriber.php
示例9: __construct
/**
* Constructor.
*
* @access public
*/
public function __construct()
{
parent::__construct();
// Setup Search Engine Connection
$this->db = ConnectionManager::connectToIndex();
$_SESSION['no_store'] = true;
}
开发者ID:bharatm,项目名称:NDL-VuFind,代码行数:12,代码来源:AJAX_HierarchyTree.php
示例10: execute
public function execute()
{
if (empty($this->connection)) {
$this->connection = $this->DbConfig->getConfig();
}
$this->out('Generating Proxy classes');
$dm = ConnectionManager::getDataSource($this->connection)->getDocumentManager();
$metadatas = $dm->getMetadataFactory()->getAllMetadata();
$metadatas = MetadataFilter::filter($metadatas, isset($this->params['filter']) ? $this->params['filter'] : null);
// Process destination directory
$destPath = empty($this->params['destPath']) ? $dm->getConfiguration()->getHydratorDir() : $this->params['destPath'];
if (!is_dir($destPath)) {
mkdir($destPath, 0777, true);
}
$destPath = realpath($destPath);
if (!file_exists($destPath)) {
throw new \InvalidArgumentException(sprintf("Proxies destination directory '<info>%s</info>' does not exist.", $destPath));
} else {
if (!is_writable($destPath)) {
throw new \InvalidArgumentException(sprintf("Proxies destination directory '<info>%s</info>' does not have write permissions.", $destPath));
}
}
if (count($metadatas)) {
foreach ($metadatas as $metadata) {
$this->out(sprintf('Processing document "<info>%s</info>"', $metadata->name));
}
// Generating Proxies
$dm->getHydratorFactory()->generateHydratorClasses($metadatas, $destPath);
// Outputting information message
$this->out(sprintf('Hydrator classes generated to "<info>%s</info>"', $destPath));
} else {
$this->out('No Metadata Classes to process.');
}
}
开发者ID:beyondkeysystem,项目名称:MongoCake,代码行数:34,代码来源:HydratorsTask.php
示例11: configure
static function configure()
{
if (empty($_COOKIE['selenium'])) {
return;
}
$cookie = $_COOKIE['selenium'];
App::import('Model', 'ConnectionManager', false);
ClassRegistry::flush();
Configure::write('Cache.disable', true);
$testDbAvailable = in_array('test', array_keys(ConnectionManager::enumConnectionObjects()));
$_prefix = null;
if ($testDbAvailable) {
// Try for test DB
restore_error_handler();
@($db =& ConnectionManager::getDataSource('test'));
set_error_handler('simpleTestErrorHandler');
$testDbAvailable = $db->isConnected();
}
// Try for default DB
if (!$testDbAvailable) {
$db =& ConnectionManager::getDataSource('default');
}
$_prefix = $db->config['prefix'];
$db->config['prefix'] = $cookie . '_';
ConnectionManager::create('test_suite', $db->config);
$db->config['prefix'] = $_prefix;
// Get db connection
$db =& ConnectionManager::getDataSource('test_suite');
$db->cacheSources = false;
ClassRegistry::config(array('ds' => 'test_suite'));
}
开发者ID:rodrigorm,项目名称:selenium-helper,代码行数:31,代码来源:database.php
示例12: main
/**
* Truncates all tables and loads fixtures into db
*
* @return void
* @access public
*/
function main()
{
if (!empty($this->args)) {
if ($this->args[0] == 'chmod') {
return $this->chmod();
}
$fixtures = $this->args;
foreach ($fixtures as $i => $fixture) {
$fixtures[$i] = APP . 'tests/fixtures/' . $fixture . '_fixture.php';
}
} else {
App::import('Folder');
$Folder = new Folder(APP . 'tests/fixtures');
$fixtures = $Folder->findRecursive('.+_fixture\\.php');
}
$db = ConnectionManager::getDataSource('default');
$records = 0;
foreach ($fixtures as $path) {
require_once $path;
$name = str_replace('_fixture.php', '', basename($path));
$class = Inflector::camelize($name) . 'Fixture';
$Fixture =& new $class($db);
$this->out('-> Truncating table "' . $Fixture->table . '"');
$db->truncate($Fixture->table);
$Fixture->insert($db);
$fixtureRecords = count($Fixture->records);
$records += $fixtureRecords;
$this->out('-> Inserting ' . $fixtureRecords . ' records for "' . $Fixture->table . '"');
}
$this->out(sprintf('-> Done inserting %d records for %d tables', $records, count($fixtures)));
}
开发者ID:stripthis,项目名称:donate,代码行数:37,代码来源:fixtures.php
示例13: truncateModel
public function truncateModel($name)
{
$model = ClassRegistry::init(array('class' => $name, 'ds' => 'test'));
$table = $model->table;
$db = ConnectionManager::getDataSource('test_suite');
$db->truncate($table);
}
开发者ID:nojimage,项目名称:Bdd,代码行数:7,代码来源:FeatureContext.php
示例14: setUp
public function setUp()
{
$this->Model = ClassRegistry::init('Country');
$this->db = ConnectionManager::getDataSource('test');
$this->skipIf(!$this->db instanceof Mysql, 'The subquery test is only compatible with Mysql.');
parent::setUp();
}
开发者ID:Jony01,项目名称:LLD,代码行数:7,代码来源:SubqueryTest.php
示例15: health
public function health()
{
App::Import('ConnectionManager');
$MPSearch = ConnectionManager::getDataSource('MPSearch');
$elasticSearch = $MPSearch->API->cluster()->health();
$this->set(array('elasticSearch' => $elasticSearch, '_serialize' => array('elasticSearch')));
}
开发者ID:slachiewicz,项目名称:_mojePanstwo-API-Server,代码行数:7,代码来源:SystemController.php
示例16: getAPISource
/**
* @return mpAPISource
*/
private function getAPISource()
{
if (!self::$apiSource) {
self::$apiSource = ConnectionManager::getDataSource('mpAPI');
}
return self::$apiSource;
}
开发者ID:Marcin11,项目名称:_mojePanstwo-Portal,代码行数:10,代码来源:AdminModel.php
示例17: main
function main()
{
if ($this->args && $this->args[0] == '?') {
return $this->out('Usage: ./cake fixturize <table> [-force] [-reindex]');
}
$options = array('force' => false, 'reindex' => false, 'all' => false);
foreach ($this->params as $key => $val) {
foreach ($options as $name => $option) {
if (isset($this->params[$name]) || isset($this->params['-' . $name]) || isset($this->params[$name[0]])) {
$options[$name] = true;
}
}
}
if ($options['all']) {
$db = ConnectionManager::getDataSource('default');
$this->args = $db->listSources();
}
if (empty($this->args)) {
return $this->err('Usage: ./cake fixturize <table>');
}
foreach ($this->args as $table) {
$name = Inflector::classify($table);
$Model = new AppModel(array('name' => $name, 'table' => $table));
$file = sprintf('%stests/fixtures/%s_fixture.php', APP, Inflector::underscore($name));
$File = new File($file);
if ($File->exists() && !$options['force']) {
$this->err(sprintf('File %s already exists, use --force option.', $file));
continue;
}
$records = $Model->find('all');
$out = array();
$out[] = '<?php';
$out[] = '';
$out[] = sprintf('class %sFixture extends CakeTestFixture {', $name);
$out[] = sprintf(' var $name = \'%s\';', $name);
$out[] = ' var $records = array(';
foreach ($records as $record) {
$out[] = ' array(';
if ($options['reindex']) {
foreach (array('old_id', 'vendor_id') as $field) {
if ($Model->hasField($field)) {
$record[$name][$field] = $record[$name]['id'];
break;
}
}
$record[$name]['id'] = String::uuid();
}
foreach ($record[$name] as $field => $val) {
$out[] = sprintf(' \'%s\' => \'%s\',', addcslashes($field, "'"), addcslashes($val, "'"));
}
$out[] = ' ),';
}
$out[] = ' );';
$out[] = '}';
$out[] = '';
$out[] = '?>';
$File->write(join("\n", $out));
$this->out(sprintf('-> Create %sFixture with %d records (%d bytes) in "%s"', $name, count($records), $File->size(), $file));
}
}
开发者ID:riotera,项目名称:debuggable-scraps,代码行数:60,代码来源:fixturize.php
示例18: Migrations
/**
* Constructor - checks dependencies and loads the connection
*
* @param string $sConnecion The connection from database.php to use. Deafaults to "default"
* @return void
*/
function Migrations($sConnection = 'default')
{
if (class_exists('Spyc')) {
$this->bSpycReady = true;
}
$this->oDb =& ConnectionManager::getDataSource($sConnection);
}
开发者ID:gildonei,项目名称:candycane,代码行数:13,代码来源:migrations.php
示例19: __dbStructure
private function __dbStructure($options = array())
{
if (is_string($options) || isset($options['useSchema'])) {
$version = new MigrationVersion();
$versions = $version->getMapping('rcms');
if (!isset($options['targetVersion'])) {
$options['targetVersion'] = array_pop($versions);
}
if (!isset($options['initVersion'])) {
$options['initVersion'] = array_pop($versions);
}
$version->run(array('version' => array($options['initVersion'], $options['targetVersion']), 'type' => 'rcms', 'direction' => 'up'));
} else {
if (isset($options['fileName'])) {
$db = ConnectionManager::getDataSource('default');
$statements = file_get_contents(CONFIGS . 'sql/' . $options['fileName']);
/* Replacing the block comments */
$statements = preg_replace('/\\/\\*[^\\*]*\\*\\//', '', $statements);
/* Replacing the line comments */
$statements = preg_replace('/.*\\-\\-.*\\n/', '', $statements);
$statements = explode(';', $statements);
foreach ($statements as $statement) {
if (trim($statement) != '') {
$db->query($statement);
}
}
return true;
}
}
}
开发者ID:jcicero,项目名称:Comitiva,代码行数:30,代码来源:installer_controller.php
示例20: status
/**
* Displays information about the system configuration.
*/
public function status()
{
$this->set('core', array('debug' => Configure::read('debug'), 'database' => @ConnectionManager::getDataSource('default')));
$uploads_path = Configure::read('uploads.path');
$this->set('uploads', array('url' => Configure::read('uploads.url'), 'path' => $uploads_path, 'exists' => is_dir($uploads_path), 'writable' => is_writable($uploads_path), 'executable' => is_executable($uploads_path)));
$this->set('dependencies', array('Ghostscript' => is_executable('ghostscript'), 'Imagemagick' => class_exists('Imagick')));
}
开发者ID:ndreynolds,项目名称:arcs,代码行数:10,代码来源:AdminController.php
注:本文中的ConnectionManager类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论