Questions tagged [dbal]

Database Abstraction Layer for Doctrine ORM (PHP)

Database abstraction layer with many features for database schema introspection, schema management and PDO abstraction.

261 questions
7
votes
1 answer

Incorrect mapping of mysql tinyint(2) as boolean with doctrine

I reverse engineered my database with symfony2 and doctrine with commands : php app/console doctrine:mapping:convert php app/console doctrine:mapping:import php app/console doctrine:generate:entities But my field was mapped as boolean instead of…
Mohammed H
  • 6,880
  • 16
  • 81
  • 127
6
votes
2 answers

Need a simple ORM or DBAL for existing PHP app

I am working on extending an existing PHP application. Unfortunately for me, the existing app is a mess. It's all spaghetti code with raw mysql_* calls. Groan. No way that I am going to do that in the parts that I am extending. So, I am looking for…
Sander Marechal
  • 22,978
  • 13
  • 65
  • 96
6
votes
5 answers

Autowire specific DBAL connection when using multiple of them

I'm using Doctrine 2 where I have multiple connections for DBAL. I have also multiple EntityManagers in ORM. I need to be able to somehow autowire specific DBAL connection into other Symfony 3 services. I can autowire any EntitiyManager using…
simPod
  • 11,498
  • 17
  • 86
  • 139
6
votes
1 answer

Reusing QueryBuilder in Doctrine DBAL

The following example shows some extract of an code example. Invoking the QueryBuilder of Doctrine DBAL is done twice there - once for executing a SELECT(*) statement and prior to that executing a COUNT(*) statement. Common settings like table,…
Oliver Hader
  • 4,093
  • 1
  • 25
  • 47
6
votes
2 answers

Doctrine: ORM QueryBuilder or DBAL QueryBuilder

DBAL Query Builder: http://www.doctrine-project.org/api/dbal/2.3/class-Doctrine.DBAL.Query.QueryBuilder.html ORM Query Builder: http://www.doctrine-project.org/api/orm/2.3/class-Doctrine.ORM.QueryBuilder.html Inside Doctrine there is 2 QueryBuilder…
thesearentthedroids
  • 588
  • 1
  • 7
  • 24
6
votes
1 answer

Doctrine (DBAL) Error Handling while Executing Multiple Queries

I have a schema sql file (with syntax error) including multiple queries for settings database example.sql CREATE TABLE IF NOT EXISTS `example` ( `id` int(11) NOT NULL AUTO_INCREMENT, `name` text COLLATE utf8_unicode_ci NOT NULL, PRIMARY KEY…
Murat SAÇ
  • 396
  • 1
  • 3
  • 13
6
votes
2 answers

Unrecognized option "mapping_types" by multiple connections

I'm trying to add the "enum" type to my symfony2 dbal connection, but I can't find a way to do it. doctrine: dbal: mapping_types: enum: string default_connection: default connections: default: …
KhorneHoly
  • 4,666
  • 6
  • 43
  • 75
6
votes
1 answer

What does Doctrine's Database Abstraction Layer offer over simple PDO?

What do I gain if I use Doctrine's Database Abstraction Layer (DBAL) over simple PDO? Isn't PDO supposed to be an abstraction layer itself? As far as I can tell, the only benefit I gain is the ability to use Oracle's oci8 driver with a PDO-like API.…
cesarv
  • 87
  • 6
6
votes
1 answer

Symfony 2 Console command for creating custom Database

I am working on a Symfony 2 project where each user have his own database. In my config.yml file I have a doctrine:dbal:orm set for a client but no connection properties because they are set at runtime and referenced by all users. I.e I only have…
5
votes
1 answer

Expression created by DBAL query builder for IN clause doesn't set in values as strings?

I have this simple example: $names = ['a', 'b']; $query = $dbConnection->createQueryBuilder(); $query->select('*') ->from('foo') ->where($query->expr()->in('name', $names)); print $query->getSQL(); outputs SELECT * FROM foo WHERE name…
baa2w
  • 314
  • 2
  • 11
5
votes
2 answers

DBAL cardinality violation error

I am getting the 'Cardinality Violation' error, for the following SQL: Doctrine\DBAL\Exception\DriverException: An exception occurred while executing SELECT p.* FROM mod_products_products p LEFT JOIN mod_products_products_categories c_link ON…
Meep3D
  • 3,803
  • 4
  • 36
  • 55
5
votes
1 answer

Can Doctrine DBAL be mixed with ORM Query Builder?

I am trying to create a querybuilder using ORM. But I stumble upon a field on an entity with a relationship to 2 possible tables. With this structure it would be (IMHO) impossible to map it in the entity itself. ╔═══════╗ ╔═══════╗ …
rrw
  • 671
  • 7
  • 18
5
votes
2 answers

Deleting multiple rows at once with Doctrine DBAL, is it possible?

First of all, I just want to mention that this is not an "issue" at all. Deleting with Doctrine DBAL is not a problem and I am able to do it. What I actually wanted to know is if there is way to delete multiple rows at once without have to loop for…
bzin
  • 1,921
  • 2
  • 14
  • 15
5
votes
1 answer

Retrieving boolean values with Doctrine's DBAL in Symfony

I'm using DBAL in a Symfony project to access data in a Mysql database. When querying tables with boolean fields (created as tinyint) I get tinyint values in PHP but I would like to get booleans. Somehow, I'd like to get the same mapping as using…
Dmt
  • 193
  • 1
  • 10
5
votes
1 answer

DBAL Symfony 2 SQL Statements

I'm currently playing around with symfony and DBAL to collect data from an external database. $conn = $this->get('database_connection'); $users = $conn->fetchAll('SELECT * FROM cms_clients'); print_r($users); The code…
Brent
  • 2,385
  • 10
  • 39
  • 63
1
2
3
17 18