/** * importSchema * * A method to import a Schema and translate it into a Doctrine_Record object * * @param string $schema The file containing the XML schema * @param string $format Format of the schema file * @param string $directory The directory where the Doctrine_Record class will be written * @param array $models Optional array of models to import * * @return void */ public function importSchema($schema, $format = 'yml', $directory = null, $models = array()) { $manager = Doctrine_Manager::getInstance(); $modelLoading = $manager->getAttribute(Doctrine_Core::ATTR_MODEL_LOADING); $zendStyles = array(ZFDoctrine_Core::MODEL_LOADING_ZEND, ZFDoctrine_Core::MODEL_LOADING_ZEND_SINGLE_LIBRARY, ZFDoctrine_Core::MODEL_LOADING_ZEND_MODULE_LIBRARY); if (!in_array($modelLoading, $zendStyles)) { throw new ZFDoctrine_DoctrineException("Can't use ZFDoctrine_Schema with Doctrine_Core::ATTR_MODEL_LOADING not equal to 4 (Zend)."); } $schema = (array) $schema; $records = $this->buildSchema($schema, $format); if (count($records) == 0) { throw new Doctrine_Import_Exception(sprintf('No records found for schema "' . $format . '" found in ' . implode(", ", $schema))); } $builder = $this->_getBuilder(); $builder->setOptions($this->getOptions()); $this->_initModules(); foreach ($records as $name => $definition) { if (!empty($models) && !in_array($definition['className'], $models)) { continue; } $this->_buildRecord($builder, $definition); } if ($this->_listener) { $this->_listener->notifyImportCompleted(); } }
/** * * @return Doctrine_Schema * @access public */ public function read() { $dataDict = Doctrine_Manager::getInstance()->getCurrentConnection()->getDataDict(); $schema = new Doctrine_Schema(); /* @todo FIXME i am incomplete*/ $db = new Doctrine_Schema_Database(); $schema->addDatabase($db); $dbName = 'XXtest'; // @todo FIXME where should we get $this->conn->set("name", $dbName); $tableNames = $dataDict->listTables(); foreach ($tableNames as $tableName) { $table = new Doctrine_Schema_Table(); $table->set("name", $tableName); $tableColumns = $dataDict->listTableColumns($tableName); foreach ($tableColumns as $tableColumn) { $table->addColumn($tableColumn); } $this->conn->addTable($table); if ($fks = $dataDict->listTableConstraints($tableName)) { foreach ($fks as $fk) { $relation = new Doctrine_Schema_Relation(); $relation->setRelationBetween($fk['referencingColumn'], $fk['referencedTable'], $fk['referencedColumn']); $table->setRelation($relation); } } } return $schema; }
public function testTest() { Doctrine_Manager::getInstance()->setAttribute(Doctrine_Core::ATTR_VALIDATE, Doctrine_Core::VALIDATE_ALL); $user = new Ticket_DC187_User(); $user->username = '******'; $user->email = '*****@*****.**'; $user->password = '******'; $user->save(); $user->delete(); try { $user = new Ticket_DC187_User(); $user->username = '******'; $user->email = '*****@*****.**'; $user->password = '******'; $user->save(); $this->pass(); } catch (Exception $e) { $this->fail($e->getMessage()); } try { $user = new Ticket_DC187_User(); $user->username = '******'; $user->email = '*****@*****.**'; $user->password = '******'; $user->save(); $this->fail(); } catch (Exception $e) { $this->pass(); } Doctrine_Manager::getInstance()->setAttribute(Doctrine_Core::ATTR_VALIDATE, Doctrine_Core::VALIDATE_NONE); }
public function reset_() { $facility_code = $this->session->userdata('facility_id'); $reset_facility_transaction_table = Doctrine_Manager::getInstance()->getCurrentConnection(); $reset_facility_transaction_table->execute("DELETE FROM `facility_transaction_table` WHERE facility_code={$facility_code}; "); $reset_facility_stock_table = Doctrine_Manager::getInstance()->getCurrentConnection(); $reset_facility_stock_table->execute("DELETE FROM `facility_stocks` WHERE facility_code={$facility_code}"); $reset_facility_issues_table = Doctrine_Manager::getInstance()->getCurrentConnection(); $reset_facility_issues_table->execute("DELETE FROM `facility_issues` WHERE facility_code={$facility_code};"); $reset_facility_issues_table = Doctrine_Manager::getInstance()->getCurrentConnection(); $reset_facility_issues_table->execute("DELETE FROM `redistribution_data` WHERE source_facility_code={$facility_code} or receive_facility_code={$facility_code};"); $facility_order_details_table = Doctrine_Manager::getInstance()->getCurrentConnection()->fetchAll("select id from `facility_orders` WHERE facility_code={$facility_code};"); foreach ($facility_order_details_table as $key => $value) { $reset_facility_order_table = Doctrine_Manager::getInstance()->getCurrentConnection(); $reset_facility_order_table->execute("DELETE FROM `facility_order_details` WHERE order_number_id={$value['id']}; "); } $reset_facility_order_table = Doctrine_Manager::getInstance()->getCurrentConnection(); $reset_facility_order_table->execute("DELETE FROM `facility_orders` WHERE facility_code={$facility_code}; "); $reset_facility_historical_stock_table = Doctrine_Manager::getInstance()->getCurrentConnection(); $reset_facility_historical_stock_table->execute("DELETE FROM `facility_monthly_stock` WHERE facility_code={$facility_code}; "); $reset_facility_update_stock_first_temp = Doctrine_Manager::getInstance()->getCurrentConnection(); $reset_facility_update_stock_first_temp->execute("DELETE FROM `facility_stocks_temp` WHERE facility_code={$facility_code}; "); $this->session->set_flashdata('system_success_message', 'Facility Stock Details Have Been Reset'); redirect('home'); }
public function postUp() { //Se crea la primera encuesta para el sitio $conn = Doctrine_Manager::getInstance()->connection(); $query = 'INSERT INTO encuesta(id,nombre, created_at, updated_at) values(1,"Visita Oficina",now(), now())'; $conn->execute($query); }
public function set_point($facility_code, $service_point) { $update_points = Doctrine_Manager::getInstance()->getCurrentConnection(); $sql = "INSERT INTO `selected_service_points`(`facility_code`,`service_point_id`,`status`) VALUES ('{$facility_code}','{$service_point}','1')"; $update_points->execute($sql); echo true; }
public function preExecute() { if (isset($_SESSION['username'])) { $this->redirect("http://ausw_travelagency_app.com/home/index"); } $this->conn = Doctrine_Manager::getInstance()->connection(); }
/** * Build SQL Tables * * @return type null */ protected function buildDataTables() { try { $sqlPaths = $this->installData['dbscript_path']; if (!is_array($sqlPaths)) { $sqlPaths = array($sqlPaths); } $sqlString = ''; foreach ($sqlPaths as $sqlPath) { $sqlString = $sqlString . file_get_contents(sfConfig::get('sf_plugins_dir') . DIRECTORY_SEPARATOR . $this->installData['plugin_name'] . DIRECTORY_SEPARATOR . $sqlPath); } if (!empty($sqlString)) { $q = Doctrine_Manager::getInstance()->getCurrentConnection(); $patterns = array(); $patterns[0] = '/DELIMITER \\$\\$/'; $patterns[1] = '/DELIMITER ;/'; $patterns[2] = '/\\$\\$/'; $new_sql_string = preg_replace($patterns, '', $sqlString); $result = $q->exec($new_sql_string); foreach ($sqlPaths as $value) { $this->log('Execute ' . $value . " file"); } } } catch (Exception $e) { throw new sfCommandException($e->getMessage()); } }
public function setTableDefinition() { $conn = $this->getTable()->getConnection(); if (!$conn) { $conn = Doctrine_Manager::getInstance()->getConnection(IcingaDoctrineDatabase::CONNECTION_ICINGA); } $prefix = $conn->getPrefix(); $this->setTableName($prefix . 'servicechecks'); $this->hasColumn('servicecheck_id', 'integer', 4, array('type' => 'integer', 'length' => 4, 'fixed' => false, 'unsigned' => false, 'primary' => true, 'autoincrement' => true)); $this->hasColumn('instance_id', 'integer', 2, array('type' => 'integer', 'length' => 2, 'fixed' => false, 'unsigned' => false, 'primary' => false, 'default' => '0', 'notnull' => true, 'autoincrement' => false)); $this->hasColumn('service_object_id', 'integer', 4, array('type' => 'integer', 'length' => 4, 'fixed' => false, 'unsigned' => false, 'primary' => false, 'default' => '0', 'notnull' => true, 'autoincrement' => false)); $this->hasColumn('check_type', 'integer', 2, array('type' => 'integer', 'length' => 2, 'fixed' => false, 'unsigned' => false, 'primary' => false, 'default' => '0', 'notnull' => true, 'autoincrement' => false)); $this->hasColumn('current_check_attempt', 'integer', 2, array('type' => 'integer', 'length' => 2, 'fixed' => false, 'unsigned' => false, 'primary' => false, 'default' => '0', 'notnull' => true, 'autoincrement' => false)); $this->hasColumn('max_check_attempts', 'integer', 2, array('type' => 'integer', 'length' => 2, 'fixed' => false, 'unsigned' => false, 'primary' => false, 'default' => '0', 'notnull' => true, 'autoincrement' => false)); $this->hasColumn('state', 'integer', 2, array('type' => 'integer', 'length' => 2, 'fixed' => false, 'unsigned' => false, 'primary' => false, 'default' => '0', 'notnull' => true, 'autoincrement' => false)); $this->hasColumn('state_type', 'integer', 2, array('type' => 'integer', 'length' => 2, 'fixed' => false, 'unsigned' => false, 'primary' => false, 'default' => '0', 'notnull' => true, 'autoincrement' => false)); $this->hasColumn('start_time', 'timestamp', null, array('type' => 'timestamp', 'fixed' => false, 'unsigned' => false, 'primary' => false, 'default' => '0000-00-00 00:00:00', 'notnull' => true, 'autoincrement' => false)); $this->hasColumn('start_time_usec', 'integer', 4, array('type' => 'integer', 'length' => 4, 'fixed' => false, 'unsigned' => false, 'primary' => false, 'default' => '0', 'notnull' => true, 'autoincrement' => false)); $this->hasColumn('end_time', 'timestamp', null, array('type' => 'timestamp', 'fixed' => false, 'unsigned' => false, 'primary' => false, 'default' => '0000-00-00 00:00:00', 'notnull' => true, 'autoincrement' => false)); $this->hasColumn('end_time_usec', 'integer', 4, array('type' => 'integer', 'length' => 4, 'fixed' => false, 'unsigned' => false, 'primary' => false, 'default' => '0', 'notnull' => true, 'autoincrement' => false)); $this->hasColumn('command_object_id', 'integer', 4, array('type' => 'integer', 'length' => 4, 'fixed' => false, 'unsigned' => false, 'primary' => false, 'default' => '0', 'notnull' => true, 'autoincrement' => false)); $this->hasColumn('command_args', 'string', 255, array('type' => 'string', 'length' => 255, 'fixed' => false, 'unsigned' => false, 'primary' => false, 'default' => '', 'notnull' => true, 'autoincrement' => false)); $this->hasColumn('command_line', 'string', 1024, array('type' => 'string', 'length' => 1024, 'fixed' => false, 'unsigned' => false, 'primary' => false, 'default' => '', 'notnull' => true, 'autoincrement' => false)); $this->hasColumn('timeout', 'integer', 2, array('type' => 'integer', 'length' => 2, 'fixed' => false, 'unsigned' => false, 'primary' => false, 'default' => '0', 'notnull' => true, 'autoincrement' => false)); $this->hasColumn('early_timeout', 'integer', 2, array('type' => 'integer', 'length' => 2, 'fixed' => false, 'unsigned' => false, 'primary' => false, 'default' => '0', 'notnull' => true, 'autoincrement' => false)); $this->hasColumn('execution_time', 'float', null, array('type' => 'float', 'fixed' => false, 'unsigned' => false, 'primary' => false, 'default' => '0', 'notnull' => true, 'autoincrement' => false)); $this->hasColumn('latency', 'float', null, array('type' => 'float', 'fixed' => false, 'unsigned' => false, 'primary' => false, 'default' => '0', 'notnull' => true, 'autoincrement' => false)); $this->hasColumn('return_code', 'integer', 2, array('type' => 'integer', 'length' => 2, 'fixed' => false, 'unsigned' => false, 'primary' => false, 'default' => '0', 'notnull' => true, 'autoincrement' => false)); $this->hasColumn('output', 'string', 255, array('type' => 'string', 'length' => 255, 'fixed' => false, 'unsigned' => false, 'primary' => false, 'default' => '', 'notnull' => true, 'autoincrement' => false)); $this->hasColumn('long_output', 'string', null, array('type' => 'string', 'fixed' => false, 'unsigned' => false, 'primary' => false, 'notnull' => true, 'autoincrement' => false)); $this->hasColumn('perfdata', 'string', null, array('type' => 'string', 'fixed' => false, 'unsigned' => false, 'primary' => false, 'notnull' => true, 'autoincrement' => false)); }
public function preUp() { parent::preUp(); // get a mapping of current ids for later use $conn = Doctrine_Manager::getInstance()->connection(); $episodes = $conn->execute('SELECT * FROM project_episodes')->fetchAll(); $mapping = array(); $afterDelete = array(); foreach ($episodes as $episode) { if (empty($mapping[$episode['project_id'] . '-' . $episode['number'] . '-' . $episode['version']])) { $mapping[$episode['project_id'] . '-' . $episode['number'] . '-' . $episode['version']] = $episode['id']; } else { $afterDelete[] = $episode['id']; } } foreach ($episodes as $episode) { $rel = new Projects_Model_EpisodeRelease(); $rel->vcodec = $episode['vcodec']; $rel->acodec = $episode['acodec']; $rel->container = $episode['container']; $rel->crc = $episode['crc']; $rel->released_at = $episode['released_at']; $rel->updated_by = $episode['updated_by']; $rel->created_at = $episode['created_at']; $rel->updated_at = $episode['updated_at']; $rel->episode_id = $mapping[$episode['project_id'] . '-' . $episode['number'] . '-' . $episode['version']]; $rel->save(); $rel->free(); } Doctrine_Query::create()->delete('Projects_Model_Episode')->whereIn('id', $afterDelete)->execute(); }
public function setUp() { $manager = Doctrine_Manager::getInstance(); $manager->registerConnectionDriver('test', 'Doctrine_Connection_Test'); $this->_conn = $manager->openConnection('test://*****:*****@localhost/dbname', false); $this->_dbh = $this->_conn->getDbh(); }
/** * @remotable * @formHandler */ public function saveForm($a) { //capture the param 'staffList' and loop through the array of IDs //echo $a['staffList']; if (strlen($a['staffList'] > 0)) { $orgID = $this->getOrgID(); $staff = $a['staffList']; $q = Doctrine_Manager::getInstance()->getCurrentConnection(); $query = "UPDATE contact_value SET \r\n\t\t\t\t\t\t\tisRedFlag = CASE \r\n\t\t\t\t\t\t\t\t\tWhen id in ({$staff}) \r\n\t\t\t\t\t\t\t\t\t\t THEN 1 \r\n\t\t\t\t\t\t\t\t\tElse 0\r\n\t\t\t\t\t\t\t\t\tend\r\n\t\t\t\t\t\t WHERE orgID={$orgID}"; $result = $q->execute($query); //$q = Doctrine_Manager::getInstance()->getCurrentConnection(); //$query = "UPDATE `contact_value` SET `isRedFlag` = '0' WHERE `orgID` = $orgID;"; //$result = $q->execute($query); //$query = "UPDATE `contact_value` SET `isRedFlag` = '1' WHERE (`contact_value`.`ID` IN ($staff) AND `orgID` = $orgID);"; //$result = $q->execute($query); //$q = Doctrine_Query::create() //->update('ContactValue') //->set('isRedFlag', 0) //->where('ID NOT IN (' . $a['staffList'] . ')') //->andWhere('orgID = '.$orgID.''); //$q->execute(); //echo $q->getSqlQuery(); } return parent::saveForm($a); }
public function findOneByUser($nid, $uid) { $q = Doctrine_Manager::getInstance()->getConnectionForComponent('Quiz')->createQuery(); $q->from('Quiz')->where('nid = ? AND uid = ?'); $result = $q->execute(array($nid, $uid), Doctrine::HYDRATE_RECORD); return count($result) > 0 ? $result[0] : null; }
protected function execute($arguments = array(), $options = array()) { $databaseManager = new sfDatabaseManager($this->configuration); $conn = Doctrine_Manager::getInstance()->getCurrentConnection(); $conn->beginTransaction(); try { foreach ($arguments['filename'] as $filename) { $this->logSection('import', 'filename: ' . $filename); if ($fh = fopen($filename, 'r')) { $op2Member = new Op2Member(); $op2Member->number = $this->getMemberIdFromFileName($filename); $this->parse($fh, $conn, $op2Member); fclose($fh); } } $jobs = Doctrine::getTable('ImportDiaryJob')->findAll(); foreach ($jobs as $job) { $file = $job->File; $op2Member = $job->Op2Member; $this->logSection('import', 'started importing diaries of ' . $op2Member->Member->name); $this->logSection('import', 'filename: ' . $file->name); $op2Member->number = $this->getMemberIdFromFileName($file->original_filename); try { $this->parse($file, $conn, $op2Member); } catch (Exception $e) { } $job->delete(); } $conn->commit(); } catch (Exception $e) { $conn->rollBack(); throw $e; } }
protected function execute($arguments = array(), $options = array()) { $databaseManager = new sfDatabaseManager($this->configuration); if (!$options['skip-build']) { $buildModel = new sfDoctrineBuildModelTask($this->dispatcher, $this->formatter); $buildModel->setCommandApplication($this->commandApplication); $buildModel->setConfiguration($this->configuration); $buildModel->run(); } $connections = array(); $models = $arguments['models']; foreach ($models as $key => $model) { $model = trim($model); $conn = Doctrine_Core::getTable($model)->getConnection(); $connections[$conn->getName()][] = $model; } foreach ($connections as $name => $models) { $this->logSection('doctrine', 'dropping model tables for connection "' . $name . '"'); $conn = Doctrine_Manager::getInstance()->getConnection($name); $models = $conn->unitOfWork->buildFlushTree($models); $models = array_reverse($models); foreach ($models as $model) { $tableName = Doctrine_Core::getTable($model)->getOption('tableName'); $this->logSection('doctrine', 'dropping table "' . $tableName . '"'); try { $conn->export->dropTable($tableName); } catch (Exception $e) { $this->logSection('doctrine', 'dropping table failed: ' . $e->getMessage()); } } $this->logSection('doctrine', 'recreating tables for models'); Doctrine_Core::createTablesFromArray($models); } }
public function delete($id) { $qa_generic = sfConfig::get("app_table_qa_generic"); $query = Doctrine_Manager::getInstance()->getCurrentConnection(); $sql = "DELETE FROM " . $qa_generic . ".project_to_product WHERE id = " . $id; $result = $query->execute($sql); }
public function profiler_start() { self::$profiler = new Doctrine_Connection_Profiler(); foreach (Doctrine_Manager::getInstance()->getConnections() as $conn) { $conn->setListener(self::$profiler); } }
/** * 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); } } }
public function down() { $this->removeColumn('ficha', 'metaficha_opciones'); $conn = Doctrine_Manager::getInstance()->connection(); $query = 'ALTER TABLE ficha ADD metaficha_categoria varchar(16)'; $results = $conn->execute($query); }
public function testTest() { $dbh = new Doctrine_Adapter_Mock('mysql'); $conn = Doctrine_Manager::getInstance()->connection($dbh, 'mysql', false); $sql = $conn->export->exportSortedClassesSql(array('Ticket_DC101_User', 'Ticket_DC101_Profile'), false); $this->assertEqual($sql[2], 'ALTER TABLE ticket__d_c101__profile ADD CONSTRAINT user_id_fk FOREIGN KEY (user_id) REFERENCES ticket__d_c101__user(id)'); }
/** * @return PDOStatement */ public static function pdo($query, array $values = array(), Doctrine_Connection $conn = null) { $conn = null === $conn ? Doctrine_Manager::getInstance()->getCurrentConnection() : $conn; $stmt = $conn->prepare($query)->getStatement(); $stmt->execute($values); return $stmt; }
public function __construct($table = null, $isNewEntry = false) { $dbalmm = AgaviContext::getInstance()->getModel("Api_DBALMetaManagerModel", "Api"); $db = $dbalmm->getCurrentDB(); Doctrine_Manager::getInstance()->bindComponent($this->get, $db); parent::__construct($table, $isNewEntry); }
public function execute() { try { $migrationsPath = $this->getArgument('migrations_path'); $yamlSchemaPath = $this->getArgument('yaml_schema_path'); $migration = new Doctrine_Migration($migrationsPath); $result1 = false; if (!count($migration->getMigrationClasses())) { $result1 = Doctrine_Core::generateMigrationsFromDb($migrationsPath); } $connections = array(); foreach (Doctrine_Manager::getInstance() as $connection) { $connections[] = $connection->getName(); } $changes = Doctrine_Core::generateMigrationsFromDiff($migrationsPath, $connections, $yamlSchemaPath); $numChanges = count($changes, true) - count($changes); $result = $result1 || $numChanges ? true : false; } catch (Exception $e) { $result = false; } if (!$result) { throw new Doctrine_Task_Exception('Could not generate migration classes from database'); } else { $this->notify('Generated migration classes successfully from database'); } }
/** * @see sfPluginConfiguration */ public function initialize() { sfConfig::set('sf_orm', 'doctrine'); if (!sfConfig::get('sf_admin_module_web_dir')) { sfConfig::set('sf_admin_module_web_dir', '/sfDoctrinePlugin'); } if (sfConfig::get('sf_web_debug')) { require_once dirname(__FILE__) . '/../lib/debug/sfWebDebugPanelDoctrine.class.php'; $this->dispatcher->connect('debug.web.load_panels', array('sfWebDebugPanelDoctrine', 'listenToAddPanelEvent')); } if (!class_exists('Doctrine_Core', false)) { require_once sfConfig::get('sf_doctrine_dir', realpath(dirname(__FILE__) . '/../lib/vendor/doctrine')) . '/Doctrine/Core.php'; } spl_autoload_register(array('Doctrine_Core', 'autoload')); $manager = Doctrine_Manager::getInstance(); $manager->setAttribute(Doctrine_Core::ATTR_EXPORT, Doctrine_Core::EXPORT_ALL); $manager->setAttribute(Doctrine_Core::ATTR_VALIDATE, Doctrine_Core::VALIDATE_NONE); $manager->setAttribute(Doctrine_Core::ATTR_RECURSIVE_MERGE_FIXTURES, true); $manager->setAttribute(Doctrine_Core::ATTR_AUTO_ACCESSOR_OVERRIDE, true); $manager->setAttribute(Doctrine_Core::ATTR_AUTOLOAD_TABLE_CLASSES, true); // apply default attributes $manager->setDefaultAttributes(); if (method_exists($this->configuration, 'configureDoctrine')) { $this->configuration->configureDoctrine($manager); } $this->dispatcher->notify(new sfEvent($manager, 'doctrine.configure')); // make sure the culture is intercepted $this->dispatcher->connect('user.change_culture', array('sfDoctrineRecord', 'listenToChangeCultureEvent')); }
/** * @param Doctrine_Table|string $table Doctrine_Table object */ public function __construct($table) { if (!$table instanceof Doctrine_Table) { $table = Doctrine_Manager::getInstance()->getCurrentConnection()->getTable($table); } $this->table = $table; }
public function executeCrear(sfWebRequest $request) { $this->gestion = sfConfig::get('app_gestion'); // Este periodo esta definido por default por Semestre, para configurar revisar app.yml $this->periodo = $this->getUser()->getAttribute('PERIODO'); // Buscando Unidad Educativa $buscar_ue = Doctrine::getTable('RelUsuarioUe')->getCodUE($this->getUser()->getAttribute('USUARIO_ID')); // Asignado Codigo de Unidad Educativa $this->codue = $buscar_ue['cod_ue']; // Recuperando variable de subcentro $param_subcentro = $request->getParameter('dat_rue_subcentro'); // Asignando variable de subcentro $this->subcea = $param_subcentro['subcentro_id']; //verificamos si tiene permisos para la Centro de Educacion Alternativa $unidad = Doctrine::getTable('DatRueUnidadEducativa')->getAsignacionUesUsuario($this->codue, $this->getUser()->getAttribute('USUARIO_ID')); if ($unidad) { $this->getUser()->setFlash('ue', $this->codue); $this->getUser()->setFlash('gestion', $this->gestion); $this->unidad_educativa = Doctrine::getTable('SdatRueUnidadEducativa')->find(array($this->codue, $this->subcea, $this->periodo)); $this->turnos = Doctrine::getTable('ClaTurno')->findAll(); if (!$this->unidad_educativa) { // Ejecutando Procedimiento Almacenedao que inserta en la tabla sdat_rue_unidad_Educativa los datos $proc_inicio_gestion_alternativa = Doctrine_Manager::getInstance()->getCurrentConnection()->execute("CALL proc_inicio_gestion_alt(" . $this->gestion . "," . $this->periodo . ",'" . $this->codue . "'," . $this->subcea . ")"); $this->unidad_educativa = Doctrine::getTable('SdatRueUnidadEducativa')->find(array($this->codue, $this->subcea, $this->periodo)); } } else { $this->notice = 'NO TIENE TUICION SOBRE EL C.E.A. O EL C.E.A NO SE ENCUENTRA REGISTRADO'; } return sfView::SUCCESS; }
public function testCachedResultsAreSpecificToDsn() { $cacheDriver = new Doctrine_Cache_Array(); $conn1 = Doctrine_Manager::connection('sqlite::memory:', 'conn_1'); $conn1->setAttribute(Doctrine_Core::ATTR_RESULT_CACHE, $cacheDriver); $conn2 = Doctrine_Manager::connection('sqlite::memory:', 'conn_2'); $conn2->setAttribute(Doctrine_Core::ATTR_RESULT_CACHE, $cacheDriver); $this->assertNotEqual($conn1, $conn2); $manager = Doctrine_Manager::getInstance(); $manager->setCurrentConnection('conn_1'); $this->assertEqual($conn1, Doctrine_Manager::connection()); Doctrine_Core::createTablesFromArray(array('Ticket_1706_User')); $user = new Ticket_1706_User(); $user->name = 'Allen'; $user->save(); $manager->setCurrentConnection('conn_2'); $this->assertEqual($conn2, Doctrine_Manager::connection()); Doctrine_Core::createTablesFromArray(array('Ticket_1706_User')); $user = new Ticket_1706_User(); $user->name = 'Bob'; $user->save(); $manager->setCurrentConnection('conn_1'); $u1 = Doctrine_Query::create()->from('Ticket_1706_User u')->useResultCache()->execute(); $this->assertEqual(1, count($u1)); $this->assertEqual('Allen', $u1[0]->name); $manager->setCurrentConnection('conn_2'); $u2 = Doctrine_Query::create()->from('Ticket_1706_User u')->useResultCache()->execute(); $this->assertEqual(1, count($u2)); $this->assertEqual('Bob', $u2[0]->name); }
public function testInit() { $this->dbh = new Doctrine_Adapter_Mock('mysql'); $this->conn = Doctrine_Manager::getInstance()->openConnection($this->dbh); $this->conn->setCharset('utf8'); $this->conn->setAttribute(Doctrine::ATTR_USE_NATIVE_ENUM, true); }
/** * initialise module */ public function install() { if (!DBUtil::createTable('categories_category')) { return false; } // Create the index if (!DBUtil::createIndex('idx_categories_parent', 'categories_category', 'parent_id') || !DBUtil::createIndex('idx_categories_is_leaf', 'categories_category', 'is_leaf') || !DBUtil::createIndex('idx_categories_name', 'categories_category', 'name') || !DBUtil::createIndex('idx_categories_ipath', 'categories_category', array('ipath', 'is_leaf', 'status')) || !DBUtil::createIndex('idx_categories_status', 'categories_category', 'status') || !DBUtil::createIndex('idx_categories_ipath_status', 'categories_category', array('ipath', 'status'))) { return false; } $this->insertData_10(); // Set autonumber to 10000 (for DB's that support autonumber fields) $cat = array('id' => 9999, 'parent_id' => 1, 'is_locked' => 0, 'is_leaf' => 0, 'name' => '', 'value' => '', 'sort_value' => 0, 'display_name' => '', 'display_desc' => '', 'path' => '', 'ipath' => '', 'status' => ''); DBUtil::insertObject($cat, 'categories_category', 'id', true); // for postgres, we need to explicitly set the sequence value to reflect the inserted data $dbDriverName = strtolower(Doctrine_Manager::getInstance()->getCurrentConnection()->getDriverName()); if ($dbDriverName == 'pgsql') { $dbtables = DBUtil::getTables(); $tab = $dbtables['categories_category']; $col = $dbtables['categories_category_column']; $seq = $tab . '_cat_id_seq'; $sql = "SELECT setval('{$seq}', (SELECT MAX({$col['id']}) + 1 FROM {$tab}))"; DBUtil::executeSQL($sql); } DBUtil::deleteObjectByID('categories_category', 9999, 'id'); $this->createTables_101(); $this->setVar('userrootcat', '/__SYSTEM__/Users'); $this->setVar('allowusercatedit', 0); $this->setVar('autocreateusercat', 0); $this->setVar('autocreateuserdefaultcat', 0); $this->setVar('userdefaultcatname', 'Default'); // Initialisation successful return true; }
public function tearDown() { $manager = Doctrine_Manager::getInstance(); $manager->getConnection($this->getDoctrineConnection()->getName())->close(); $manager->reset(); $manager->resetInstance(); }