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
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
34
votes
1 answer

Object-Relational Mapping vs Database Abstraction Layer

I'm using Doctrine which provides both ORM and DBAL. What is difference between them? How should one decide when to use which?
Mohammed H
  • 6,880
  • 16
  • 81
  • 127
31
votes
2 answers

Doctrine DBAL - WHERE IN array with additional parameter

Using the example docs, I was able to get a query like this to work. SELECT f.foo, b.bar FROM Foo f LEFT JOIN Bar b WHERE f.foo = 20 AND b.bar IN ? Using DBAL, this code returns results. $result = $this->connection->executeQuery( …
Zoot
  • 2,217
  • 4
  • 29
  • 47
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
18
votes
6 answers

Doctrine DBAL 2: fetchAll() unnecessary array dimensions

In doctrine DBAL2 when I execute a query like this: getDatabaseConnection(); $sql = "SELECT page_url FROM cms_user_page WHERE site_id = :siteid AND active = '1' "; $stmt =…
mmmmm
  • 595
  • 2
  • 5
  • 20
17
votes
2 answers

Doctrine DBAL setParameter() with array value

I'm using doctrine DBAL and have some problem with SQL query as result of a queryBuilder. $builder = $this->getConnection()->getQueryBuilder(); $builder->select(['id','name','type']) ->from('table') ->where('id='.(int)$value) …
Sergey Nikolaev
  • 685
  • 1
  • 6
  • 16
16
votes
12 answers

Symfony 2 SQLSTATE[HY000] [2002] Connection refused Error

I get an error like database operations using Symfony2. SQLSTATE[HY000] [2002] Connection refused parameters.yml parameters: database_driver: pdo_mysql database_host: 127.0.0.1 database_port: '8889' database_name: symfony database_user:…
kemal
  • 371
  • 2
  • 4
  • 14
14
votes
1 answer

using insert() method to insert DateTime value with PHP Doctrine\DBAL 2

How can i pass PHP's DateTime object as a value for database field using Doctrine\DBAL? $DB is a Doctrine\DBAL\Connection instance. $DB->insert('table_name', [ 'field' => new \DateTime(), ]); // Catchable fatal error: Object of class DateTime…
Slava Fomin II
  • 26,865
  • 29
  • 124
  • 202
11
votes
3 answers

Symfony / Doctrine UnitTests with SQLite memory DB

I'm still working on PHP unit tests for testing my symfony2 controllers. My test classes are derivations of WebTestCase and the tests are doing GET or POST requests do check if everything works fine. I want to test all underlying layers, but I don't…
Hennes
  • 1,340
  • 1
  • 10
  • 26
10
votes
2 answers

Doctrine custom data type

I'm developing application with Symfony2. Symfony2 is using Doctrine 2 for DBAL and ORM. As far as I know Doctrine2 doesn't have suport for BLOB data type. However I want to implement BLOB support through the custom data type…
Websirnik
  • 1,372
  • 3
  • 21
  • 35
10
votes
3 answers

Symfony2 / Doctrine make $statement->execute() not "buffer" all values

I've got a basic codeset like this (inside a controller): $sql = 'select * from someLargeTable limit 1000'; $em = $this->getDoctrine()->getManager(); $conn = $em->getConnection(); $statement = $conn->prepare($sql); $statement->execute(); My…
Sarel
  • 1,210
  • 2
  • 15
  • 23
9
votes
1 answer

Is it possible to build INSERT INTO SELECT query with Doctrine QueryBuilder?

I have some Criteria and need to create INSERT query based on SELECT with that Criteria. Query should be like this: INSERT INTO mytable (field1, field2) SELECT f1, f2 FROM mytable2 JOIN mytable3 ON mytable3.field3 = mytable2.field2 WHERE…
Nick
  • 9,735
  • 7
  • 59
  • 89
8
votes
2 answers

Doctrine schema update always try to add NOT NULL

I have a fresh Symfony 2.8 installation, with doctrine and MySQL 5.6 stack. After executing a doctrine:schema:update --force, i can see Database schema updated successfully! "x" queries were executed Here is my problem : Even if i execute it…
j-guyon
  • 1,822
  • 1
  • 19
  • 31
8
votes
7 answers

Symfony : how to set SSL parameters in Doctrine DBAL configuration (YAML)?

I'd like to add my SSL cert and key files to Doctrine DBAL configuration but I don't see how to achieve that. In PHP, I just have to write something like : $databaseHandler = new \PDO( 'mysql:host=my_host;dbname=my_db', 'username', …
Ivan Gabriele
  • 6,433
  • 5
  • 39
  • 60
8
votes
1 answer

Doctrine 2 DBAL expressions in update or insert methods

I like the convenience methods for data manipulation queries $conn->insert() and $conn->update() in doctrine 2 DBAL because insert/update values can be held an passed as associative array. But how can i pass a NULL value, a MySQL function or other…
Mario A
  • 3,286
  • 1
  • 17
  • 22
1
2 3
17 18