Category: sql

add new column after another column in symfony using docrine schema

Code Entity for room table. use DoctrineORMMapping as ORM; class Room { /** * @ORMId() * @ORMGeneratedValue() * @ORMColumn(type=”integer”) */ private $id; /** * @var string * * @ORMColumn(type=”string”) */ private $name; /** * @var int * * @ORMColumn(type=”integer”) */…

How can I edit the sql commands of symfony doctrine when updating a schema?

I have the following error when I’m trying to update my database schema : SQLSTATE[HY000]: General error: 1833 Cannot change column ‘IdEcole’: used in a foreign key constraint ‘appartient_ibfk_2’ of table ‘tuteure.appartient’ However, I don’t have anything that make the…

How to make a query_builder out of raw sql

I need help to change this code into a query builder in Symfony 5. $em = $this->getEntityManager(); $query = “SELECT * FROM fizuser where roles::text LIKE :role”; $statement = $em->getConnection()->prepare($query); $statement->bindValue(‘role’, ‘%’.$role.’%’); $statement->execute(); $result = $statement->fetchAll(); return $result; This is…

Symfony WHERE-SQL – “SQLSTATE[42000]: Syntax error"

I am a newbie in symfony. Whenever I type php symfony select-sql, I get the following error: public function test(Connection $connection, request $request){ $id = $request -> query->get(‘id’); $rows = $connection->fetchAll(‘SELECT * FROM question WHERE qcm_fk_id=$id’); The sql syntax is…