You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
1 - Prefix the name of the table that is inside the connection model (JOIN) together with the where conditions, when the table and column are not referenced together.
Também seria legal as junçõe join, terem por padrão um alias ( AS ) com o nome do metodo de jução no model, ao ivéns de apenas o nome da tabela
SELECT my_schema.users.* FROM my_schema.users JOIN my_schema.posts ON my_schema.posts.user_id = my_schema.user.id AND my_schema.posts.approved = 1 AND my_schema.posts.status = 2 AND my_schema.posts.deleted IS NULL
This makes it easier to avoid having to cite the table name in each where statement of the connection.
This avoids conflicts when 2 tables have one or more columns with the same name.
2 - Add the behavior of ( joinRelationship ) equal to ( joinRelationshipUsingAlias ), but with the following behavior:
A: In joinRelationship, if there are 2 parameters, the first is the relationship and the second is the anonymous function containing the WHERE clause.
B: In joinRelationship, if there are 3 parameters, the first is the relationship, the second is an alias to be assigned to the relationship, and the third is the anonymous function containing the WHERE clause.
SELECT my_schema.users.* FROM my_schema.users JOIN my_schema.posts as test ON test.user_id = my_schema.user.id AND test.approved = 1 AND test.status = 2 AND test.deleted IS NULL
This helps in the flexibility of handling the join connection.
The text was updated successfully, but these errors were encountered:
1 - Prefix the name of the table that is inside the connection model (JOIN) together with the where conditions, when the table and column are not referenced together.
Também seria legal as junçõe join, terem por padrão um alias ( AS ) com o nome do metodo de jução no model, ao ivéns de apenas o nome da tabela
My Current Query Example:
User::joinRelationship('posts', fn ($join) => $join->where(' my_schema.posts.approved', true)->where(' my_schema.posts.status', 2)->where(' my_schema.posts.deleted', null) )->toSql();
Example:
User::joinRelationship('posts', fn ($join) => $join->where('approved', true)->where('status', 2)->where('deleted', null) )->toSql();
Result:
SELECT my_schema.users.* FROM my_schema.users JOIN my_schema.posts ON my_schema.posts.user_id = my_schema.user.id AND my_schema.posts.approved = 1 AND my_schema.posts.status = 2 AND my_schema.posts.deleted IS NULL
This makes it easier to avoid having to cite the table name in each where statement of the connection.
This avoids conflicts when 2 tables have one or more columns with the same name.
2 - Add the behavior of ( joinRelationship ) equal to ( joinRelationshipUsingAlias ), but with the following behavior:
A: In joinRelationship, if there are 2 parameters, the first is the relationship and the second is the anonymous function containing the WHERE clause.
B: In joinRelationship, if there are 3 parameters, the first is the relationship, the second is an alias to be assigned to the relationship, and the third is the anonymous function containing the WHERE clause.
Example:
User::joinRelationship('posts', 'test', fn ($join) => $join->where('test.approved', true)->where('test.status', 2)->where('test.deleted', null) )->toSql();
Result:
SELECT my_schema.users.* FROM my_schema.users JOIN my_schema.posts as test ON test.user_id = my_schema.user.id AND test.approved = 1 AND test.status = 2 AND test.deleted IS NULL
This helps in the flexibility of handling the join connection.
The text was updated successfully, but these errors were encountered: