本文整理汇总了PHP中Doctrine_Manager类的典型用法代码示例。如果您正苦于以下问题:PHP Doctrine_Manager类的具体用法?PHP Doctrine_Manager怎么用?PHP Doctrine_Manager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Doctrine_Manager类的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: configureDoctrine
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');
}
示例3: configureDoctrineCache
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);
}
}
示例4: configureDoctrine
/**
* 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);
}
示例5: configureDoctrine
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');
}
示例6: configureDoctrine
/**
* 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');
}
示例7: testTest
public function testTest()
{
Doctrine_Manager::getInstance()->setAttribute(Doctrine_Core::ATTR_VALIDATE, Doctrine_Core::VALIDATE_ALL);
$user = new Ticket_DC187_User();
$user->username = 'jwage';
$user->email = 'jonwage@gmail.com';
$user->password = 'changeme';
$user->save();
$user->delete();
try {
$user = new Ticket_DC187_User();
$user->username = 'jwage';
$user->email = 'jonwage@gmail.com';
$user->password = 'changeme';
$user->save();
$this->pass();
} catch (Exception $e) {
$this->fail($e->getMessage());
}
try {
$user = new Ticket_DC187_User();
$user->username = 'jwage';
$user->email = 'jonwage@gmail.com';
$user->password = 'changeme';
$user->save();
$this->fail();
} catch (Exception $e) {
$this->pass();
}
Doctrine_Manager::getInstance()->setAttribute(Doctrine_Core::ATTR_VALIDATE, Doctrine_Core::VALIDATE_NONE);
}
示例8: read
/**
*
* @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;
}
示例9: __construct
/**
* @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;
}
示例10: 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();
}
示例11: postUp
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);
}
示例12: pdo
/**
* @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;
}
示例13: preExecute
public function preExecute()
{
if (isset($_SESSION['username'])) {
$this->redirect("http://ausw_travelagency_app.com/home/index");
}
$this->conn = Doctrine_Manager::getInstance()->connection();
}
示例14: execute
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";
}
示例15: down
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);
}