Missing insert () method in Doctrine DBAL Query Builder
I feel like I have a moment where I miss something small here; I am having trouble using a method insert()
in a component QueryBuilder
in Dotrine DBAL 2.2.x / 2.3.x.
I did some investigation and here's a snippet from the QueryBuilder page from the DBAL documentation
\ Doctrine \ DBAL \ Query \ QueryBuilder supports creating SELECT, INSERT, UPDATE and DELETE queries. What type of query you build depends on the methods you are using.
Next, we explain some code examples I can just do:
$builder = $connection->createQueryBuilder();
$result = $builder
->insert('table_name')
// ...
To use Query Builder in insert mode . Except when I do this, I get a complaint from PHP:
Fatal error : Call to undefined Doctrine \ DBAL \ Query \ QueryBuilder :: insert () method
Further verification QueryBuilder.php source code
I don't see any reference to any method insert(...)
, no class inherits from it, no traits added to QueryBuilder
that the insertion mechanism can open. Also, I can see this right at the top:
/* The query types. */
const SELECT = 0;
const DELETE = 1;
const UPDATE = 2;
No insert request type; however this interesting method comment for execute()
:
/**
* Execute this query using the bound parameters and their types.
*
* Uses {@see Connection::executeQuery} for select statements and {@see Connection::executeUpdate}
* for insert, update and delete statements.
*
* @return mixed
*/
Bottom line:
This is a large-scale project with the participation of 100 maintainers, I am more likely to find my interpretation here than aversion to something so fundamental because of the numerous versions, but I cannot understand for life what I am missing, Please help me to see the obvious.
source to share
It depends on your version. Insert added since v2.5.0-BETA3.
Viz https://github.com/doctrine/dbal/blob/master/lib/Doctrine/DBAL/Query/QueryBuilder.php#L563 and commit
You can decide to update the package version or check this alternative solution
source to share