Questions tagged [doctrine-dbal]
27 questions
40
votes
3 answers
What is the difference between Database Abstraction Layer & Data Access Layer?
I am actually stuck in 3-tier structure. I surfed the internet and found two terminologies "Database Abstraction Layer" & "Data Access Layer".
What are the differences between the two?

Starx
- 77,474
- 47
- 185
- 261
22
votes
1 answer
How to fetch results into a custom object now that fetchAll() and FetchMode are deprecated?
On some existing code I have the following statement (after a rather long query building exercise):
return $statement->fetchAll(
DBAL\FetchMode::CUSTOM_OBJECT,
PublishedLead::class
);
This works (so far), but I see now that both fetchAll()…
user10844537
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
5
votes
1 answer
alternative for doctrine deprecated ping()
Doctrine\DBAL\Connection::ping()
is marked as @deprecated
I found this commit that introduced it but no info about successor for this method was given.
I would like to know what is expected alternative for this functionality.
Should I just rely on…

wormhit
- 3,687
- 37
- 46
3
votes
2 answers
Change primary key in Laravel migration with SQLite
I have the following migration:
Schema::create('items', function(Blueprint $table) {
$table->uuid('id')->primary();
// more columns ...
});
Now, we want to add an additional auto-increment column:
Schema::table('items', function(Blueprint…

shaedrich
- 5,457
- 3
- 26
- 42
2
votes
1 answer
Error: Call to undefined method Doctrine\DBAL\Schema\SqliteSchemaManager::introspectTable()
In a Laravel project after I upgraded to Laravel 10, PHPUnit 10, etc. I get this error when I try to run PHPUnit:
Error: Call to undefined method…

netdjw
- 5,419
- 21
- 88
- 162
2
votes
2 answers
Prooph Eventstore (PDO) and Doctrine DBAL results in multiple connections
Situation
I'm using Prooph for my commandbus, eventbus and eventstore within Symfony 4.3. Since not every aggregate needs to be eventsourced, we also use Doctrine DBAL to just simply CRUD those simple aggregates.
Within a given domain I have…

Christian Vermeulen
- 516
- 5
- 12
1
vote
2 answers
How is it possible to map column names from a Doctrine sql query?
I created a query with query builder like this:
$qb = $em->createQueryBuilder();
$qb->select(['u.id', 'u.name'])
->from(User::class, 'u')
->where('u.active = 1')
;
$sql = $qb->getQuery()->getSql();
The result looks like this:
SELECT…

Iter Ator
- 8,226
- 20
- 73
- 164
1
vote
1 answer
Doctrine DBAL 2.13 $statement->execute() returns bool (instead of Result)
Since the release of Doctrine DBAL 2.13 deprecations have been added as stated here.
While the old way of fetching results is something like this:
$statement->execute();
while (($row = $statement->fetch()) !== false) {
}
The new way goes like…

Select0r
- 12,234
- 11
- 45
- 68
1
vote
0 answers
Doctrine MasterSlaveConnection with empty env-vars
# doctrine.yaml
parameters:
# Adds a fallback DATABASE_URL if the env var is not set.
# This allows you to run cache:warmup even if your
# environment variables are not available yet.
# You should not need to change this value.
…

Max Schindler
- 380
- 2
- 17
1
vote
3 answers
TYPO3 QueryBuilder - how to find the most recent record for a user?
This is a really obvious data problem, but I can't find a simple solution anywhere.
Using TYPO3 QueryBuilder, how do you select the most recent entry for each user from a table that has multiple entries per user?
uid user_id value crdate
1 1 …

David Green
- 103
- 9
1
vote
1 answer
Saving Date field with doctrine
In my application I save data with doctrine to an mysql database.
for me it is totally sufficient to save the date and not also the time therefore I have chosen the Date format for my database field.
In the entity of my Symfony 4 app this looks…

Calamity Jane
- 2,189
- 5
- 36
- 68
1
vote
1 answer
Doctrine: Hydrate models from raw SQL
I have the following custom query. I know its a simple one, so it can also be used as a DQL, but I have more complex ones too. But I want to know the way, how to do it even with more complex queries.
select j.*
from `shop`.`jobs` j
-- 2 joins
where…

Zoltán Fekete
- 504
- 1
- 6
- 22
0
votes
0 answers
How to reverse migration in Laravel using Doctrine DBAL
I'm using PHP 7.3|8.0, Laravel 8.75, Doctrine DBAL 3.6 and MySQL.
I want to change the data type of a column from integer to enum. I also added custom enum type following this guide…

user16711828
- 3
- 3
0
votes
0 answers
How do close the file associated with the DBAL Adapter
I'm trying to avoid a "Too Many Files Open" error when writing to a DBAL cache.
I'm creating the connections via
$cache = new DoctrineDbalAdapter('sqlite:///' . $fullFilename);
and implementing a LRU cache, but the files appear to remain open. …

Tac Tacelosky
- 3,165
- 3
- 27
- 28