I’m using Doctrine DBAL.
Everything worked fine until I put a function as a Where value.
Here is my code I’m talking about.
private QueryBuilder $query;
private string $tablename = 't_members';
private string $viewname = 'v_members';
private string $tablealias = 'm';
public function __construct(private Connection $connection) {
$this->query = $this->connection->createQueryBuilder();
}
//get all members of organization
function getAllByOrganization(): array {
// TODO change to variable organization
$qry = $this->query
->select('*')#'id', 'nickname')
->from($this->viewname)
->where('org_id = :organization')
->setParameter('organization', AuthMember::getOrganization())
->getSQL();
die($qry);
}
The SQL Statement of the function looks like this: SELECT * FROM t_members, v_members WHERE org_id = :organization
I don’t understand, why the plain tablename is used. I want to use the view, wich I added to the from statement.
Can someone tell my where my problem is?
Thank you
I tried the table alias parameter, but the t_members is still in use.
I tried to use no parameters at all, but this returned an error.
jevylein is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.