本文整理汇总了PHP中Doctrine_Manager::connection方法的典型用法代码示例。如果您正苦于以下问题:PHP Doctrine_Manager::connection方法的具体用法?PHP Doctrine_Manager::connection怎么用?PHP Doctrine_Manager::connection使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Doctrine_Manager
的用法示例。
在下文中一共展示了Doctrine_Manager::connection方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: indexDirectory
public function indexDirectory($dir)
{
if (!file_exists($dir)) {
throw new Doctrine_Search_Indexer_Exception('Unknown directory ' . $dir);
}
$it = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dir), RecursiveIteratorIterator::LEAVES_ONLY);
$files = array();
foreach ($it as $file) {
$name = $file->getPathName();
if (strpos($name, '.svn') === false) {
$files[] = $name;
}
}
$q = new Doctrine_Query();
$q->delete()->from('Doctrine_File f')->where('f.url LIKE ?', array($dir . '%'))->execute();
// clear the index
$q = new Doctrine_Query();
$q->delete()->from('Doctrine_File_Index i')->where('i.file_id = ?')->execute();
$conn = Doctrine_Manager::connection();
$coll = new Doctrine_Collection('Doctrine_File');
foreach ($files as $file) {
$coll[]->url = $file;
}
$coll->save();
}
示例2: execute
/**
* DOCUMENT ME
* @param mixed $arguments
* @param mixed $options
*/
protected function execute($arguments = array(), $options = array())
{
// initialize the database connection
$databaseManager = new sfDatabaseManager($this->configuration);
$connection = $databaseManager->getDatabase($options['connection'] ? $options['connection'] : null)->getConnection();
// PDO connection not so useful, get the doctrine one
$conn = Doctrine_Manager::connection();
if ($options['table'] === 'aPage') {
$q = Doctrine::getTable('aLuceneUpdate')->createQuery('u');
} else {
$q = Doctrine::getTable($options['table'])->createQuery('o')->where('o.lucene_dirty IS TRUE');
}
if ($options['limit'] !== false) {
$q->limit($options['limit'] + 0);
}
$updates = $q->execute();
$i = 0;
foreach ($updates as $update) {
$i++;
if ($options['table'] === 'aPage') {
$page = aPageTable::retrieveByIdWithSlots($update->page_id, $update->culture);
// Careful, pages die
if ($page) {
$page->updateLuceneIndex();
}
$update->delete();
} else {
// The actual object
$update->updateLuceneIndex();
$update->lucene_dirty = false;
$update->save();
}
}
}
示例3: execute
public function execute($arguments = array(), $options = array())
{
$databaseManager = new sfDatabaseManager(sfProjectConfiguration::getApplicationConfiguration('frontend', $options['env'], true));
$configuration = ProjectConfiguration::getApplicationConfiguration('frontend', $options['env'], true);
sfContext::createInstance($configuration);
$conn = Doctrine_Manager::connection();
// Récupération de toutes les notices.
$noeuds = $conn->execute("SELECT id, name FROM ei_data_set_structure;");
$this->log('Récupération des noeuds...OK');
// Création de la requête permettant
$this->log('Création de la requête de mise à jour...');
$requeteToUpdate = "UPDATE ei_data_set_structure SET slug = #{NEW_SLUG} WHERE id = #{NODE_ID};";
$requeteGlobale = array();
foreach ($noeuds->fetchAll() as $noeud) {
// Remplacement SLUG.
$tmpRequete = str_replace("#{NEW_SLUG}", $conn->quote(MyFunction::sluggifyForXML($noeud["name"])), $requeteToUpdate);
// Remplacement ID.
$tmpRequete = str_replace("#{NODE_ID}", $noeud["id"], $tmpRequete);
// Ajout dans la requête globale.
$requeteGlobale[] = $tmpRequete;
}
// Préparation de la requête.
$this->log("Préparation de la requête...");
$requete = implode(" ", $requeteGlobale);
try {
// Exécution de la requête.
$this->log("Exécution de la requête...");
$conn->execute($requete);
// Fin.
$this->log("Processus terminé avec succès.");
} catch (Exception $exc) {
$this->log($exc->getMessage());
}
}
示例4: copyModel
protected function copyModel($model)
{
$table = dmDb::table($model);
$tableName = $table->getTableName();
$vars = array();
$placeholders = array();
foreach ($table->getColumns() as $columnName => $column) {
$fields[] = $columnName;
$placeholders[] = ':' . $columnName;
}
$conn = Doctrine_Manager::connection();
$stmt = $conn->prepare(sprintf('INSERT INTO %s (%s) VALUES (%s)', $tableName, implode(',', $fields), implode(',', $placeholders)))->getStatement();
$conn->beginTransaction();
try {
foreach ($this->oldDb->getData($tableName) as $array) {
$values = array();
foreach ($fields as $field) {
$values[':' . $field] = isset($array[$field]) ? $array[$field] : '';
}
$stmt->execute($values);
}
} catch (Exception $e) {
dmDebug::show($model, $array);
throw $e;
}
$conn->commit();
}
示例5: execute
protected function execute($arguments = array(), $options = array())
{
$configuration = ProjectConfiguration::getApplicationConfiguration($arguments['application'], $options['env'], true);
$databaseManager = new sfDatabaseManager($configuration);
$databaseManager->initialize($configuration);
$db = Doctrine_Manager::connection();
//get person entities with all-caps names
$sql = 'SELECT e.id, e.name FROM entity e ' . 'WHERE e.name <> \'\' AND e.primary_ext = ? AND CAST(UPPER(e.name) AS BINARY) = CAST(e.name AS BINARY)';
$stmt = $db->execute($sql, array('Person'));
$names = $stmt->fetchAll(PDO::FETCH_ASSOC);
foreach ($names as $ary) {
$new = PersonTable::nameizePersonName($ary['name']);
if ($new != $ary['name']) {
$sql = 'UPDATE entity SET name = ? WHERE id = ?';
$stmt = $db->execute($sql, array($new, $ary['id']));
print "Changed Entity name " . $ary['name'] . " to " . $new . "\n";
}
}
//get aliases with all-caps names
$sql = 'SELECT a.id, a.name FROM alias a LEFT JOIN entity e ON (e.id = a.entity_id) ' . 'WHERE a.name <> \'\' AND a.is_primary = 1 AND e.primary_ext = ? AND ' . 'CAST(UPPER(a.name) AS BINARY) = CAST(a.name AS BINARY)';
$stmt = $db->execute($sql, array('Person'));
$names = $stmt->fetchAll(PDO::FETCH_ASSOC);
foreach ($names as $ary) {
$new = PersonTable::nameizePersonName($ary['name']);
if ($new != $ary['name']) {
$sql = 'UPDATE alias SET name = ? WHERE id = ?';
$stmt = $db->execute($sql, array($new, $ary['id']));
print "Changed Alias " . $ary['name'] . " to " . $new . "\n";
}
}
//DONE
LsCli::beep();
}
示例6: deleteProjectParams
public function deleteProjectParams($project_id, $project_ref, Doctrine_Connection $conn = null)
{
if ($conn == null) {
$conn = Doctrine_Manager::connection();
}
$conn->getTable('EiProjectParam')->createQuery('pp')->delete()->where('pp.project_id=? And pp.project_ref=?', array($project_id, $project_ref))->execute();
}
示例7: getDefaultInterventionWithScenarioVersion
public function getDefaultInterventionWithScenarioVersion(EiProjet $ei_project, EiVersion $ei_version, Doctrine_Connection $conn = null)
{
if ($conn == null) {
$conn = Doctrine_Manager::connection();
}
return $conn->fetchRow("select s.id as subject_id,s.name as subject_name,sp.ei_version_id as sp_ei_version_id, s.package_id,s.package_ref ,t.name as ticket_name from ei_subject s " . " inner join ei_ticket t on s.package_id=t.ticket_id and s.package_ref=t.ticket_ref " . " Left join ei_scenario_package sp on sp.package_id=t.ticket_id and sp.package_ref=t.ticket_ref and sp.ei_scenario_id=" . $ei_version->getEiScenarioId() . " inner join ei_user_default_package udp on t.ticket_id=udp.ticket_id and t.ticket_ref=udp.ticket_ref " . " where udp.user_id=" . $this->getUserId() . " and udp.user_ref=" . $this->getRefId() . " and s.project_id=" . $ei_project->getProjectId() . " and s.project_ref=" . $ei_project->getRefId());
}
示例8: createOrUpdateDistantParams
public static function createOrUpdateDistantParams(EiProjet $ei_project, EiProfil $ei_profile, KalFunction $kal_function, $data, Doctrine_Connection $conn = null)
{
if ($conn == null) {
$conn = Doctrine_Manager::connection();
}
try {
$conn->beginTransaction();
//Début de la transaction
//Appel du webservice
$result_update = MyFunction::loadResultOfWebServiceByPostJson(MyFunction::getPrefixPath(null) . "/serviceweb/project/parameter/createOrUpdate.json", array('project_id' => $ei_project->getProjectId(), 'project_ref' => $ei_project->getRefId(), 'profile_id' => $ei_profile->getProfileId(), 'profile_ref' => $ei_profile->getProfileRef(), 'function_id' => $kal_function->getFunctionId(), 'function_ref' => $kal_function->getFunctionRef(), 'data' => $data));
$array_result = json_decode(html_entity_decode($result_update), true);
//Récupération du paramètre pour traitement
if (count($array_result) == 0) {
return false;
}
if (array_key_exists("error", $array_result)) {
return false;
}
if (!$array_result[0]) {
return false;
}
//Rechargement d'un paramètre
self::reload($array_result, $conn);
$conn->commit();
return $array_result[0]['fp_id'];
} catch (Exception $e) {
$conn->rollback();
return false;
throw $e;
}
}
示例9: getDefaultInterventionWithScenarioVersion
public function getDefaultInterventionWithScenarioVersion(EiProjet $ei_project, EiVersion $ei_version, Doctrine_Connection $conn = null)
{
if ($conn == null) {
$conn = Doctrine_Manager::connection();
}
return $conn->fetchRow("select sp.*, s.id as subject_id ,s.name as subject_name from ei_scenario_package sp\n inner join ei_subject s on sp.package_id= s.package_id and sp.package_ref=s.package_ref\n where sp.ei_scenario_id= " . $ei_version->getEiScenarioId() . " and sp.ei_version_id=" . $ei_version->getId() . " and s.project_id=" . $ei_project->getProjectId() . " and s.project_ref=" . $ei_project->getRefId());
}
示例10: __construct
/**
* initialize the library scan by setting a new scan_id for the session
* @param source str: add a service name for each scanner
*/
public function __construct($service_name)
{
//Since this class services a batch script, stop Doctrine from leaving objects in memory
Doctrine_Manager::connection()->setAttribute(Doctrine_Core::ATTR_AUTO_FREE_QUERY_OBJECTS, true);
$this->service_name = $service_name;
$this->scan_id = Doctrine_Core::getTable('Scan')->addScan('playlist');
}
示例11: setup
/**
* Setup Doctrine
*
* @return void
*/
public function setup(Zend_Config $config)
{
if (is_array($config->path_config)) {
$this->setPathConfig($config->path_config);
} elseif ($config->path_config instanceof Zend_Config) {
$this->setPathConfig($config->path_config->toArray());
}
if ($charset = $config->get('charset')) {
$listener = new Zym_App_Resource_Doctrine_ConnectionListener();
$listener->setCharset($charset);
Doctrine_Manager::getInstance()->addListener($listener);
}
// determine if config is for a single-db or a multi-db site
$connections = $config->connection instanceof Zend_Config ? $config->connection->toArray() : (array) $config->connection;
// add connection(s) to doctrine
foreach ($connections as $name => $connection) {
if ($connection instanceof Zend_Config) {
$connection = $connection->toArray();
}
if (is_string($name)) {
Doctrine_Manager::connection($connection, $name);
} else {
Doctrine_Manager::connection($connection);
}
}
}
示例12: testTest2
public function testTest2()
{
$dbh = new Doctrine_Adapter_Mock('mysql');
$conn = Doctrine_Manager::connection($dbh);
$sql = $conn->export->exportClassesSql(array('Ticket_255_User'));
$this->assertEqual($sql[0], 'CREATE TABLE ticket_255__user (id BIGINT AUTO_INCREMENT, username VARCHAR(255), email_address VARCHAR(255), password VARCHAR(255), UNIQUE INDEX username_email_address_unqidx_idx (username, email_address), PRIMARY KEY(id)) ENGINE = INNODB');
}
示例13: insertTmpData
public function insertTmpData($projets, $project_id, $project_ref, Doctrine_Connection $conn = null)
{
if ($conn == null) {
$conn = Doctrine_Manager::connection();
}
//On vide la table temporaire avant toute opération
$conn->execute("TRUNCATE TABLE script_ei_notice");
$items = $projets->getElementsByTagName("ei_notices");
if ($items->length != 0) {
//ya t-il des éléments à traiter?
$ei_notices = $items->item(0)->getElementsByTagName("ei_notice");
$stmt = $conn->prepare("INSERT INTO script_ei_notice (notice_id, notice_ref,function_id,function_ref,name) " . "VALUES (:notice_id, :notice_ref,:function_id,:function_ref,:name) " . "ON DUPLICATE KEY UPDATE notice_id=notice_id,notice_ref=notice_ref ");
if ($ei_notices->length != 0) {
foreach ($ei_notices as $ei_notice) {
$notice_id = $ei_notice->getAttribute("notice_id");
$notice_ref = $ei_notice->getAttribute("notice_ref");
//recherche du profil en base
if ($notice_id != null && $notice_ref != null) {
$stmt->bindValue("notice_id", $notice_id);
$stmt->bindValue("notice_ref", $notice_ref);
$stmt->bindValue("function_id", $ei_notice->getElementsByTagName("function_id")->item(0)->nodeValue);
$stmt->bindValue("function_ref", $ei_notice->getElementsByTagName("function_ref")->item(0)->nodeValue);
$stmt->bindValue("name", $ei_notice->getElementsByTagName("name")->item(0)->nodeValue);
$stmt->execute(array());
}
}
}
}
return null;
}
示例14: countByEntityId
static function countByEntityId($id)
{
$db = Doctrine_Manager::connection();
$sql = 'SELECT COUNT(*) FROM os_entity_donor WHERE entity_id = ?';
$stmt = $db->execute($sql, array($id));
return $stmt->fetch(PDO::FETCH_COLUMN);
}
示例15: postDelete
public function postDelete(Doctrine_Event $event)
{
//Make sure all linked tables are clean
//RokGallery_Model_FileTags
$q = Doctrine_Query::create()->delete('RokGallery_Model_FileTags ft')->andWhere('ft.file_id NOT IN (SELECT f.id from RokGallery_Model_File f)');
$q->execute();
$q->free();
//RokGallery_Model_FileViews
$q = Doctrine_Query::create()->delete('RokGallery_Model_FileViews fv')->andWhere('fv.file_id NOT IN (SELECT f.id from RokGallery_Model_File f)');
$q->execute();
$q->free();
//RokGallery_Model_FileLoves
$q = Doctrine_Query::create()->delete('RokGallery_Model_FileLoves fl')->andWhere('fl.file_id NOT IN (SELECT f.id from RokGallery_Model_File f)');
$q->execute();
$q->free();
//rokgallery_files_index
$conn =& Doctrine_Manager::connection();
$dbh =& $conn->getDbh();
$stmt = $dbh->prepare('delete from ' . RokCommon_Doctrine::getPlatformInstance()->setTableName('rokgallery_files_index') . ' where id NOT IN (SELECT f.id from ' . RokGallery_Model_FileTable::getInstance()->getTableName() . ' f)');
$stmt->execute();
//RokGallery_Model_Slice
$q = Doctrine_Query::create()->delete('RokGallery_Model_Slice s')->andWhere('s.file_id NOT IN (SELECT f.id from RokGallery_Model_File f)');
$q->execute();
$q->free();
}