Being inspired by the wonderful series of articles/screencasts on the nettuts website called CodeIgniter From Scratch I decided to write my own series on using CodeIgniter and Doctrine together to build a functional website in a series of tutorials.
In this first part of series, I will show you how to create a basic CodeIgniter install and add Doctrine as a plug-in.
"CodeIgniter and Doctrine from Scratch" Series:
Why add Doctrine to CodeIgniter?
Before we get started, first let me explain the reason I am doing this. Doctrine is an Object Relational Mapper for PHP. It’s OK if you don’t know this term. It basically means that you can map your database tables to classes in your web application. And instances of these classes (i.e. objects) represent records in the database.
This makes it very easy to create, read, update and delete records from the database, while handling them almost like regular objects, so you don’t even have to write any queries. It will also handle relationships between your tables. There are several other benefits that I will not get into until later in these tutorials. See the Doctrine Introduction, if you would like more info right now.
Here is an illustration I put together, that might give you a visual picture.

First Step: Setup your development environment
If you already have a web server with PHP and MySQL setup, you can skip some of this.
- Download and install WAMP (for Mac: MAMP)
Warning Skype Users: You must shutdown Skype first before you start up WAMP, due to a port conflict. After WAMP starts up, you can open Skype again. - Visit http://localhost/ in your browser to make sure it’s working
- Open the “www” folder under the WAMP installation.
- Create a folder named “ci_doctrine_day1″. We will put our files here.
Install CodeIgniter
- Download CodeIgniter
- Extract and copy the contents into your new “ci_doctrine_day1″ folder.
- You may delete the “user_guide” folder.
Your new folders should look like this:

You should see this:

CodeIgniter Crash Course: Controllers
Controllers are called by CodeIgniter on every page load.
They are located under:
system/application/controllers/
The url structure looks like this:
http://localhost/ci_doctrine_day1/index.php/CONTROLLER_NAME/FUNCTION_NAME
For example if you open this url:
http://localhost/ci_doctrine_day1/index.php/hello/world
CodeIgniter will look for a controller class named “Hello” and call it’s method named “world()”.
So let’s create our first controller.
Our First Controller
- Create this file: system/application/controllers/hello.php
<?php
// system/application/controllers/hello.php
class Hello extends Controller {
function world() {
echo "Hello CodeIgniter!";
}
}
You should see:
Hello CodeIgniter!
Please Note:
- The class must extend Controller.
- The class name must be capitalized.
- The file name must be lowercase.
Recommended Reading:
Install Doctrine
CodeIgniter allows us to add plug-ins. That’s how we will be installing it.
- Create this folder: system/application/plugins
- Create this folder: system/application/plugins/doctrine
- Download Doctrine
- Extract the files. Find the folder named “lib” and copy it to system/application/plugins/doctrine.
Now your folders should look like this:

- Create the plug-in file: system/application/plugins/doctrine_pi.php
<?php
// system/application/plugins/doctrine_pi.php
// load Doctrine library
require_once APPPATH.'/plugins/doctrine/lib/Doctrine.php';
// load database configuration from CodeIgniter
require_once APPPATH.'/config/database.php';
// this will allow Doctrine to load Model classes automatically
spl_autoload_register(array('Doctrine', 'autoload'));
// we load our database connections into Doctrine_Manager
// this loop allows us to use multiple connections later on
foreach ($db as $connection_name => $db_values) {
// first we must convert to dsn format
$dsn = $db[$connection_name]['dbdriver'] .
'://' . $db[$connection_name]['username'] .
':' . $db[$connection_name]['password'].
'@' . $db[$connection_name]['hostname'] .
'/' . $db[$connection_name]['database'];
Doctrine_Manager::connection($dsn,$connection_name);
}
// CodeIgniter's Model class needs to be loaded
require_once BASEPATH.'/libraries/Model.php';
// telling Doctrine where our models are located
Doctrine::loadModels(APPPATH.'/models');
// (OPTIONAL) CONFIGURATION BELOW
// this will allow us to use "mutators"
Doctrine_Manager::getInstance()->setAttribute(
Doctrine::ATTR_AUTO_ACCESSOR_OVERRIDE, true);
// this sets all table columns to notnull and unsigned (for ints) by default
Doctrine_Manager::getInstance()->setAttribute(
Doctrine::ATTR_DEFAULT_COLUMN_OPTIONS,
array('notnull' => true, 'unsigned' => true));
// set the default primary key to be named 'id', integer, 4 bytes
Doctrine_Manager::getInstance()->setAttribute(
Doctrine::ATTR_DEFAULT_IDENTIFIER_OPTIONS,
array('name' => 'id', 'type' => 'integer', 'length' => 4));
Read the comments in the code for explanations. However, don’t worry if you don’t understand all of it for now.
Database Setup and Configuration
- Open phpMyAdmin: http://localhost/phpmyadmin/
- Create a database named “ci_doctrine”

- Edit file: system/application/config/database.php
- Find the lines below and input the values.
// in system/application/config/database.php // ... $db['default']['hostname'] = "localhost"; $db['default']['username'] = "root"; $db['default']['password'] = ""; $db['default']['database'] = "ci_doctrine"; // ...
We just edited the database configuration file of CodeIgniter.
More Configuration
Almost done.
config.php
- Edit file: system/application/config/config.php
// in system/application/config/config.php // ... $config['base_url'] = "http://localhost/ci_doctrine_day1/"; // ...
Now CodeIgniter knows the url of our site.
autoload.php
- Edit file: system/application/config/autoload.php
// in system/application/config/autoload.php
// ...
$autoload['plugin'] = array('doctrine');
// ...
This makes sure the Doctrine plug-in is always loaded.
Finished!
Now we’re ready to rock. Let’s start testing our setup.
Our First Doctrine Model
Create a user Table
- Open phpMyAdmin: http://localhost/phpmyadmin/
- Go to database “ci_doctrine”
- Create a table named “user” with columns:
id => int, primary key, auto_increment,
username => varchar(255), unique,
password => varchar(255),
first_name => varchar(255),
last_name => varchar(255)
You may use this query:
CREATE TABLE `ci_doctrine`.`user` ( `id` INT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY , `username` VARCHAR( 255 ) NOT NULL , `password` VARCHAR( 255 ) NOT NULL , `first_name` VARCHAR( 255 ) NOT NULL , `last_name` VARCHAR( 255 ) NOT NULL , UNIQUE ( `username` ) )

Create the Model
- Create file: system/application/models/user.php
<?php
// system/application/models/user.php
class User extends Doctrine_Record {
public function setTableDefinition() {
$this->hasColumn('username', 'string', 255);
$this->hasColumn('password', 'string', 255);
$this->hasColumn('first_name', 'string', 255);
$this->hasColumn('last_name', 'string', 255);
}
}
Note:
- We extend Doctrine_Record, instead of Model (which you normally would with CodeIgniter models).
- Inside the function setTableDefinition() we need to define the table structure.
- By default, Doctrine will look for a table with same name as the class. In this case: “user”. (this can be changed)
- In our doctrine_pi.php file above in this tutorial, we specified for a default primary key named “id”. Therefore we don’t need to put it again in our User class.
Testing the Model: Add Some Users
- Edit our controller we created earlier: system/application/controllers/hello.php
<?php
// system/application/controllers/hello.php
class Hello extends Controller {
function world() {
echo "Hello CodeIgniter!";
}
function user_test() {
$u = new User;
$u->username = 'johndoe';
$u->password = 'secret';
$u->first_name = 'John';
$u->last_name = 'Doe';
$u->save();
$u2 = new User;
$u2->username = 'phprocks';
$u2->password = 'mypass';
$u2->first_name = 'Codeigniter';
$u2->last_name = 'Doctrine';
$u2->save();
echo "added 2 users";
}
}
We just generated 2 objects, and populated them with some data. Simply calling save() should save them into our database.
Note:
- We are able to access the fields as parameters (e.g. $u->username), even though we did not create these as class parameters. Isn’t Doctrine nice?
- If you are familiar with CodeIgniter, you might remember that you need to call $this->load->model() function to load models. However since we registered the autoload function of Doctrine, just saying “new User;” is enough.
- We didn’t create the “save()” function, because it comes from the Doctrine_Record class we extended. It saves the objects to the database. There are many other functions and goodies that come with Doctrine classes, we will see later in the tutorials.
You should see output:
added 2 users
- Now go back to phpMyAdmin: http://localhost/phpmyadmin/
- Browse the table ‘user’
Voila! Now you should be able see the 2 new records that just got created.

Stay Tuned
We just saw how to install and setup CodeIgniter with Doctrine. It took some work, but now we have a powerful MVC framework and ORM combination.
In the next tutorials, I will show you more practical examples and eventually build a functional website. You will see how easy it is to create models with Doctrine and save time from having to write repetitive CRUD (Create, read, update and delete) functions in all of your models.
Doctrine will also help us handle the relationships between our classes, and let us avoid writing complex logic code and queries.
See you next time!

