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 …
Tag: orm
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 $…
Symfony OneToMany Assiociations not working
I have Product entity and ProductAttachment entity. One product should be able to have many attachments. I Used Doctrine mapping OneToMnay – ManyToOne but everytime i get product, it has empty $files collection ProductAttachment Entity Product Entity Am i Missing anything? When i call this is what i get Answer The problem is Doctrine’s lazy loading of collections, which is
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 …
symfony @oneToMany relation returns only last object in collection
I have a situation and not really sure what I’m doing wrong. in Sumfony 3.3 I’ve created a relation between entity Page and Language, where Page is related to multiple Languages, and when I search for a Page and get Page object but property Languages returns collection with only last Language object. No matter how many objects are there in
Laravel – Eloquent – Dynamically defined relationship
Is it possible to set a model’s relationship dynamically? For example, I have model Page, and I want to add relationship banners() to it without actually changing its file? So does something like this exist: Or something similar? As they are fetched using the magic methods anyway, perhaps I can add the relationship dynamically? Thanks! Answer I’ve added a package
Type hinting for the model objects of Eloquent ORM
I haven’t used laravel yet, but watching the tutorials on youtube left me with a question to type hinting, that is really important to me. Now I have read here Type Hinting Eloquent Models and here Eloquent ORM Code Hinting in PhpStorm but neither addresses the following problem: now lets say movie has a name, id, length, author all those
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 …
Virtual fields with Cakephp 3
I need to have a virtual property in my user entity. I followed the CakePHP book. UserEntity.php In a controller I followed exactly the book and I only get a null value. Answer According to @ndm, the problem was due to a bad file naming. I named the user entity class UserEntity.php. The CakePHP name conventions says that: The Entity
Get primary key of Eloquent model instance
I’m happy enough to work on a project with (not) very consistent column names in our MySQL database. We have camelCase, PascalCase, ‘Id’, ID and it’s driving me nuts. I’ve decided to start using Eloquent in our application (which is NOT Laravel). I would love to have a method of receiving the value of the primary key easily without knowing