I'm trying to extend the inetorgperson schema with a date attribute in OpenLDAP 2.4.X.Which is the right way to do this?
Create an auxiliary class with the attribute and mix it into your objects. You really shouldn't touch the core schemas.
Related
I have two related PostgreSQL tables: persons(.., person_department_id,..) and departments(department_id, ..) with foreign keys properties "ON UPDATE CASCADE". I can't change this behavior, because data comes from external database by a script, i. e. departments.department_id can be changed without Symfony 3 application, but I must to implement a partial editing of records in those tables with Symfony 3 app.
My Q: Because "onUpdate" property has been removed from Doctrine ORM, how I can to validate the database schema? Or, maybe I can't use ORM and must to use only DBAL in this situation?
You might use Symfony's validator for this purpose.
You can set validation rules for any entity property or for the entire class.
Depending on your needs it's possible to create custom validators for more complexes validation rules.
a customer has an existing database. The schema is often changed within the database itself (e.g. he adds a new column).
My task is to develop an admin area with symfony that automatically reacts on table schema changes without modifying the application code. E.g. the customer adds a new column to table "MyEntity", and the application automatically generates a new column in the accordingly list view.
My approach is to dynamically map the table columns to the Entity class so that ALL Attributes and ALL Getters/Setters are generated dynamically from the table schema.
So is it possible to map the table columns in a Doctrine Entity without the use of Annotations or XML Files.
Something like:
class MyEntity{
public function generateMappingFromSchema($sTableName){...}
}
Please don't do that. Doctrine was not designed for such use case.
There is a library though you should check https://github.com/laravel-doctrine/fluent which basically is a mapping driver that allows you to manage your mappings in an Object Oriented approach. And there are other tools:
http://crud-admin-generator.com/
http://crudkit.com/
http://www.grocerycrud.com/
which are maybe better for that, I don't know.
But again, please don't do that. Do not allow the customer to modify the database schema or give them e.g. a phpMyAdmin which was designed for that.
So I'm using Symfony 2 with Doctrine 2 for a new web application but we have a few common tables shared among different applications.
We need to access these tables (read-only, there would be no updates) but I don't want Doctrine to manage them. My vision is to create an entity for it so Doctrine can use it, including relations to it, but not have it do create/alter table statements when I do doctrine:schema:update.
Am I overthinking this?
Create your entities (manually or using generator) and mark them as readOnly
I am trying to use the a2lix TranslationFormBundle ( https://github.com/a2lix/TranslationFormBundle ) with a Symfony2 project.
I have been looking at docs and specifically at this demo: https://github.com/a2lix/Demo/tree/master/src/A2lix/DemoTranslationBundle
I noticed all examples in both the doc and the demo use specific translation tables (end entity) for each translatable entity, as set in the class annotation with
#Gedmo\TranslationEntity(class="A2lix\DemoTranslationBundle\Entity\ProductGedmoTranslation")
My idea was to stay with just one table, like the ext_translations table that the Gedmo Doctrine Extension Translatable creates and manages.
Is this possible or does the TranslationFormBundle absolutely need separate tables?
Does anyone have a working example?
TIA
With the current implementation of TranslationFormBundle, you need separate tables. Use an only one ext_translations table is not plan.
I have a small question about doctrine and Symfony 2:
Is it possible to declare a relation (OneToMany) between two entities which are managed by two different entity managers (and two different DB connections) ?
To be more precise, I have two bundles :
FpnABundle -> Mapped with A_database (and A_entitymanager)
FpnBBundle -> Mapped with B_database (and B_entitymanager)
And I need to define an association between FpnABundle:User and FpnBBundle:Post
If I try to do that, when I perform a DB schema update, I have the following error :
The class 'Fpn\ABundle\Entity\User' was not found in the chain configured namespaces Fpn\BBundle\Entity
Thanks for your help!
Basically, the answer is no.
You will probably need to do this: http://symfony.com/doc/current/cookbook/doctrine/resolve_target_entity.html
Even with this it will only work if the two databases are on the same server. And at some point you will probably need to add the schema name to the the table name. Somewhat painful.