Pingback: Tweets that mention CodeIgniter and Doctrine from scratch.Day 1 – Install and Setup. | PHP and Stuff -- Topsy.com
#1 by David Ferguson on October 29th, 2009
| Quote
Any plans to turn these into screencasts? I am tempted to read it but honestly, I really hate sitting here reading through something this long. Chances are I typically know most of it, but then I try to skim over the stuff and I’ll miss one little thing that was important
I’m lazy, what can I say? haha
#2 by Burak on October 29th, 2009
| Quote
Yea, I am planning on doing some screencasts in the near future. But I don’t think they can replace the article format entirely.
#3 by RexDomz on July 18th, 2010
| Quote
I’m just new to php particularly CI. But i guess reading is merely good for those individuals that have enough time to explore. And i agree with your suggestions. But for me this tuts is pretty good and i learned a lot of this stuff! Thank you!
For the author:
Can you give us the list of the class and methods for doctrine and also more examples? I really lyk your tuts!
#4 by DANIEL BRAHM on October 29th, 2009
| Quote
I have been working with CI for 2 years and I am always checking for more about ci. Keep your great job!
#5 by kodegeek on October 29th, 2009
| Quote
Hi, i’ve followed every steps as above, in Mac with php 5.2.6 and mysql 5.0.41 using MAMP, if i hit the worl method – it shows fine but if i hit for test user, nothing comes – just a blank page! I realy like your post that implements ORM feature. Here are the error log i found(which seems no error)
DEBUG – 2009-10-30 06:04:19 –> Config Class Initialized
DEBUG – 2009-10-30 06:04:19 –> Hooks Class Initialized
DEBUG – 2009-10-30 06:04:19 –> URI Class Initialized
DEBUG – 2009-10-30 06:04:19 –> Router Class Initialized
DEBUG – 2009-10-30 06:04:19 –> Output Class Initialized
DEBUG – 2009-10-30 06:04:19 –> Input Class Initialized
DEBUG – 2009-10-30 06:04:19 –> Global POST and COOKIE data sanitized
DEBUG – 2009-10-30 06:04:19 –> Language Class Initialized
DEBUG – 2009-10-30 06:04:19 –> Loader Class Initialized
DEBUG – 2009-10-30 06:04:19 –> Plugin loaded: doctrine_pi
DEBUG – 2009-10-30 06:04:19 –> Controller Class Initialized
Thanks
#6 by Burak on October 29th, 2009
| Quote
Try adding some echo statements inside the user_test() function. Both at the beginning and also between the lines.
See if you get any output at all.
Also I had a missing parenthesis at the end of the SQL query for generating the user table, I just fixed that.
#7 by Pierce on October 29th, 2009
| Quote
This is a great first look into Doctrine, which I have been interested in for some time. Great job
#8 by Aziz Light on October 30th, 2009
| Quote
Great job! I can’t wait for the next tutorials, and the eventual screencasts.
Also, I totally agree with you: as much as I love screencasts, a screencast can entirely replace a written article.
By the way I had a (weird) question. Since we’re using Doctrice to extend our models, can’t we remove all the Model class, database drivers, etc that we are not using anymore so that the whole app become smaller? or that might break CI?
#9 by Burak on October 30th, 2009
| Quote
You can delete the entire database folder if you want. But I believe CodeIgniter doesn’t load the database libraries unless you ask it to. So we’re already saving memory and execution time by not loading them.
Model is a very small component, but if you really want to remove it, first you need to delete this line in doctrine_pi.php:
require_once BASEPATH.’/libraries/Model.php’;
#10 by Aziz Light on October 30th, 2009
| Quote
Yeah obviously if I use doctrine I won’t autoload the database library (which I do normally). My point is to save space, but since the database folder is indeed very small it’s not worth it.
By the way, I absolutely love how you designed your comments display, with the thumbnail of the author’s site and the Reply | Quote links appearing on hover.
Actually, the whole design of the site is really cool. Good Job!
#11 by Kyle Farris on October 30th, 2009
| Quote
I second Aziz… this was very informative. I’ve always been very interested in trying Doctrine in Codeigniter but was never motivated enough to sit down and figure it out. It’s nice when people do that for you (and do it well).
Can’t wait for the tutorial/screencasts. My two cents: If every tutorial was written, I wouldn’t care… I’d read them all… it’s the content that matters to me, not the medium of delivery.
Once again, great job.
#12 by Rafael F P Viana on October 31st, 2009
| Quote
Very nice walkthrough, its on my delicious allready.
Great job!
Trackback: MVCForge - News for MVC Web Developers
#13 by iDVB on November 3rd, 2009
| Quote
Nice Tut Burak! Wish I had this when I first got started!
Got a question for you that you might have solved regarding this plugin.
Can you (or anyone) have a peak at this?
http://codeigniter.com/forums/viewreply/659878/
I feel like I have a good handle on everything doctrine except this issue.
Cheers!
#14 by Burak on November 3rd, 2009
| Quote
The link to the plugin in that article is broken, so I can’t take a look at the code.
However, from what I understand, Doctrine is just passing you an error from MySQL regarding a foreign key violation issue.
Is it trying to drop the tables one by one, or is just calling Doctrine::dropDatabases(); ?
#15 by iDVB on November 3rd, 2009
| Quote
My apologies…I thought you were using this same plugin in this tut. s this not the case? I see you have doctrine setup as a “plugin” and that other url I gave was the first time I had seen it bootstrapped this way.
If your way is indeed setup differently…then can I ask….are YOU able to use Doctrine::dropDatabases(); even when there are FKs without getting errors?
The plugin I mentioned simply did this:
function doctrine_destroy_database() {
$conn = Doctrine_Manager::getInstance()->getCurrentConnection();
$models = Doctrine::getLoadedModels();
foreach($models as $model) { $conn->export->dropTable(Doctrine::getTable($model)->getTableName());
}
}
#16 by Burak on November 3rd, 2009
| Quote
No I’m not using that one. Can you e-mail it to me? programming[AT]gmail.com
Doctrine::dropDatabases() should work. You might also need to call Doctrine::createDatabases() before creating tables.
But be careful with it, because it will drop the entire database, so if there are non-Doctrine tables, they will be dropped too.
#17 by Bradigan on November 3rd, 2009
| Quote
Great tutorial! Just found it on Google today.
I have the exact same problem as KodgGeek above. Same Debug (no errors). I’m also on a Mac running PHP / Mysql.
I did as you mentioned and put several echo statements at the beginning, middle and end of the user_test function, but still nothing.
#18 by Burak on November 3rd, 2009
| Quote
There might be some hidden errors going on. I don’t have a Mac currently to test this.
Maybe error reporting in MAMP is off by default?
Found this article on turning them on: http://www.jhuskisson.com/code-tidbits/re-enabling-error-reporting-in-mamp
#19 by Bradigan on November 3rd, 2009
| Quote
Great Suggestion. However I still received a blank page. BUT, I did manage to find this:
and it had the following error:
[03-Nov-2009 20:50:45] PHP Fatal error: Class ‘User’ not found in /Users/brad/Sites/mysite/application/controllers/hello.php on line 13
Like some other tutorials out there, I have moved the /application folder out of the /system folder. I put the folder back in there, but it still did not work.
#20 by Bradigan on November 3rd, 2009
| Quote
BTW, I had a missing ; in one of my lines and now I can get the echo statement at the top of user_test function, so I know its getting called now for sure. I’ll see if I can figure it out, I’ll post the answer here (hopefully)
#21 by Bradigan on November 3rd, 2009
| Quote
Fixed Blank Page Issue:
I had to move the /application/plugins/doctrine so it was in /system/plugins/doctrine
(Remember, I have the application folder out of my system folder).
I then had to move doctrine_pi.php folder to /system/plugins folder.
Lastly, I had to change the doctrine_pi.php file so that this line:
require_once APPPATH.’/plugins/doctrine/lib/Doctrine.php’;
was changed to
require_once BASEPATH.’/plugins/doctrine/lib/Doctrine.php’;
And now everything works!
Thanks AGAIN! Great Series!
#22 by Blue on January 18th, 2010
| Quote
Dear Bradigan,
I’m a very newby for Codeigniter. I’ve found your comments are very useful for me. I have a problem as below:
Fatal error: Class ‘User’ not found in C:\AppServ\www\CodeIgniter\system\application\controllers\hello.php on line 13
I tryed to solve it by following your guide, I moved the doctrine folder into /system/plugins and changed require_once APPPATH.’/plugins/doctrine/lib/Doctrine.php’; to require_once BASEPATH.’/plugins/doctrine/lib/Doctrine.php’;, but it’s still show the same error. Could you please give me any advice?
PS. very sorry for my English ^^
Pingback: » Les liens de millieu de semaine ! oxynel, blog communication - Agence de communication Montpellier
Pingback: CodeIgniter, ORM, Doctrine | PHP - TechnoFrame
#23 by iDVB on November 9th, 2009
| Quote
Does anyone have any links for good examples, tuts or the like that relate to CodeIgniter, Doctrine and OOP?
Thanks to help from Burak and a few others, I’ve managed to get this implementation combination working 100%. However, could really use some guidance on how Doctrine and CI play in the big picture.
Eg. Let’s say I want to build a website that can have many users and groups with various permissions. As far as security/permissions I would have a Doctrine User Class with function setpassword() would should hash the password. For extensibility, I’d like that actual “hashing” to be done in some kinda external CodeIgniter model called lets say…Auth_model->hashpassword()
Could you/Should you access the CI “Auth_model->hashpassword()” from within the Doctrine “User-setpassword()” function?
I know this is a crap example….but I’m really just trying to wrap my head around these fine ladies. (CI & Doctrine)
Cheers
#24 by Burak on November 9th, 2009
| Quote
It shouldn’t be a model in my opinion, if it’s just for utility. Models are meant to represent data. You can create a helper or library instead.
#25 by iDVB on November 9th, 2009
| Quote
Oh right, however, I’m more concerned with the Doctrine CI part of that example then anything….eg….even as a helper or library…Could you/should you being using a “CI” helper/library from “within” a Doctrine Class (User Class). What would that look like? as I assume you would have to load in the CI classes using “require_once” or something of the like? Reason being that, is it not true, that CI classes are not accessible (for free) from within Doctrine Classes?
Hope some of that makes some sense.
#26 by Burak on November 9th, 2009
| Quote
You need to get the CI superclass, since you can’t do $this->load
$CI =& get_instance();
$CI->load->helper(’blahblah’);
#27 by iDVB on November 9th, 2009
| Quote
Right…sorry…I did read that before. Is that the proper/efficient thing to do with CI and Doctrine? Eg. If I have a Doctrine User Class that loads that helper….would that not mean that for each time a User Object gets created…that helper will get loaded again and again? Something about this just seem like it might possibly be inefficient? Of course, I’m sure you have a much better handle on it then I, but I had to ask.
#28 by Burak on November 9th, 2009
| Quote
CI knows that a helper is already loaded. When load() is called again on the same helper, it doesn’t actually load anything. Helpers exist globally once loaded, because they are just procedural functions.
And the get_instace() call only gets a “reference” to an object, that already exists. It doesn’t get recreated or reloaded.
I believe it’s an efficient way of accessing/calling CI stuff from within a Doctrine Model.
If you really wanted to get deep into the “best practices” regarding OOP, some people would probably rather use the “Dependency Injection” pattern or something similar. But even CI itself does not follow that convention. I wouldn’t worry too much about it.
#29 by iDVB on November 9th, 2009
| Quote
Thanks again Burak. I’ll paste something useful once I’ve got a bit more into this.
Cheers
#30 by AD on November 10th, 2009
| Quote
One question you have not addressed — Why should we bother adding doctine? What’s wrong with using CodeIgniter as it is? What problem are you addressing and why should I, as a developer, care?
Thanks.
#31 by Burak on November 10th, 2009
| Quote
What do you mean I have not addressed it? The very first section of the article is titled “Why add Doctrine to CodeIgniter?”.
Codeigniter doesn’t have an ORM, it just has the Active Record class, which has limited functionality.
#32 by Kerran on November 11th, 2009
| Quote
awesome tutorial dude, keep up the good work and I look forward to creating this website with you
#33 by walter on November 24th, 2009
| Quote
Great tutorial, keep it going!
Lot of people are googling for ci tutorials nowdays.
Pingback: CodeIgniter – Doctrine ORM Tutorial : A way of enhancing CI « IndiRelease
Pingback: PHP MVC Tutorial series - OSNN Forum
Pingback: CodeIgniter et Doctrine à partir de zéro. Jour 1 – L’installation « Lerni – Le blog du site
#34 by Bruno on November 30th, 2009
| Quote
Really nice tuts, mate. Thanks to share!
Pingback: Обзор e-$ и прочего говна » Blog Archive » 21 Совет по оптимизации MySQL
#35 by Budy on December 3rd, 2009
| Quote
Really a great tutorial, very appreciate it. Thanks for your sharing, Burak
#36 by Sander Versluys on December 4th, 2009
| Quote
Awesome tutorial, i’ve been using CI and Doctrine in a similar way… It’s always nice to see how others did it! Thanks!
#37 by Enrique on December 8th, 2009
| Quote
Awesome tutorial. AWESEOME !!
I didn’t know about Doctrine at all, just heard of it someday…
Thanks !!
#38 by Taylan Bahar on December 9th, 2009
| Quote
Benim iki sorum olacak.
Birincisi : Neden codeigniter? Neden tanıdığım web programcıları codeigniter’ı kötülüyor?
İkincisi : bu alıştırmaların Türkçe’sini yayınlamayı düşünüyor musun?
#39 by mehike on December 12th, 2009
| Quote
excuse me for bad english… but my question:
In one computer in Windows XP system all works fine: Xampp+Codeigniter+Doctrine.
same, but in Linux (lampp+CodeIgniter+Doctrine) I can’t connect mysql with Doctrine (CodeIgniter with models and mysql works fine, connected to mysql) – but If I want use Doctrine in my web page:
A PHP Error was encountered
Severity: Warning
Message: PDO::__construct() [pdo.--construct]: [2002] Invalid argument (trying to connect via unix://)
Filename: Doctrine/Connection.php
Line Number: 474
Fatal error: Uncaught exception ‘Doctrine_Connection_Exception’ with message ‘PDO Connection Error: SQLSTATE[HY000] [2002] Invalid argument’ in /opt/lampp/htdocs/uusweb/application/plugins/doctrine/lib/Doctrine/Connection.php:478 Stack trace: #0 /opt/lampp/htdocs/uusweb/application/plugins/doctrine/lib/Doctrine/Connection/Mysql.php(101): Doctrine_Connection->connect() #1 /opt/lampp/htdocs/uusweb/application/plugins/doctrine/lib/Doctrine/Transaction.php(186): Doctrine_Connection_Mysql->connect() #2 /opt/lampp/htdocs/uusweb/application/plugins/doctrine/lib/Doctrine/Connection.php(1376): Doctrine_Transaction->beginTransaction(NULL) #3 /opt/lampp/htdocs/uusweb/application/plugins/doctrine/lib/Doctrine/Export.php(1210): Doctrine_Connection->beginTransaction() #4 /opt/lampp/htdocs/uusweb/application/plugins/doctrine/lib/Doctrine/Export.php(1100): Doctrine_Export->exportClasses(Array) #5 /opt/lampp/htdocs/uusweb/application/plugins/doctrine/lib/Doctrine/Core.php(889): Doctrine_Export->exportSchema(NULL) #6 /opt/lampp/htdocs/uusw in /opt/lampp/htdocs/uusweb/application/plugins/doctrine/lib/Doctrine/Connection.php on line 478
in database.php:
$db['default']['hostname'] = “localhost”;
$db['default']['username'] = “rp_user_27″;
$db['default']['password'] = “76rp77FG5er”;
$db['default']['database'] = “rpDB_uusweb_27″;
$db['default']['dbdriver'] = “mysql”;
$db['default']['dbprefix'] = “”;
$db['default']['pconnect'] = TRUE;
$db['default']['db_debug'] = TRUE;
$db['default']['cache_on'] = FALSE;
$db['default']['cachedir'] = “”;
$db['default']['char_set'] = “utf8″;
$db['default']['dbcollat'] = “utf8_unicode_ci”;
in doctrine_pi.php I print dsn string, it’s fine:
mysql://rp_user_27:76rp77FG5er@localhost/rpDB_uusweb_27
in doctrine Connection.php I print values too, before new PDO() command in 473line:
echo $this->options['dsn'].’*';
echo $this->options['username'].’*';
echo $this->options['password'].’*';
I see all fine:
mysql:host=localhost;dbname=rpDB_uusweb_27*rp_user_27*76rp77FG5er*
from linux commandline I can connect to mysql fine… I can’t think, that else I can do?
any help?
#40 by mehike on December 12th, 2009
| Quote
ok I’m find answer: unix_socket in connection string must be:
$dsn = $db[$connection_name]['dbdriver'] .
‘://’ . $db[$connection_name]['username'] .
‘:’ . $db[$connection_name]['password'].
‘@’ . $db[$connection_name]['hostname'] .
‘/’ . $db[$connection_name]['database'] .
‘;unix_socket=/opt/lampp/var/mysql/mysql.sock’;
#41 by Haqqi on May 27th, 2010
| Quote
Thank you for the solution. This problem makes me crazy in LAMPP.
In windows xampp (that is not using unix_socket), i uploaded it to cpanel shared host (linux OS), it doesn’t overcome any problem.
One question, I haven’t try it. Does it make any problem when we upload the file in cpanel based shared host if we use this script?
#42 by Fabiano on December 19th, 2009
| Quote
PHP Error was encountered
Severity: Warning
Message: Cannot modify header information – headers already sent by (output started at /Applications/XAMPP/xamppfiles/htdocs/ci/system/application/config/autoload.php:1)
Filename: codeigniter/Common.php
Line Number: 360
An Error Was Encountered
Unable to load the requested file: plugins/doctrine_pi.php
What’s this? How I fix it?
#43 by Ale on December 20th, 2009
| Quote
Thanks dude…very great things!!!
#44 by joe on December 21st, 2009
| Quote
hi,
I was thinking about using an ORM for my projects and thank God you have done this piece. I have a question though, I followed the install just like you said copied the doctrine_pi.php and saved it in the specified folders but it gives me this error when I followed the first example you gave:
Fatal error: Uncaught exception 'Doctrine_Connection_Mysql_Exception' with message 'SQLSTATE[42S02]: Base table or view not found: 1146 Table 'inventory.user' doesn't exist' in D:\xampplite\htdocs\inventory\application\plugins\doctrine\lib\Doctrine\Connection.php:1084 Stack trace: #0 D:\xampplite\htdocs\inventory\application\plugins\doctrine\lib\Doctrine\Connection\Statement.php(253): Doctrine_Connection->rethrowException(Object(PDOException), Object(Doctrine_Connection_Statement)) #1 D:\xampplite\htdocs\inventory\application\plugins\doctrine\lib\Doctrine\Connection.php(1049): Doctrine_Connection_Statement->execute(Array) #2 D:\xampplite\htdocs\inventory\application\plugins\doctrine\lib\Doctrine\Connection.php(693): Doctrine_Connection->exec('INSERT INTO use...', Array) #3 D:\xampplite\htdocs\inventory\application\plugins\doctrine\lib\Doctrine\Connection\UnitOfWork.php(595): Doctrine_Connection->insert(Object(Doctrine_Table), Array) #4 D:\xampplite\htdocs\inventory\application\plugins\doctrine\lib\Doctrine\Connection\Unit in D:\xampplite\htdocs\inventory\application\plugins\doctrine\lib\Doctrine\Connection.php on line 108I am using xampplite 1.7.2 thanks for all the good work. will expect to hear from you soon.
#45 by Burak on December 21st, 2009
| Quote
It says the table “inventory.user” does not exist. You need to create it first, as described in the article.
#46 by joe on December 21st, 2009
| Quote
you know what I am sooooo sorry for this. I missed an ’s’ at the end of user. when I got your reply was when i noticed the missing s. I am so sorry.
Cheers
#47 by Tim Reynolds on December 26th, 2009
| Quote
This is a great tutorial. Have never heard of doctrine before, but I definitely intend on following these tuts.
It might be a nice idea to move the application folder outside the systems folder to allow CI to be easily updated. I would also change the name of the application and systems folder for security.
#48 by lechuzo on December 27th, 2009
| Quote
Hi to everyone.
I have this error when I’m trying to run the Day1 tutorial.
I’m working on XP and I have Appserv 2.5.9 with PHP Version 5.2.3, phpMyAdmin Version 2.10.2 and mysql Version 5.0.45-community-nt-log
Could you have an ida about this message? I will really appreciate your help. (Sorry about my English)
Fatal error: Uncaught exception ‘Doctrine_Transaction_Exception’ with message ‘Rollback failed. There is no active transaction.’ in C:\AppServ\www\ci_doctrine_day1\system\application\plugins\doctrine\lib\Doctrine\Transaction.php:319 Stack trace: #0 C:\AppServ\www\ci_doctrine_day1\system\application\plugins\doctrine\lib\Doctrine\Connection.php(1426): Doctrine_Transaction->rollback(NULL) #1 C:\AppServ\www\ci_doctrine_day1\system\application\plugins\doctrine\lib\Doctrine\Connection\UnitOfWork.php(136): Doctrine_Connection->rollback() #2 C:\AppServ\www\ci_doctrine_day1\system\application\plugins\doctrine\lib\Doctrine\Record.php(1597): Doctrine_Connection_UnitOfWork->saveGraph(Object(User)) #3 C:\AppServ\www\ci_doctrine_day1\system\application\controllers\hello.php(16): Doctrine_Record->save() #4 [internal function]: Hello->user_test() #5 C:\AppServ\www\ci_doctrine_day1\system\codeigniter\CodeIgniter.php(236): call_user_func_array(Array, Array) #6 C:\AppServ\www\ci_doctrine_day1\index.php(115): require_once(’C:\AppServ\www\… in C:\AppServ\www\ci_doctrine_day1\system\application\plugins\doctrine\lib\Doctrine\Transaction.php on line 319
#49 by Burak on December 27th, 2009
| Quote
Look at my comment here about Appserv: http://www.phpandstuff.com/articles/codeigniter-doctrine-scratch-day-4-user-login/comment-page-1#comment-303
See if that solves your issue.
#50 by lechuzo on December 29th, 2009
| Quote
Thanks a lot!!! I’m sorry about my hurry. When I read this link everything went right. I’m still learning with your tutorial.
Pingback: Чуть более 20 хороших советов по MySQL (часть 2) » Пара слов о программировании
#51 by Максим on December 31st, 2009
| Quote
Занятная статья, да и сам сайт я смотрю очень даже не плох. Попал сюда по поиску из Гугла, занес в закладки
#52 by Naim on January 2nd, 2010
| Quote
Would you be soo Kind to show us how to install Doctrine with Kohana please. If you have used at all?
Thanks
#53 by Кирилл Александров on January 5th, 2010
| Quote
Действительно интересно написанно, я наверное бы так не смог.
Pingback: CodeIgniter Clan Site – Part 1 | PHP Tutorials
#54 by Blue on January 19th, 2010
| Quote
hi All,
I’m a very newby for CodeIgniter. Now, I’m trying to do Web Application Project using Codeigniter. I’ve tried to follow Day 1 – Install and Setup. I faced the problem below:
Fatal error: Uncaught exception ‘Doctrine_Connection_Exception’ with message ‘Couldn’t locate driver named mssql’ in C:\AppServ\www\ci\system\plugins\doctrine\lib\Doctrine\Connection.php:486 Stack trace: #0 C:\AppServ\www\ci\system\plugins\doctrine\lib\Doctrine\Connection\UnitOfWork.php(54): Doctrine_Connection->connect() #1 C:\AppServ\www\ci\system\plugins\doctrine\lib\Doctrine\Record.php(1691): Doctrine_Connection_UnitOfWork->saveGraph(Object(Users)) #2 C:\AppServ\www\ci\system\application\controllers\hello.php(17): Doctrine_Record->save() #3 [internal function]: Hello->user_test() #4 C:\AppServ\www\ci\system\codeigniter\CodeIgniter.php(232): call_user_func_array(Array, Array) #5 C:\AppServ\www\ci\index.php(115): require_once(’C:\AppServ\www\…’) #6 {main} thrown in C:\AppServ\www\ci\system\plugins\doctrine\lib\Doctrine\Connection.php on line 486
I use :
- Apache Web Server version 2.2.8
- PHP Script Language version 5.2.6
- Microsoft SQL server
Could you please help me solve this problem?
Thank you very much. ^^
#55 by Burak on January 20th, 2010
| Quote
You need to make sure the MsSQL driver is enabled with PDO.
#56 by Daryl Wood on March 23rd, 2010
| Quote
I have a similar connection problem with MySQL.
Fatal error: Uncaught exception ‘Doctrine_Connection_Exception’ with message ‘Couldn’t locate driver named mysql’ in C:\inetpub\wwwroot\ci_doctrine_day1\system\application\plugins\doctrine\lib\Doctrine\Connection.php:486 Stack trace: #0 C:\inetpub\wwwroot\ci_doctrine_day1\system\application\plugins\doctrine\lib\Doctrine\Connection\Mysql.php(101): Doctrine_Connection->connect() #1 C:\inetpub\wwwroot\ci_doctrine_day1\system\application\plugins\doctrine\lib\Doctrine\Connection\UnitOfWork.php(54): Doctrine_Connection_Mysql->connect() #2 C:\inetpub\wwwroot\ci_doctrine_day1\system\application\plugins\doctrine\lib\Doctrine\Record.php(1691): Doctrine_Connection_UnitOfWork->saveGraph(Object(User)) #3 C:\inetpub\wwwroot\ci_doctrine_day1\system\application\controllers\hello.php(17): Doctrine_Record->save() #4 [internal function]: Hello->user_test() #5 C:\inetpub\wwwroot\ci_doctrine_day1\system\codeigniter\CodeIgniter.php(236): call_user_func_array(Array, Array) #6 C:\inetpub\wwwroot\ci_doctrine_day1\index.php(115): require_once(’C:\ in C:\inetpub\wwwroot\ci_doctrine_day1\system\application\plugins\doctrine\lib\Doctrine\Connection.php on line 486
How do I make sure the MySQL driver is enabled?
Thanks for time it took you to produce the tutorial.
#57 by Burak on March 23rd, 2010
| Quote
This line in your php.ini file:
extension=php_pdo_mysql.dll
#58 by Asakurayoh on January 19th, 2010
| Quote
Hi.
I just can get this work. I use Doctrine 1.2 and the autoload doesn’t seem to work.
(Don’t find my Model, and if I include the model (with include), it doesn’t find Doctrine_Record……..)
Do you have an idea how to do?
I’m on Wampserver on Windows XP.
Thanks.
#59 by Burak on January 20th, 2010
| Quote
I am not sure. Try downloading the zip file provided at the beginning of the article.
#60 by Joakim Kejser on January 20th, 2010
| Quote
Hi Burak.
I really like the combination of codeigniter and doctrine, thank you very much for the article. It’s by far the slickest implementation of doctrine in codeigniter i’ve seen.
I just have a single question, why bother loading the CI models library from the doctrine plugin?
#61 by Burak on January 20th, 2010
| Quote
When I had a model that was extending the CI Model class, i was getting errors. Some people might be using both CI Model’s and Doctrine Model’s at the same time, that’s why I included that.
Later I found a way around it actually. Just need to add one more Doctrine autoloader just for models (which is actually lacking from the official documentation for some reason), and set the loading to conservative (it’s aggressive by default so it loads all models).
#62 by Patrick Fraley on January 23rd, 2010
| Quote
Moin Burak,
Is it also possible to install the doctrine into the system/plugins folder? I have my server setup to have a single CodeIgniter installation to be used by multiple virtual hosts/applications and I would like to have doctrine available in all those apps without having an installation of doctrine in all of them (hard to maintain)?
#63 by Patrick Fraley on January 23rd, 2010
| Quote
Sorry I noticed someone did that already, made the changes to the doctrine_ci.php (line 5 changed APPPATH to BASEPATH). Will test later if it still works
thanx for posting these cool tutorials
#64 by jävi on January 26th, 2010
| Quote
Hi Burak,
Firstly, really great tutorial, thank you!.
Just one question. What about generation the models from the DB with Doctrine? I mean this:
Doctrine_Core::generateModelsFromDb(’models’, array(’doctrine’), array(’generateTableClasses’ => true));
I tried to do it but nothings happens, no errors and no models anywhere.
Can you figure out why?
Thank you!
#65 by Burak on January 29th, 2010
| Quote
The first parameter should be the path to the models folder, which should be this:
APPPATH.’/models’
and the folder should probably be writable too
but I don’t understand why it didn’t give you an error.
#66 by San on March 23rd, 2010
| Quote
Hi,
I generated the model as follows.
1. Create a file called PHH file (doctrine_bootsrap.php) in the CodeIgniter root folder.
2.
require_once(dirname(__FILE__) . ‘/system/plugins/Doctrine/lib/Doctrine.php’);
spl_autoload_register(array(’Doctrine’, ‘autoload’));
Doctrine_Manager::connection(’mysql://root:toor@localhost/ci_doctrine’);
Doctrine::generateModelsFromDb(dirname(__FILE__) . ‘/application/models’);
Add these code to that page (modify the path if required.)
3. execute the created file by url as follows
http://yoursitename.com/doctrine_bootsrap.php
It will generate the model classes.
San.
#67 by swapnil on January 27th, 2010
| Quote
tanx dude for the step by step illustrations…wonderful article…tanx a ton…!!!
#68 by a.k.d. on January 31st, 2010
| Quote
thanks for your great tutorial !!
helped me a lot
however, in case using Doctrine 1.2, our plug-in must have
spl_autoload_register(array(’Doctrine’, ‘modelsAutoload’));
Otherwise models would not be auto-loaded, end up to ‘Class not found’ error.
Bottom entry of
http://www.doctrine-project.org/upgrade/1_2
“Models Autoloading”
seems to be it.
Unfortunately, this is not mentioned in official 1.2 documentation and I’ve spent almost 2 days.
(esp. http://www.doctrine-project.org/documentation/manual/1_2/en/introduction-to-models#autoloading-models)
hope this helps.
//
#69 by Burak on February 2nd, 2010
| Quote
I found out about this later too. But in the plugin file in this article, there is a call to the loadModels function, which will load all the model files, so you won’t get that class not found error.
You need to register modelsAutoload only when using conservative loading.
Also I found out that it doesn’t work very well when you have base classes, table classes etc.. in sub folders. The best solution might be writing a custom autoloader in that case, which is not difficult.
#70 by a.k.d. on February 3rd, 2010
| Quote
thanks for your reply.
well, let me explain what happend in my case.
I’m generating my models by invoking Doctrine_Cli, which seems to be convenient way to get model classes from YAML, without writing code
It generates model classes under APP_PATH/models and base classes under APP_PATH/models/generated.
e.g. APP_PATH/models/SimpleModel and APP_PATH/models/generated/BaseSimpleModel.
this means that generated/BaseSimpleModel.php must be loaded before loading SimpleModel.php.
However, Doctrine ‘require_once’ in aggressive mode, I get
–
Fatal error: Class ‘BaseSimpleModel’ not found in APP_PATH/models/SimpleModel.php on line 13
–
In this article, model is directly derived from Doctrine_Record and base class dependency doesn’t matter.
conservative mode and ‘modelsAutoload’ solved my problem, at least for me.
hope this helps.
thanks.
//
#71 by fpbosch on February 6th, 2010
| Quote
It drives me crazy. I tried It but I still have the same error I don’t know what can I do ? it doesn’t load my models. can you post your code of the doctrine_pi.php
#72 by a.k.d. on February 6th, 2010
| Quote
Hi.
fpbosch:
Are you using models generated by Doctrine 1.2.x in aggressive mode?
Have you tried modelsAutolod in conservative mode?
What error do you see?
Burak:
may I post whole 65 lines of modified doctrine_pi.php here for fpbosch?
thanks.
//
#73 by fpbosch on February 7th, 2010
| Quote
is it different generate models from aggressive or conservative ? I thought it was only different in the way of load it. In my doctrine_tools I created this function
public function create_models() {
Doctrine::generateModelsFromDb(APPPATH.’models’);
}
The problem is that when I call a class it doesn’t found it e.g:
Fatal error: Class ‘BaseLyProvinces’ not found in /var/www/lybica/application/models/LyProvinces.php on line 13
I don’t how to use modelsAutoload I tried this
spl_autoload_register(array(’Doctrine’, ‘modelsAutoload’));
// we load our database connections into Doctrine_Manager
// this loop allows us to use multiple connections later on
foreach ($db as $connection_name => $db_values) {
// first we must convert to dsn format
$dsn = $db[$connection_name]['dbdriver'] .
‘://’ . $db[$connection_name]['username'] .
‘:’ . $db[$connection_name]['password'].
‘@’ . $db[$connection_name]['hostname'] .
‘/’ . $db[$connection_name]['database'];
Doctrine_Manager::connection($dsn,$connection_name);
}
But then I get this error:
Fatal error: Class ‘Doctrine_Manager’ not found in /var/www/lybica/application/plugins/doctrine_pi.php on line 24
I would like to see you code
Thank you a lot
#74 by fpbosch on February 7th, 2010
| Quote
ooops I’ve got it
spl_autoload_register(array(’Doctrine’, ‘autoload’));
spl_autoload_register(array(’Doctrine_Core’, ‘modelsAutoload’));
// we load our database connections into Doctrine_Manager
// this loop allows us to use multiple connections later on
foreach ($db as $connection_name => $db_values) {
// first we must convert to dsn format
$dsn = $db[$connection_name]['dbdriver'] .
‘://’ . $db[$connection_name]['username'] .
‘:’ . $db[$connection_name]['password'].
‘@’ . $db[$connection_name]['hostname'] .
‘/’ . $db[$connection_name]['database'];
Doctrine_Manager::connection($dsn,$connection_name);
}
// CodeIgniter’s Model class needs to be loaded
require_once BASEPATH.’/libraries/Model.php’;
// telling Doctrine where our models are located
Doctrine_Manager::getInstance()->setAttribute(Doctrine_Core::ATTR_MODEL_LOADING, Doctrine_Core::MODEL_LOADING_CONSERVATIVE);
Doctrine::loadModels(APPPATH.’/models’);
.
.
…
Thank you!
#75 by fpbosch on February 7th, 2010
| Quote
But now it doesn’t found the Current_User class…
Fatal error: Class ‘Current_User’ not found in /var/www/lybica/application/controllers/login.php on line 65
#76 by a.k.d. on February 8th, 2010
| Quote
Do you have Current_User.php in your APPPATH/models/ directory?
In conservative mode, Doctrine assumes that file name == class name.
i.e. You need to define Current_User class in APPPATH/models/Current_User.php, otherwise it won’t get autoloaded.
thanks.
//
#77 by Anuraag on August 28th, 2010
| Quote
I had the same problem – that the Base class was not being loaded with a fatal Error.
In my case it got fixed by adding following lines in doctrine_pi.php – before Doctrine::loadModels –
$manager = Doctrine_Manager::getInstance();
$manager->setAttribute(Doctrine_Core::ATTR_MODEL_LOADING, Doctrine_Core::MODEL_LOADING_CONSERVATIVE);
#78 by Firman Nugraha on February 2nd, 2010
| Quote
Hello Mr. Burak, I just finished reading and practicing this tuturial. I’m heavily impressed with the way of how you write the tutorial and how you create the examples.
If possible, can I translate your tutorial to my native language which is Indonesian and post it in my blog? And of course with crediting you. I believe this will help my fellow Indonesian developers who don’t have much skill in English.
#79 by Burak on February 2nd, 2010
| Quote
Yes, you may do that
#80 by Jesse Schutt on February 3rd, 2010
| Quote
Hello Burak
Thanks for walking us through this process!
I’m getting an error that I was hoping you could help with. When I load http://localhost:8888/ci_doctrine_day_1 I get the following error:
A PHP Error was encountered
Severity: Notice
Message: Undefined index: root
Filename: plugins/doctrine_pi.php
Line Number: 17
A PHP Error was encountered
Severity: Notice
Message: Undefined index: root
Filename: plugins/doctrine_pi.php
Line Number: 18
A PHP Error was encountered
Severity: Notice
Message: Undefined index: localhost
Filename: plugins/doctrine_pi.php
Line Number: 19
A PHP Error was encountered
Severity: Notice
Message: Undefined index: ci_doctrine
Filename: plugins/doctrine_pi.php
Line Number: 20
When I try to load the hello/world or the hello/user_test, I just get a blank page. Any ideas?
Thanks again!
#81 by Burak on February 6th, 2010
| Quote
I’m not sure. Something might be wrong with the $db array in your config/database.php file.
#82 by a.k.d. on February 8th, 2010
| Quote
Do you have Current_User.php in your APPPATH/models/ directory?
In conservative mode, Doctrine assumes that file name == class name.
i.e. You need to define Current_User class in APPPATH/models/Current_User.php, otherwise it won’t get autoloaded.
thanks.
//
#83 by a.k.d. on February 8th, 2010
| Quote
oops, sorry for this.
I see no ‘reply’ link to fpbosch’s replies …
//
#84 by Mark on February 11th, 2010
| Quote
So I’ve worked with Doctrine just a bit, and using their autogenerating methods, you get a the following file layout
Models
- generated (folder)
- – BaseCity.php (this extends the doctrine record class)
- city.php ( extends basecity )
All of the custom/override methods go in city.php and table definitions/relationships go into basecity.php. Curious where you would override methods add custom methods to your model. Would it be in the same model file?
#85 by Burak on February 13th, 2010
| Quote
The auto-generated city.php file is mostly blank right? I would put the custom methods there. So Basecity.php just remains for defining the table structure.
If you don’t want this separation, you can tell Doctrine to not generate base class files. There is an option for it.
#86 by Didin Wahyudin on February 14th, 2010
| Quote
i am using WAMP, when i tried your 1st tutorial, then i browse http://localhost/doctrine/index.php/hello/user_test, i getting this error:
Fatal error: Uncaught exception ‘Doctrine_Connection_Exception’ with message ‘PDO Connection Error: SQLSTATE[28000] [1045] Access denied for user ‘roor’@'localhost’ (using password: NO)’ in G:\web\doctrine\system\application\plugins\Doctrine\lib\Doctrine\Connection.php:474 Stack trace: #0 G:\web\doctrine\system\application\plugins\Doctrine\lib\Doctrine\Connection\Mysql.php(101): Doctrine_Connection->connect() #1 G:\web\doctrine\system\application\plugins\Doctrine\lib\Doctrine\Connection\UnitOfWork.php(54): Doctrine_Connection_Mysql->connect() #2 G:\web\doctrine\system\application\plugins\Doctrine\lib\Doctrine\Record.php(1691): Doctrine_Connection_UnitOfWork->saveGraph(Object(User)) #3 G:\web\doctrine\system\application\controllers\hello.php(17): Doctrine_Record->save() #4 [internal function]: Hello->user_test() #5 G:\web\doctrine\system\codeigniter\CodeIgniter.php(236): call_user_func_array(Array, Array) #6 G:\web\doctrine\index.php(115): require_once(’G:\web\doctrine…’) #7 {main} thrown in G:\web\doctrine\system\application\plugins\Doctrine\lib\Doctrine\Connection.php on line 474
how to resolve this problem. Sorry, bad english.
#87 by Burak on February 15th, 2010
| Quote
Did you put “roor” for the database username instead of “root” ?
#88 by Didin Wahyudin on February 16th, 2010
| Quote
oo.. i see, thank you. Sorry for my idiot.
#89 by Dirk Franssen on February 16th, 2010
| Quote
Great series!
I have a doctrine class A extends B.
But I get a Fatal error: Class ‘B’ not found in … A.php
How to make sure B is also autoloaded while A gets autoloaded?
Thanks in advance
#90 by Dirk Franssen on February 16th, 2010
| Quote
Found it. These changes are working for me:
spl_autoload_register(array(’Doctrine’, ‘autoload’));
spl_autoload_register(array(’Doctrine’, ‘modelsAutoload’));
Doctrine_Core::setModelsDirectory(APPPATH.’/models’); //instead of loadModels
Doctrine_Manager::getInstance()->setAttribute(’model_loading’, ‘aggressive’);
#91 by Ned on February 16th, 2010
| Quote
Hi,
i have a problem.
In page :
http://localhost/ci_doctrine_day1/index.php/hello/world
i get a message:
Unable to load the requested file: plugins/doctrine_pi.php
What can i solve this problem?
Thanks in advance.
#92 by Habib BULUT on February 18th, 2010
| Quote
Burak ellerine saglik kardesim :] cok kaliteli bir dokuman
Pingback: CodeIgniter- Doctrine ORM Tutorial: A way of enhancing CI | TheUnical Technologies Blog
#93 by zeeshaan on March 9th, 2010
| Quote
Fatal error: Uncaught exception ‘Doctrine_Connection_Mysql_Exception’ with message ‘SQLSTATE[42S02]: Base table or view not found: 1146 Table ‘ci_doctrine.user_model’ doesn’t exist’ in C:\xampp\htdocs\system\application\plugins\doctrine\lib\Doctrine\Connection.php:1082 Stack trace: #0 C:\xampp\htdocs\system\application\plugins\doctrine\lib\Doctrine\Connection\Statement.php(269): Doctrine_Connection->rethrowException(Object(PDOException), Object(Doctrine_Connection_Statement)) #1 C:\xampp\htdocs\system\application\plugins\doctrine\lib\Doctrine\Connection.php(1042): Doctrine_Connection_Statement->execute(Array) #2 C:\xampp\htdocs\system\application\plugins\doctrine\lib\Doctrine\Connection.php(687): Doctrine_Connection->exec(’INSERT INTO use…’, Array) #3 C:\xampp\htdocs\system\application\plugins\doctrine\lib\Doctrine\Connection\UnitOfWork.php(631): Doctrine_Connection->insert(Object(Doctrine_Table), Array) #4 C:\xampp\htdocs\system\application\plugins\doctrine\lib\Doctrine\Connection\UnitOfWork.php(562): Doctrine_Connecti in C:\xampp\htdocs\system\application\plugins\doctrine\lib\Doctrine\Connection.php on line 1082 –
error -pls help
#94 by zeeshaan on March 10th, 2010
| Quote
ok.. my model name was diff from my table name … so just added “$this->setTableName(’user’); ” .. SOLVED!
#95 by papse on March 17th, 2010
| Quote
Thanks very , very , very ………. for this titorial
You are save my life
the world is running with your help
Also thanks very much !!!!!!!!!!!!!!!
#96 by papse on March 19th, 2010
| Quote
Hello everybody, I start by thank you for this tutorial
I have a question
If my table has a varchar type as a primary key ; how I define my model et how I configure my doctrine_pi.php file ?
my table is like this
create table Employee
(
idoperateur varchar(254) not null,
name varchar(254),
firstname varchar(254),
speciality varchar(254),
levelaccess int,
primary key (idoperateur)
);
Also thanks for any answer
excuse me for my english
#97 by keded on March 30th, 2010
| Quote
I am Having a similar problem.
I have an existing (mysql) database which I am trying to connect to, however I notice that the doctrine_pi.php creates a integer primary key which I commented out.
However it generates an error because the Doctrine “UnitOfWork.php” is looking for some ID field
This is my second day at CodeIgniter and Doctrine… So this is all new to me, but your tutorial thus far really serves as a great introduction
#98 by San on March 23rd, 2010
| Quote
Type your comment here
#99 by Gaurav on March 23rd, 2010
| Quote
Hello all,
I am a problem when i migrated my ci and doctrine stuff from localhost(on xampp running php5.3) to a server running 5.2. I made appropriate changes to database settings and base url and can see that the controller and views are loading. However, i am unable to save rows into tables that represent the models.. I have exported my entire database from localhost but still cant see inserts….have tried everything but cant get it to work it just hangs before the save() function call to insert records.
Any help us appreciated.
#100 by Daryl Wood on March 24th, 2010
| Quote
Hello Burak,
I followed your instruction to put this “extension=php_pdo_mysql.dll” into my php.ini file, and it didn’t help with the following error:
Fatal error: Uncaught exception ‘Doctrine_Connection_Exception’ with message ‘Couldn’t locate driver named mysql’ in C:\inetpub\wwwroot\ci_doctrine_day1\system\application\plugins\doctrine\lib\Doctrine\Connection.php:486 Stack trace: #0 C:\inetpub\wwwroot\ci_doctrine_day1\system\application\plugins\doctrine\lib\Doctrine\Connection\Mysql.php(101): Doctrine_Connection->connect() #1 C:\inetpub\wwwroot\ci_doctrine_day1\system\application\plugins\doctrine\lib\Doctrine\Connection\UnitOfWork.php(54): Doctrine_Connection_Mysql->connect() #2 C:\inetpub\wwwroot\ci_doctrine_day1\system\application\plugins\doctrine\lib\Doctrine\Record.php(1691): Doctrine_Connection_UnitOfWork->saveGraph(Object(User)) #3 C:\inetpub\wwwroot\ci_doctrine_day1\system\application\controllers\hello.php(17): Doctrine_Record->save() #4 [internal function]: Hello->user_test() #5 C:\inetpub\wwwroot\ci_doctrine_day1\system\codeigniter\CodeIgniter.php(236): call_user_func_array(Array, Array) #6 C:\inetpub\wwwroot\ci_doctrine_day1\index.php(115): require_once(’C:\ in C:\inetpub\wwwroot\ci_doctrine_day1\system\application\plugins\doctrine\lib\Doctrine\Connection.php on line 486
Any other ideas I might try?
#101 by Burak on March 24th, 2010
| Quote
Did you restart your web server after you made that change?
I can’t think of anything else. The error just says you don’t have the mysql driver enabled, and Doctrine uses PDO.
Pingback: CodeIgniter und Doctrine « Blog von Christian Fritsch
#102 by David on April 1st, 2010
| Quote
Hi
for conservative mode, add in doctrine_pi.php
// Conservative mode
Doctrine_Manager::getInstance()->setAttribute(’model_loading’, Doctrine::MODEL_LOADING_CONSERVATIVE);
Doctrine_Manager::getInstance()->setAttribute(Doctrine::ATTR_AUTOLOAD_TABLE_CLASSES, TRUE);
before :
// telling Doctrine where our models are located
Doctrine::loadModels(APPPATH.’/models’);
Doc. say : Conservative model loading is recommended in most cases, specifically for production
environments as you do not want to require every single model class even when it is not
needed as this is unnecessary overhead. You only want to require it when it is needed.
#103 by David on April 1st, 2010
| Quote
Forgot to say : thank you
#104 by Stephen on April 6th, 2010
| Quote
I am new to CodeIgnitor, I followed following steps as mentioned in this tutor
a) Downloaded CodeIgnitor 1.7.2
b) copied it to C:\Inetpub\wwwroot\ci_doctrine_day1.
c) I am able to see welcome page when l Launch in IE
http://localhost/ci_doctrine_day1/
d) Created a new php file hello.php under controller directory of application folder.
e) Created a class called Hello and function called world
as mentioned in i wrote echo statement to print hello codeignitor.
f) Launching following path http://localhost/ci_doctrine_day1/index.php/hello/world
Throw The page cannot be found HTTP 404 – File not found error.
Please let me know what I am missing here.
I have PHP 5 in my machine.
#105 by Stephen on April 6th, 2010
| Quote
http://localhost/ci_doctrine_day1/index.php?hello/world
adding ? after index.php instead of / solved my problem. But can someone expalain me why I need to put ? Is there a way to avoid it.
#106 by fleacool on April 16th, 2010
| Quote
Hi bro..
I trying this tutorials in localhost and I got errors
A PHP Error was encountered
Severity: Notice
Message: Undefined variable: dsn
Filename: plugins/doctrine_pi.php
Line Number: 24
please help me for fix this problem
thanks b4
#107 by Anthony on April 19th, 2010
| Quote
Thanks for the tutorials. They are very helpful.
Unfortunately, I am getting this error message: Fatal error: Class ‘User’ not found in C:\xampp\htdocs\ci_doctrine_day1\system\application\controller\hello.php on line 17. Line 17 is “$u = new User;”
Any idea what is causing this problem?
#108 by Anthony on April 19th, 2010
| Quote
FOUND CAUSE OF ERROR:
Re: Fatal error: Class ‘User’ not found….
I forgot to autoload doctrine in in system/application/config/autoload.php
Works great now.
#109 by Gomby on April 20th, 2010
| Quote
Fantastic series, just continue it. More and more professional details. THX.
#110 by Spinatch on April 22nd, 2010
| Quote
Hello y’all!
For all of you out there who might want to use CI with Doctrine and an Oracle database, here’s a tip.
My Doctrine wouldn’t work with the way Burak constructed the $dsn -it would not connect/find the oracle database.
Here’s what finally worked for me:
I had to replace the code inside of the foreach in the plugin config file
foreach ($db as $connection_name => $db_values) {
$dsn = ‘oracle:dbname=SRVNAME;charset=AL328TF8′;
$adapter = new Doctrine_Adapter_Oracle($dsn, $db[$connection_name]['username'], $db[$connection_name]['password']);
Doctrine_Manager::connection($adapter, $connection_name);
}
Apparently, this works fine.
Thanks again for a great series and good luck to everyone!
S
#111 by Sean Martin on April 22nd, 2010
| Quote
Thanks for these great tutorials!
I noticed that CodeIgniter 2.0 is on the horizon and that plugins are going to be removed. http://philsturgeon.co.uk/news/2010/03/codeigniter-2
What do you think would be the best way to set up Doctrine with CI 2.0 based on that?
#112 by Burak on April 22nd, 2010
| Quote
It can be installed in any folder you want and be loaded with a custom hook. I have done that for another project.
#113 by Herbert on April 23rd, 2010
| Quote
First question is if i extract lib folder it shows lib/Doctrine/lib.php (then i rename lib.php to doctrine.php – is this correct?)
Then all steps went fine until at user_test error below:
Severity: Notice
Message: Use of undefined constant doctrine – assumed ‘doctrine’
Filename: config/autoload.php
Line Number: 66
Fatal error: Uncaught exception ‘LogicException’ with message ‘Passed array does not specify an existing static method (class ‘Doctrine’ not found)’ in C:\wamp\www\ci_doctrine_day1\system\application\plugins\doctrine_pi.php:11 Stack trace: #0 C:\wamp\www\ci_doctrine_day1\system\application\plugins\doctrine_pi.php(11): spl_autoload_register(Array) #1 C:\wamp\www\ci_doctrine_day1\system\libraries\Loader.php(466): include_once(’C:\wamp\www\ci_…’) #2 C:\wamp\www\ci_doctrine_day1\system\libraries\Loader.php(968): CI_Loader->plugin(Array) #3 C:\wamp\www\ci_doctrine_day1\system\libraries\Controller.php(83): CI_Loader->_ci_autoloader() #4 C:\wamp\www\ci_doctrine_day1\system\libraries\Controller.php(43): Controller->_ci_initialize() #5 C:\wamp\www\ci_doctrine_day1\system\codeigniter\CodeIgniter.php(201): Controller->Controller() #6 C:\wamp\www\ci_doctrine_day1\index.php(115): require_once(’C:\wamp\www\ci_…’) #7 {main} thrown in C:\wamp\www\ci_doctrine_day1\system\application\plugins\doctrine_pi.php on line 11
Pingback: Best Tutorials for Web Development » Blog Archive » CodeIgniter and Doctrine from scratch. Day 10 – Pagination
Pingback: Best Tutorials for Web Development » Blog Archive » CodeIgniter and Doctrine from scratch. Day 11 – Record Hooks
#114 by fandi rahmawan on May 5th, 2010
| Quote
Hi..
I trying this tutorials in localhost and I got errorsFatal error:
Uncaught exception ‘Doctrine_Record_UnknownPropertyException’ with message ‘Unknown record property / related component “username” on “User”‘ in C:\xampp\htdocs\ci_doctrine\system\application\plugins\doctrine\lib\Doctrine\Record\Filter\Standard.php:44
Any idea what is causing this problem?
#115 by Herbert on May 5th, 2010
| Quote
Hi Burak,
Any solution to my problem? Please see post #110 April 23rd.
#116 by endless beginning on May 11th, 2010
| Quote
Nice tutorial. I just successfully completed the day 1 tutorial and it rocks. I was having much trouble setting up the doctrine. Thanks a lot for sharing such a tutorial..
#117 by Simon Hayward on May 15th, 2010
| Quote
Hello – I’m having the same error as post #111. I have tested this and it works fine locally on MAMP, but when I upload to my Linux server, I get the same error:
Fatal error: Uncaught exception ‘Doctrine_Record_UnknownPropertyException’ with message ‘Unknown record property / related component “first_name” on “User”‘ in /blah/blah/public_html/application/plugins/doctrine/lib/Doctrine/Record/Filter/Standard.php:44 Stack trace: #0 /blah/blah/public_html/application/plugins/doctrine/lib/Doctrine/Record.php(1395): Doctrine_Record_Filter_Standard->filterSet(Object(User), ‘first_name’, ‘John’) #1 /blah/blah/public_html/application/plugins/doctrine/lib/Doctrine/Record.php(1346): Doctrine_Record->_set(’first_name’, ‘John’, true) #2 /blah/blah/public_html/application/plugins/doctrine/lib/Doctrine/Access.php(60): Doctrine_Record->set(’first_name’, ‘John’) #3 /blah/blah/public_html/application/controllers/hello.php(15): Doctrine_Access->__set(’first_name’, ‘John’) #4 /blah/blah/public_html/system/codeigniter/CodeIgniter.php(236): Hello->user_test() #5 /blah/blah/public_html/index.php(115): require_once(’/blah/blah/pub…’) #6 {main} thrown in /blah/blah/public_html/application/plugins/doctrine/lib/Doctrine/Record/Filter/Standard.php on line 44
Any ideas?
Thanks
#118 by iain on May 21st, 2010
| Quote
Hi,
Great tutorial. Maybe this will help someone though… in the doctrine_pi.php file I had to change this line (5):
require_once APPPATH.’/plugins/doctrine/lib/Doctrine.php’;
to:
require_once BASEPATH.’/plugins/doctrine/lib/Doctrine.php’;
as my plugins path was actually “/system/plugins” and not “/system/application/plugins”
Thanks Burak, good work
#119 by ren on May 26th, 2010
| Quote
nice tutorial………….
Great work
Pingback: Top 20 MySQL Best Practices
Pingback: CodeIgniter + Zend Library + Doctrine = doCEND | fclose
#120 by Tahsin Hasan on June 1st, 2010
| Quote
hi,
Great tutorial, but i want to use hmvc modular extension with doctrine in codeigniter. how can I do so?
You can find helpful topics on newdailyblog.blogspot.com.
Pingback: Integrando o CodeIgniter com o Doctrine | ASNeto
#121 by Ben on June 9th, 2010
| Quote
Hi.. this is a great tut.. but i have a problem here..
Fatal error: Uncaught exception ‘Doctrine_Record_UnknownPropertyException’ with message ‘Unknown record property / related component “save” on “User”‘ in C:\AppServ\www\ci_doctrine_day1\system\application\plugins\doctrine\lib\Doctrine\Record\Filter\Standard.php:55 Stack trace: #0 C:\AppServ\www\ci_doctrine_day1\system\application\plugins\doctrine\lib\Doctrine\Record.php(1382): Doctrine_Record_Filter_Standard->filterGet(Object(User), ’save’) #1 C:\AppServ\www\ci_doctrine_day1\system\application\plugins\doctrine\lib\Doctrine\Record.php(1337): Doctrine_Record->_get(’save’, true) #2 C:\AppServ\www\ci_doctrine_day1\system\application\plugins\doctrine\lib\Doctrine\Access.php(72): Doctrine_Record->get(’save’) #3 C:\AppServ\www\ci_doctrine_day1\system\application\controllers\hello.php(15): Doctrine_Access->__get(’save’) #4 C:\AppServ\www\ci_doctrine_day1\system\codeigniter\CodeIgniter.php(236): Hello->user_test() #5 C:\AppServ\www\ci_doctrine_day1\index.php(115): require_once(’C:\AppServ\www\…’) #6 {main} thrown in C:\AppServ\www\ci_doctrine_day1\system\application\plugins\doctrine\lib\Doctrine\Record\Filter\Standard.php on line 55
#122 by Çağdaş on June 9th, 2010
| Quote
Great work Burak!!
i have a situation with doctrine paths i think.
you know this err occured before:
Fatal error: Class ‘User’ not found in C:\Program Files\EasyPHP 3.0\www\day1\system\application\controllers\hello.php on line 12
i still coulnt get over it. any help is appreciated. thanks..
#123 by Steven on June 18th, 2010
| Quote
I had the same error and it was a stupid mistake i made.
I added
$autoload['plugin'] = array(’doctrine’);
somewhere in the beginning of the autoload file, not realising there was allready one on line 66:
$autoload['plugin'] = array(”);
that was overwriting it.
Hope this helps
#124 by fbUser on June 10th, 2010
| Quote
I’ll try to use firebird driver but error. can you help me? thx be4
#125 by Steffen on June 16th, 2010
| Quote
Hi to everyone
I got some local problems with the utf8 charset encoding in my html output.
(PHP 5.3.1, MySQL 5.1.41)
I made the following changes to the doctrine_ci.php:
$conn = Doctrine_Manager::connection($dsn,$connection_name);
$conn->setCharset(’utf8′);
$conn->setCollate(’utf8_general_ci’);
Now everything works fine for me.
Is there maybe a better solution?
Does this solution work for multiple database connections?
Cheers
Steffen
PS: Great tutorial !!
#126 by Suseno on June 20th, 2010
| Quote
hai mr. burak
i’m is problem in
Parse error: syntax error, unexpected T_OBJECT_OPERATOR in D:\AppServ\www\suse\system\plugins\doctrine_pi.php on line 35
$db_values) {
// first we must convert to dsn format
$dsn = $db[$connection_name]['dbdriver'] .
‘://’ . $db[$connection_name]['username'] .
‘:’ . $db[$connection_name]['password'].
‘@’ . $db[$connection_name]['hostname'] .
‘/’ . $db[$connection_name]['database'];
Doctrine_Manager::connection($dsn,$connection_name);
}
// CodeIgniter’s Model class needs to be loaded
require_once BASEPATH.’/libraries/Model.php’;
// telling Doctrine where our models are located
Doctrine::loadModels(APPPATH.’/models’);
// (OPTIONAL) CONFIGURATION BELOW
// this will allow us to use “mutators”
Doctrine_Manager::getInstance()->setAttribute(
Doctrine::ATTR_AUTO_ACCESSOR_OVERRIDE, true);
// this sets all table columns to notnull and unsigned (for ints) by default
Doctrine_Manager::getInstance()->setAttribute(
Doctrine::ATTR_DEFAULT_COLUMN_OPTIONS,
array(’notnull’ => true, ‘unsigned’ => true));
// set the default primary key to be named ‘id’, integer, 4 bytes
Doctrine_Manager::getInstance()->setAttribute(
Doctrine::ATTR_DEFAULT_IDENTIFIER_OPTIONS,
array(’name’ => ‘id’, ‘type’ => ‘integer’, ‘length’ => 4));
//////////////////////////////
autoload.php
/////////////////////////////
because when I change autoload.php
$autoload['plugin'] = array(’doctrine’);
#127 by Burak on June 21st, 2010
| Quote
Are you running PHP 4? This requires PHP 5.2.3+
#128 by Marcin on June 22nd, 2010
| Quote
Really great tutorial, thank you!
#129 by Steve Wanless on June 23rd, 2010
| Quote
Hi, Can you help with an error I am getting in doctrine_pi.php
Fatal error: Undefined class constant ‘ATTR_AUTO_ACCESSOR_OVERRIDE’ …
If I comment out the section below “(OPTIONAL) CONFIGURATION BELOW” it mostly works but fails when I tried to use a mutator (as I expected it would).
Otherwise it seems to be working fine for me on PHP 5.2.13
Would this be a PHP version problem? Do I specifically need 5.2.3 for all of this to work?
#130 by Vinícius on June 29th, 2010
| Quote
Hello, congratz for the great tutorial!
But it’s still not clear in my mind why doctrine is better than CI Active Record native class, what kind of limited functionalities you mean?
Thanks!
#131 by John on July 6th, 2010
| Quote
Hi Burak,
Does this work with doctrine2? Or do you have any plans to update the series if not?
Thanks!
#132 by ajaz ali on July 9th, 2010
| Quote
there should be a proper error msg displayed if we try to insert duplicate value for unique column like usernme in first practice of crash course
#133 by Dean on July 9th, 2010
| Quote
Love the tutorial! I just have one problem: Is there any possible way to get Doctrine to work with a unix socket other than going in and hacking the Doctrine files?
For example, my host requires that I connect to my databases by using this: localhost:/tmp/mysql5.sock
This causes issues with Doctrine in the Connection.php file. I’ve tried mapping out the socket in both the php.ini file and .htaccess file, but this doesn’t work. Do you have any suggestions, please?
#134 by Antonio on July 19th, 2010
| Quote
@Dean
Instead of using localhost, try:
$db['default']['hostname'] = “127.0.0.1″;
inside your database.php config file.
#135 by Faz on August 18th, 2010
| Quote
Great series Burak!, I have managed to do my own little site using CI with doctrine now, however I developed it on wamp on my local machine but need to host it on a linux red hat environment
When I transferred my project (setup as is on WAMP) to LAMP my site does not display at all. I just get a blank page
no errors showing even if I try going to different url paths, removed htaccess to elimate that as a problem still nothing displays, I get the feeling my models are not being loaded or there is no database connection being made at all?
Is there something I need to set up differently for doctrine/ci to work on linux? Also my hosting server only has PHP 5.2.13 not 5.2.3 as stated on doctrine but this doesnt seem to matter on my local machine which is using 5.2.11?
Any help/suggestions would be greately appreciated
Thanks
#136 by Faz on August 18th, 2010
| Quote
Still trying to figure out what is going wrong its seems like my project is not calling the plugins/doctrine_pi.php file at all, by simple debugging I can see the config/database.php is also not called
Can I force this somehow in Linux?
Pingback: Boozox » 20 Consejos para Mejorar tu MySQL que quizás no conocías
#137 by Oli on August 23rd, 2010
| Quote
PDO is enable and i have the following message. (I’m running on Vista)
Fatal error: Uncaught exception ‘Doctrine_Manager_Exception’ with message ‘Could not parse dsn’ in D:\wamp\www\POOL_CI\system\application\plugins\doctrine\lib\Doctrine\Manager.php:419 Stack trace: #0 D:\wamp\www\POOL_CI\system\application\plugins\doctrine\lib\Doctrine\Manager.php(434): Doctrine_Manager->_buildDsnPartsArray(’://root:@localh…’) #1 D:\wamp\www\POOL_CI\system\application\plugins\doctrine\lib\Doctrine\Manager.php(304): Doctrine_Manager->parseDsn(’://root:@localh…’) #2 D:\wamp\www\POOL_CI\system\application\plugins\doctrine\lib\Doctrine\Manager.php(266): Doctrine_Manager->openConnection(’://root:@localh…’, ‘default’) #3 D:\wamp\www\POOL_CI\system\application\plugins\doctrine_pi.php(24): Doctrine_Manager::connection(’://root:@localh…’, ‘default’) #4 D:\wamp\www\POOL_CI\system\libraries\Loader.php(466): include_once(’D:\wamp\www\POO…’) #5 D:\wamp\www\POOL_CI\system\libraries\Loader.php(968): CI_Loader->plugin(Array) #6 D:\wamp\www\POOL_CI\system\libraries\Controller.php(83): CI_Loader->_ci_autoloader() in D:\wamp\www\POOL_CI\system\application\plugins\doctrine\lib\Doctrine\Manager.php on line 419
#138 by iyas on August 27th, 2010
| Quote
Thanks Burak….i am inspired by you.. You are a good programmer and writer. It very exciting to follow your tutorial. I am not just learning CI and Doctrine but also how to write tutorial….
THANKS
#139 by Paul on August 31st, 2010
| Quote
I know I must be blind and/or stupid, but when I download Doctrine I don’t have a lib folder. I have a folder Doctrine-1.2.3 with Doctrine.php and a folder called Doctrine inside it. There’s no folder “lib” inside there.
#140 by Burak on August 31st, 2010
| Quote
Looks like things changed in the new Doctrine version. Just create the lib folder yourself, and put the Doctrine folder and Doctrine.php in it.
#141 by Paul on August 31st, 2010
| Quote
Hi Burak,
thanks for that!
I’ve just installed Doctrine in CI and created the user model and the hello controller. However, when I call it (example.com/ci/index.php/hello/world) it gives me an error:
“Message: require_once(/home/paul/Projekte/example.com/ci/system/application//plugins/doctrine/lib/Doctrine.php) [function.require-once]: failed to open stream: No such file or directory
Filename: plugins/doctrine_pi.php
Line Number: 5″
So in the file doctrine_pi.php I changed the paths that use APPPATH to:
require_once APPPATH.’config/database.php’;
(line 5) require_once APPPATH.’../plugins/doctrine/lib/Doctrine.php’;
(line
(line 31) Doctrine::loadModels(APPPATH.’models’);
Now when I call example.com/ci/index.php/hello/world it gives me no error message, only the expected “Hello CodeIgniter!”.
Then when I call example.com/ci/index.php/hello/user_test I get:
“A PHP Error was encountered
Severity: Warning
Message: PDO::__construct() [pdo.--construct]: [2002] Invalid argument (trying to connect via unix://)
Filename: Doctrine/Connection.php
Line Number: 470″
I checked and it seems it has something to do with the $dsn array in doctrine_pi.php.
So I went and gave it the MySQL info that I use for my CI project:
$dsn = $db[$connection_name]['dbdriver'] .
‘://’ . $db[$connection_name]['root'] .
‘:’ . $db[$connection_name][''].
‘@’ . $db[$connection_name]['localhost'] .
‘/’ . $db[$connection_name]['ci_linksdir'];
But then I get these errors:
“A PHP Error was encountered
Severity: Notice
Message: Undefined index: root
Filename: plugins/doctrine_pi.php
Line Number: 19
A PHP Error was encountered
Severity: Notice
Message: Undefined index:
Filename: plugins/doctrine_pi.php
Line Number: 20
A PHP Error was encountered
Severity: Notice
Message: Undefined index: localhost
Filename: plugins/doctrine_pi.php
Line Number: 21
A PHP Error was encountered
Severity: Notice
Message: Undefined index: ci_linksdir
Filename: plugins/doctrine_pi.php
Line Number: 22″
I am at my wits end lol.
#142 by Paul on September 1st, 2010
| Quote
I did what was suggested in #40 (http://www.phpandstuff.com/articles/codeigniter-doctrine-from-scratch-day-1-install-and-setup/comment-page-1#comment-658) and now the errors are gone.