Example #1
1
 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();
 }
 public function configureDoctrine(Doctrine_Manager $manager)
 {
     $options = array('baseClassName' => 'BaseDoctrineRecord');
     sfConfig::set('doctrine_model_builder_options', $options);
     $manager->setCollate('utf8_unicode_ci');
     $manager->setCharset('utf8');
 }
Example #3
0
 protected function configureDoctrineCache(Doctrine_Manager $manager)
 {
     if (sfConfig::get('dm_orm_cache_enabled', true) && dmAPCCache::isEnabled()) {
         $driver = new Doctrine_Cache_Apc(array('prefix' => dmProject::getNormalizedRootDir() . '/doctrine/'));
         $manager->setAttribute(Doctrine_Core::ATTR_QUERY_CACHE, $driver);
     }
 }
 /**
  * Configure the Doctrine engine
  **/
 public function configureDoctrine(Doctrine_Manager $manager)
 {
     $manager->setAttribute(Doctrine::ATTR_QUERY_CACHE, new Doctrine_Cache_Apc());
     $manager->setAttribute(Doctrine_Core::ATTR_RESULT_CACHE, new Doctrine_Cache_Apc());
     $options = array('baseClassName' => 'DarwinModel');
     sfConfig::set('doctrine_model_builder_options', $options);
 }
 public function configureDoctrine(Doctrine_Manager $manager)
 {
     // yiid activity dispatcher
     $this->dispatcher->connect('new-yiid-activity', array('StatsFeeder', 'track'));
     $manager->setCollate('utf8_unicode_ci');
     $manager->setCharset('utf8');
 }
 /**
  * Configure doctrine connections to use tablename prefix hs_hr_
  */
 public function configureDoctrine(Doctrine_Manager $manager)
 {
     $manager->setAttribute(Doctrine_Core::ATTR_VALIDATE, Doctrine_Core::VALIDATE_ALL);
     $manager->setAttribute(Doctrine_Core::ATTR_USE_NATIVE_ENUM, true);
     //
     // If using encryption, enable dql callbacks. Needed by EncryptionListener
     //
     if (KeyHandler::keyExists()) {
         $manager->setAttribute(Doctrine_Core::ATTR_USE_DQL_CALLBACKS, true);
     }
     //$manager->setAttribute(Doctrine::ATTR_TBLNAME_FORMAT, 'hs_hr_%s');
 }
 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);
 }
