Welcome Guest, Not a member yet? Register   Sign In
Drop-in PHP Doctrine plugin
#11

[eluser]RedLeader[/eluser]
[quote author="GSV Sleeper Service" date="1237927266"]most odd, these are my doctrine autoload settings, they're probably out of date, I've been using these since Doctrine 1.0.1, but they're still working with 1.1
Code:
Doctrine_Manager::getInstance()->setAttribute(Doctrine::ATTR_MODEL_LOADING, Doctrine::MODEL_LOADING_CONSERVATIVE);
Doctrine_Manager::getInstance()->setAttribute(Doctrine::ATTR_AUTOLOAD_TABLE_CLASSES, TRUE);
[/quote]

GSV you legend! I added the 2nd line to autoload the table classes and it worked! That bit clearly isn't necessary when using AGGRESSIVE autoloading because it just loads every php file in the model directries!

Thanks for posting that!

Now onwards and upwards with my Doctrine learning curve...

Oh, by the way, I'm still using Doctrine 1.0 because that's what came with CI-Doctrine plugin. Is it a simple matter of swapping out Doctrine 1.0 for 1.1 from the plugins directory? Did it work straight away or cause any issues?
#12

[eluser]GSV Sleeper Service[/eluser]
yep, I've just been replacing the Doctrine core files each time a new version is released. just copy everything from the Doctrine 'lib' folder to the 'doctrine' folder in the plugin folder.
#13

[eluser]RedLeader[/eluser]
[quote author="GSV Sleeper Service" date="1237928236"]yep, I've just been replacing the Doctrine core files each time a new version is released. just copy everything from the Doctrine 'lib' folder to the 'doctrine' folder in the plugin folder.[/quote]

Great - I'll try that out.

I see this page mentions the differences between 1.0 and 1.1:
http://www.doctrine-project.org/blog/doc...1-released

It also details the SVN repo so I think I'll add that as an SVN:External to my CI project Smile
#14

[eluser]scor[/eluser]
Great! 10xs!! I searched it for a long time Smile
#15

[eluser]acpbl[/eluser]
Hi all,

great job this looks very promising.

A couple of questions:

1. Would the plugin work with multiple databases?
2. What about name conflicts where the same table name is used in database A and database B. Is it possible to distinguish within the models definition?

thanks in advance
#16

[eluser]andriansandi[/eluser]
Is the CLI working with this plugin?
#17

[eluser]sshz[/eluser]
[quote author="sandhee_tube" date="1241361495"]Is the CLI working with this plugin?[/quote]

There is no CLI in plugin, I use this for CLI, works great with this plugin, there is two files, put them in application folder

doctrine.php
Code:
<?php

require_once('config/database.php');
require_once('../system/plugins/doctrine_pi.php');
// Configure Doctrine Cli
// Normally these are arguments to the cli tasks but if they are set here the arguments will be auto-filled
$config = array('fixtures_path'  =>  dirname(__FILE__) . DIRECTORY_SEPARATOR . 'doctrine/fixtures',
                'data_fixtures_path'  =>  dirname(__FILE__) . DIRECTORY_SEPARATOR . 'doctrine/fixtures',
                'models_path'         =>  dirname(__FILE__) . DIRECTORY_SEPARATOR . 'doctrine/models',
                'migrations_path'     =>  dirname(__FILE__) . DIRECTORY_SEPARATOR . 'doctrine/migrations',
                'sql_path'            =>  dirname(__FILE__) . DIRECTORY_SEPARATOR . 'doctrine/sql',
                'yaml_schema_path'    =>  dirname(__FILE__) . DIRECTORY_SEPARATOR . 'doctrine/schema');


$cli = new Doctrine_Cli($config);
$cli->run($_SERVER['argv']);

?>



dt
Code:
#!/usr/local/bin/php
<?php
define('BASEPATH','.'); // mockup that this app was executed from ci ;)
chdir(dirname(__FILE__));
include('doctrine.php');

?>

run the dt file
#18

[eluser]fourcs[/eluser]
Using CI_1.7.1 and doctrine-1.1.1. Executing dt produces PHP warning that it can't find doctrine_pi.php and PHP fatal error for not finding the file, yet the file is where it should be, namely, in the system/plugins folder.
#19

[eluser]iDVB[/eluser]
[quote author="Nick Husher" date="1228345768"]CI-Doctrine - built for Doctrine 1.0 (included in package)

A colleague of mine recently turned me on to Doctrine, an Object-Relational Mapper for PHP5. There are plenty of great resources that explain exactly what using an ORM gets you, but for me it boils down to being able to transparently serialize objects into my database in a human-understandable way.

The problem is that Doctrine didn't really have CodeIgniter in mind when it was developed, so it can be a little difficult and confusing to install it in such a way as to be maintainable and comfortable to use for a CI developer. I read the Wiki article, which is a little dated (for version 0.1 rather that version 1.0), and requires hacking of core CodeIgniter files. I also found a helpful blog entry, which migrates any core hacking out into a hook, but it still required some configuration and couldn't be selectively disabled on some pages (not every page needs that kind of page overhead). I want drop-in-and-go ease, and flexibility.

So, I developed my own solution in the form of a CI plugin. It grabs information from the database.php configuration file, just like the hook, but is as simple as dropping it into your CI plugins directory and writing your schema file.

The Readme file follows:[/quote]

I read later in this thread that others have gotten this plugin working even with other versions of doctrine? Is this supposed to work that way? is upgrading this plugin as simple as dropping in the new doctrine code?
#20

[eluser]Nick Husher[/eluser]
Suggestion: Give it a try and let me know how it works. Wink

Doctrine and CodeIgniter are very loosely coupled in my plugin: it's basically just adding your Doctrine classes to the global namespace (if you load the Doctrine plugin somewhere in your request) and letting you do what you want. It should continue to work as long as the API to turn a schema into a set of class files and fixtures into database data haven't changed. I'm not an expert in Doctrine, but I don't see why 1.1 wouldn't work with the plugin. I don't know anything about Doctrine 2.0, so I can't speak to that.




Theme © iAndrew 2016 - Forum software by © MyBB