fightbulc / simplon_mysql

MySQL PDO Wrapper (php, mysql, pdo, crud, library)
70 stars 22 forks source link

Replace conditions with stripped conditions #21

Closed angi- closed 1 month ago

angi- commented 4 years ago

When using joins in the readQueryBuilder in the format table.column there's always an exception because both of the initial conditions and stripped conditions are passed to PDO.

This query

$readQueryBuilder = (new ReadQueryBuilder)
    ->addSelect('users.*')
    ->addSelect(profiles.nickname as user_nickname')
    ->addCondition('users.id', $userId)
    ->addInnerJoin('profiles', 'profiles', 'users.id = profiles.user_id');

will generate the following conditions:

[
    { "users.id": "35140057-a2a4-5adb-a500-46f8ed8b66a9" },
    { "usersid": "35140057-a2a4-5adb-a500-46f8ed8b66a9" }
]

which will throw an exception.