Example #8
0
 /**
  *
  * @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;
 }
Example #9
0
 /**
  * @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;
 }
 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();
 }
Example #11
0
 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);
 }
Example #12
0
 /**
  * @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 preExecute()
 {
     if (isset($_SESSION['username'])) {
         $this->redirect("http://ausw_travelagency_app.com/home/index");
     }
     $this->conn = Doctrine_Manager::getInstance()->connection();
 }
 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();
     echo "\nApostrophe Database Migration Task\n  \nThis task will make any necessary database schema changes to bring your \nMySQL database up to date with the current release of Apostrophe and any additional\nApostrophe plugins that you have installed. For other databases see the source code \nor run './symfony doctrine:build-sql' to obtain the SQL commands you may need.\n  \nBACK UP YOUR DATABASE BEFORE YOU RUN THIS TASK. It works fine in our tests, \nbut why take chances with your data?\n\n";
     if (!$options['force']) {
         if (!$this->askConfirmation("Are you sure you are ready to migrate your project? [y/N]", 'QUESTION_LARGE', false)) {
             die("Operation CANCELLED. No changes made.\n");
         }
     }
     $this->migrate = new aMigrate(Doctrine_Manager::connection()->getDbh());
     // If I needed to I could look for the constraint definition like this.
     // But since we added these in the same migration I don't have to. Keep this
     // comment around as sooner or later we'll probably need to check for this
     // kind of thing
     //
     // $createTable = $data[0]['Create Table'];
     // if (!preg_match('/CONSTRAINT `a_redirect_page_id_a_page_id`/', $createTable))
     // {
     //
     // }
     if (!$this->migrate->tableExists('a_redirect')) {
         $this->migrate->sql(array("CREATE TABLE IF NOT EXISTS a_redirect (id INT AUTO_INCREMENT, page_id INT, slug VARCHAR(255) UNIQUE, created_at DATETIME NOT NULL, updated_at DATETIME NOT NULL, INDEX slugindex_idx (slug), INDEX page_id_idx (page_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci ENGINE = INNODB;", "ALTER TABLE a_redirect ADD CONSTRAINT a_redirect_page_id_a_page_id FOREIGN KEY (page_id) REFERENCES a_page(id) ON DELETE CASCADE;"));
     }
     if (!$this->migrate->getCommandsRun()) {
         echo "Your database is already up to date.\n\n";
     } else {
         echo $this->migrate->getCommandsRun() . " SQL commands were run.\n\n";
     }
     echo "Done!\n";
 }
Example #15
0
 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);
 }
Example #16
0
 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');
     }
 }
Example #17
0
 public function testExport()
 {
     $conn = Doctrine_Manager::connection('mysql://root@localhost/test');
     $sql = $conn->export->exportClassesSql(array('Ticket_1604_User', 'Ticket_1604_EmailAdresses'));
     $def = array("CREATE TABLE ticket_1604__user (id BIGINT AUTO_INCREMENT, name VARCHAR(30), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = INNODB", "CREATE TABLE ticket_1604__email_adresses (id BIGINT AUTO_INCREMENT, user_id BIGINT, address VARCHAR(30), INDEX user_id_idx (user_id), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE = INNODB", "ALTER TABLE ticket_1604__email_adresses ADD CONSTRAINT ticket_1604__email_adresses_user_id_ticket_1604__user_id FOREIGN KEY (user_id) REFERENCES ticket_1604__user(id)");
     $this->assertEqual($sql, $def);
 }
Example #18
0
 public function validate($user, $password)
 {
     if (!isset($user)) {
         $user = new CocoasUser();
     }
     $cuenta = 0;
     try {
         $this->connection = Doctrine_Manager::connection();
         $q = Doctrine_Query::create()->from('user u')->where("u.email='" . $user->name . "'");
         $rows = $q->execute();
         $cuenta = count($rows);
     } catch (Exception $e) {
         if ($GLOBALS["debugMode"]) {
             $this->validator->errors->addError(ErrorManager::CANIS_FATAL, $e->getMessage());
         }
     }
     if ($cuenta == 1) {
         $auxUser = $rows[0];
         //Si los hash de la clave coinciden
         if ($password == $auxUser->password) {
             $user->roleName = $auxUser->Role->name;
             $user->locationId = $auxUser->Location->id;
             $user->status = $auxUser->status;
             $user->id = $auxUser->id;
         }
     } else {
         $user = new CocoasUser();
     }
     return $user;
 }
Example #19
0
 /**
  * Retrieves the connection associated to this expression at creation,
  * or the current connection used if it was not specified. 
  * 
  * @return Doctrine_Connection The connection
  */
 public function getConnection()
 {
     if (!isset($this->_conn)) {
         return Doctrine_Manager::connection();
     }
     return $this->_conn;
 }
