Laravel Eloquent ORM – Mismatch between generated SQL and querybuilder results when selecting all models where two relationships are both absent

Let’s say I have a model Foobar with relationships named baz and quux. Foobar belongsTo Baz and Baz hasOne Foobar. This means there is a foreign key column in the Foobar table for baz_id. The …

Laravel – Filtering a Model by Condition between “a Field and Its Relationship Model Field”

I have these two models with one to one relationship. “products” id name minimum_required “product_data” id product_id price oh_hand I want to get the count of product_data …

Do I have to persist object from repository in Doctrine?

Do I have to persist the object I fetched from a repository? For example: $foo = $this->repository->find($id); $foo->setBar($baz); $this->flush(); Do I have to add $this->persist($foo)…

Symfony – creating new entity instead of updating existing

I have the following structure: Category property that contains link to property and its value:

How to append or attach a pivot relationship to a model?

I am trying to get the practice area record of lawyers from practice_areas table along side each time I get a lawyer’s record from lawyer_profiles_table. This two tables (practice_areas and …

Problem with binding NULL value to named placeholders with associative array in execute function in PDO

I am trying to construct and execute a delete query when the table_name and the conditional_clauses are passed as parameters in OOP fashion. I am using PDO by wrapping it in a custom wrapper. I am …

Laravel pass parameter to its distant relationship (translate children)

I have categories with id, parent_id, slug , pivot table category_language which columns are id,category_id,language_id,value As you can see I can translate parent category, but can’t send desired $…

Phalcon ORM – integer field id is string after save

I’m using Phalcon for my current project and i’m seeing some strange behaviour with the type casting. I have this model class Customer extends Model { protected $id; protected $name; } In …

Aliasing fields using partial object syntax + array hydrator in doctrine 2

Is there any way to alias fields when using partial object syntax in Doctrine 2? I know I can do this: $this->createQueryBuilder(‘user’)->select([ ‘user.id AS id’, ‘user.firstName AS …

Object-Relational Mapping vs Database Abstraction Layer

I’m using Doctrine which provides both ORM and DBAL. What is difference between them? How should one decide when to use which?