Thanks. Will make a pdo_mysql driver and report here again.
As for the prefix in Doctrine: I use an eventlistener, like in the cookbook-example in the Doctrine documentation: http://docs.doctrine-project.org/projects/doctrine-orm/en/latest/cookbook/sql-table-prefixes.html
I only changed it to replace #__ like we are used to do in Joomla This is my TablePrefix listener:
namespace Jooctrine;
use \Doctrine\ORM\Event\LoadClassMetadataEventArgs;
class TablePrefix
{
protected $prefix = '';
public function __construct($prefix)
{
$this->prefix = (string) $prefix;
}
public function loadClassMetadata(LoadClassMetadataEventArgs $eventArgs)
{
$classMetadata = $eventArgs->getClassMetadata();
$classMetadata->setTableName(str_replace('#__', $this->prefix, $classMetadata->getTableName()));
foreach ($classMetadata->getAssociationMappings() as $fieldName => $mapping) {
if ($mapping['type'] == \Doctrine\ORM\Mapping\ClassMetadataInfo::MANY_TO_MANY) {
$mappedTableName = $classMetadata->associationMappings[$fieldName]['joinTable']['name'];
$classMetadata->associationMappings[$fieldName]['joinTable']['name'] = str_replace('#__', $this->prefix, $mappedTableName);
}
}
}
}
When creating my EntityManager I have:
// Event-listener to change the #__ db-prefix into the current db-prefix
$prefix = \JFactory::getConfig()->get('dbprefix');
$evm = new EventManager;
$tablePrefix = new TablePrefix($prefix);
$evm->addEventListener(Events::loadClassMetadata, $tablePrefix);
I'll upload some code I use on https://github.com/jooctrine and write some on http://jooctrine.org/
Planned that long ago allready, but couln't find the time for it, sorry.
On Sunday, 6 April 2014 13:37:06 UTC+2, piotr_cz wrote:
I use Sqlite for testing, and it's being used in the Database tests and in Jooma CMS tests too, it's really handy.
By the way, did you manage to use Doctrine with table prefix (Joomla style)? While it works for me when creating entities and updating table schema, it doesn't when going other way around, I'm getting double-prefixed table names.
see my
DoctrineServiceProvider.
On Sunday, April 6, 2014 9:23:39 AM UTC+2, Herman Peeren wrote:
I want to extend it to a pdo-mysql driver for Joomla.
I use Doctrine ORM in Joomla. The Doctrine DBAL uses PDO. I had no problem to use their pdo_mysql driver besides the mysqli-driver the rest of the Joomla system in which my extensions run, BUT I've read some reports of it giving problems (mainly "native" mysql not operating correctly immediately after having used the pdo_mysql connection). Last year, at JAB13, some people (Nicholas from Akeeba and Matthias from Kunena) mentioned those same problems. Although I didn't encounter those problems myself in production environments, one of which is running with that double database connection for 2 and a half years now, I don't completely like the double database connection, the pdo_mysql for my extensions and mysqli for the rest of Joomla. Therefore I'm now investigating in two ways: 1. to use a pdo_mysql connection (which has greatly improved over the years and is not worse than "native" mysqli-driver anymore. It is BTW also used in Drupal). Therefore I'd have to make a pdo_mysql-driver for Joomla 2. to rewrite the Joomla CMS core components using Doctrine, not using the Joomla Database and Model classes at all. I'll present the work I've done on it at JAB14 (nice to meet you then Don):
http://jandbeyond.org/program/sessions/next-generation-joomla.htmlAnyone using Oracle or Sqlite with the Joomla Database package at the moment? As
those drivers extend from the PDO-driver. Do I understand it correctly
that although those drivers are shipped with this package, they are not
supported? Read something vague like that in the tracker.
On Saturday, 5 April 2014 23:53:28 UTC+2, Don Gilbert wrote:
Some of the other core drivers extend it, so it is being used. Do you want to refactor / improve it?