Of course, you can use place a ‘use’ statement at the top of the php file in which User will be instantiated. Then you don’t need to use the fully qualified name
<?php
use Models\User;
// snip…
$user = new User; // same thing as: new Models\UserThis is an archived forum and the content is probably no longer relevant, but is provided here for posterity.
The active forums are here.
July 04, 2010 5:39pm
Subscribe [13]#16 / Jan 04, 2011 10:53am
Of course, you can use place a ‘use’ statement at the top of the php file in which User will be instantiated. Then you don’t need to use the fully qualified name
<?php
use Models\User;
// snip…
$user = new User; // same thing as: new Models\User#17 / Jan 04, 2011 6:38pm
Thanks!
I didn’t manage to make the cli command working though, if anyone wants to help.
Cheers!
#18 / Jan 16, 2011 4:45pm
Hello ...
I need help setting up Codeigniter 2 with Doctrine 2 ..
So far I think I have most thing setup but when I try using an example
with $this->em->flush(); the app just block… I dont know I to debut it…
I have created the table with the cli the get/set with the cli also…
$user = new User;
print_r($user);
$user->setUsername(‘Eryr’);
$user->setPassword(‘secretPassw0rd’);
$this->em = $this->doctrine->em;
$this->em->persist($user);
This is where the code fail
$this->em->flush();
Thanks for any help.
#19 / Jan 16, 2011 5:07pm
Hello ...
I need help setting up Codeigniter 2 with Doctrine 2 ..
So far I think I have most thing setup but when I try using an example
with $this->em->flush(); the app just block… I dont know I to debut it…
I have created the table with the cli the get/set with the cli also…
$user = new User;
print_r($user);
$user->setUsername(‘Eryr’);
$user->setPassword(‘secretPassw0rd’);
$this->em = $this->doctrine->em;
$this->em->persist($user);
This is where the code fail
$this->em->flush();
Thanks for any help.
#20 / Feb 08, 2011 9:53pm
For those still having trouble setting up Doctrine 2 and CodeIgniter 2, take a look at the tutorial I wrote on how to integrate CodeIgniter 2 and Doctrine 2.
-Tim
#21 / Feb 16, 2011 5:21pm
tselaty’s tutorial was a great help!
I have a quick question though - how come the regular DQL queries don’t work. Am I missing a step?
Example:
$dql = “SELECT model FROM product p WHERE p.id = ?1”;
$products = $this->em->createQuery($dql)
->setMaxResults(15)
->setParameter(1, 1)
->getResult();
foreach ($products AS $product) {
echo $product->getModel() . "\n";
}
I keep getting this error: “APPPATH/libraries/Doctrine/ORM/Mapping/MappingException.ph”
#22 / Feb 16, 2011 5:40pm
OKAY! I finally got it to work. I think it was something to do with the “namespace”:
SOLUTION:
$query = $this->em->createQuery(‘SELECT p.model FROM models\product p’);
$products = $query->getResult();
foreach ($products AS $product) {
echo $product['model'] . "\n";
}
#23 / Feb 04, 2012 1:28pm
Try this setup:
Finally, an easy installer that works in 5 minutes or less.
I have read a lot of tutorials to get Doctrine and CodeIgniter together but all seems to be very complicated.
I’m wondering why CodeIgniter or Doctrine doesn’t have such integration packages on their websites?
#24 / Mar 23, 2012 12:44pm
Here’s github repo for this:
https://github.com/wildlyinaccurate/CodeIgniter-2-with-Doctrine-2