Example #20
0
 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();
 }
 public function initialize($context, $parameters = array())
 {
     parent::initialize($context, $parameters);
     $this->db = Doctrine_Manager::connection();
     $this->request = $context->getRequest();
     $this->response = $context->getResponse();
 }
 protected function execute($arguments = array(), $options = array())
 {
     $configuration = ProjectConfiguration::getApplicationConfiguration($arguments['application'], $options['env'], true);
     $databaseManager = new sfDatabaseManager($configuration);
     $databaseManager->initialize($configuration);
     $this->db = Doctrine_Manager::connection();
     $this->s3 = new S3(sfConfig::get('app_amazon_access_key'), sfConfig::get('app_amazon_secret_key'));
     // hide strict errors
     error_reporting(E_ERROR | E_WARNING | E_PARSE | E_NOTICE);
     $sql = "SELECT DISTINCT(r.source) FROM reference r ORDER BY id ASC LIMIT " . $options["limit"] . " OFFSET " . $options["offset"];
     $stmt = $this->db->execute($sql);
     $sources = $stmt->fetchAll(PDO::FETCH_COLUMN);
     foreach ($sources as $source) {
         if (!$options["localdir"]) {
             $s3path = ReferenceTable::generateS3path($source);
             if (!$options["overwrite"] && $this->s3->getObjectInfo(sfConfig::get('app_amazon_s3_bucket'), $s3path) !== false) {
                 print "ALREADY UPLOADED: " . $s3path . "\n";
                 continue;
             }
         }
         $this->writeTmpFile($source, $options["debug_mode"], $options["localdir"]);
         if (!$options["localdir"]) {
             $this->uploadTmpFile($source, $options["overwrite"], $options["debug_mode"]);
             if (unlink($this->getLocalPath($source, $options["local_dir"])) && $options["debug_mode"]) {
                 print "REMOVED LOCAL: " . $source . " [" . sha1($source) . "]\n";
             }
         }
         print "----------------------------------------------------------------\n";
     }
     //DONE
     LsCli::beep();
 }
 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());
     }
 }
 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();
 }
 public static function createDistantNoticeLang($version_notice_id, $notice_id, $notice_ref, $lang, Doctrine_Connection $conn = null)
 {
     if ($conn == null) {
         $conn = Doctrine_Manager::connection();
     }
     try {
         $conn->beginTransaction();
         //Début de la transaction
         //Appel du webservice
         $result_service = MyFunction::loadResultOfWebServiceByPostJson(MyFunction::getPrefixPath(null) . "serviceweb/createNoticeVersion.json", array('version_notice_id' => $version_notice_id, 'notice_id' => $notice_id, 'notice_ref' => $notice_ref, 'lang' => $lang));
         //Récupération de la nouvelle langue de notice pour traitement
         $array_result = json_decode(html_entity_decode($result_service), true);
         if (count($array_result) == 0) {
             return array("success" => false, "message" => "Error on transaction");
         }
         if (array_key_exists("error", $array_result)) {
             return array("success" => false, "message" => $array_result["error"]);
         }
         if (!$array_result[0]) {
             return array("success" => false, "message" => "Empty result content");
         }
         self::reload($array_result, $conn);
         $conn->commit();
         return Doctrine_Core::getTable("EiVersionNotice")->findOneByVersionNoticeIdAndNoticeIdAndNoticeRefAndLang($version_notice_id, $notice_id, $notice_ref, $lang);
     } catch (Exception $e) {
         $conn->rollback();
         throw $e;
         return false;
     }
 }
Example #26
0
 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');
 }
Example #27
0
 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);
 }
Example #28
0
 function index()
 {
     $category = new Category();
     $category->title = "The CodeIgniter Lounge";
     $forum = new Forum();
     $forum->title = "Introduce Yourself!";
     $forum->description = "Use this forum to introduce yourself to the CodeIgniter community, or to announce your new CI powered site.";
     // add category to the forum
     $forum->Category = $category;
     $forum2 = new Forum();
     $forum2->title = "The Lounge";
     $forum2->description = "CodeIgniter's social forum where you can discuss anything not related to development. No topics off limits... but be civil.";
     // you can also add the other way around
     // add forum to the category
     $category->Forums[] = $forum2;
     // a different syntax (array style)
     $category2 = new Category();
     $category2['title'] = "CodeIgniter Development Forums";
     $forum3 = new Forum();
     $forum3['title'] = "CodeIgniter Discussion";
     $forum3['description'] = "This forum is for general topics related to CodeIgniter";
     $forum4 = new Forum();
     $forum4['title'] = "Code and Application Development";
     $forum4['description'] = "Use the forum to discuss anything related to programming and code development.";
     $category2['Forums'][] = $forum3;
     $category2['Forums'][] = $forum4;
     // flush() saves all unsaved objects
     $conn = Doctrine_Manager::connection();
     $conn->flush();
     echo "Success!";
 }
Example #29
0
 /**
  * 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;
 }
Example #30
0
 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());
 }