I was reading about cross database joins in Doctrine on their blog: http://www.doctrine-project.org/blog/cross-database-joins.html
The problem is that whenever table name contains a dot (used to specify the database), doctrine:schema:update outputs Nothing to update - your database is already in sync with the current entity metadata. The command basically just ignores entities whose table name contains a dot.
This is normal and it is a limitation of the ORM/DBAL.
The Doctrine\ORM\Tools\SchemaTool uses a schema manager retrieved from your current connection.
The Doctrine\DBAL\Schema\AbstractSchemaManager reads the tables from the current connection's db, and not from all databases.
Therefore, you have to manually handle tables placed in different DBs, or use your own schema manager with your own listTables implementation.
Related
I have a staging db with new changes, now I want to make these changes to live db.
My specific requirements :
1) Fetch all the data from the parent table (Id will be passed by user)
2) Fetch all the child tables data based on the parent id.
3) Check if that record is present on live.
If record is not present, insert as new
If record is already present, keep the id's intact and update only the data.
Below is the approach I am trying to do. I created two connections for staging and live db's, I fetched the data in php objects, Now I am trying to compare each key/value and will create an insert/update based on the distinct values and will exclude the duplicates.
For this, I am thinking of using the Reflection API, (Comparing each value of the object)
Also looked upon few already given answers related to this :
Laravel 4.2: Copying database records from one database to another
Please guide me if there is some faster/better solution. (Like using Seeders, Eloquent, etc)
I have two databases primary/parent database is in Mysql (with PHP) and child database is in Mssql (with .Net). Both databases are of same structure and contains same data. My requirement is when any record in parent database updated then it will update the same record in child database. In other means data syncing in parent and child databases. Only want to do it via Mysql and PHP. Can some one help me out. Thanks in advance for any help.
Update:- I don't want to use trigger as well.
.Net application has some advanced functionality as well, so there is difference in number of tables, mssql database has some more tables than mysql database. But the matched tables have same structure as in parent database.
Using phpMyAdmin I can track a certain table's transactions (new inserts, deletes, etc), but is it possible to change or export it to a SQL table to be imported into my site using PHP.
While it is not exactly what I was looking for, I found a way to do it for the time being, one of the tables in the phpmyadmin (it's own) database is called pma__tracking, which contains a record of all tables being tracked, one of its columns is the data_sql longtext column which writes each report (ascendingly which is a bit annoying) in the following format
# log date username
data definition statement
Just added it for future references.
I have generated 2 entities in my bundle and then using app/console doctrine:schema:update --force I recreate database schema. The order of fields that I have defined in the entities does not match the order of fields in the database table. Is there a way to control/define order in which fields are listed in the database table?
Thanks,
Z
It's not a problem; If you have generated the schema first then you updated it, the new fields will be just appended to current columns.
Furthermore you can find this different order for columns which has relationship which will be appended, too (on the generation time). In fact it does not create any issue; but if it's important to you, you can change the arrangement through one of the DataBase Management Tools (e.g. phpMyAdmin)
I have two tables, Inventory and, say, Stuff. Inventory is used to store data common to Stuff and other tables. The way the DBA envisioned this working would be with us inserting the Inventory table and then using the generated ID to insert the Stuff table.
How can I implement this scenario using Doctrine 2? I'm tempted to just add a 1:1 relationship on the model but I'm not sure I can convince the DBA to change the database.
With the workaround described here http://www.doctrine-project.org/docs/orm/2.0/en/reference/limitations-and-known-issues.html#foreign-keys-as-identifiers you should be able to get the DBAs schema working. With version 2.1 of Doctrine (or the current master) you can use the new foreign key as identifier feature to get it working.
However if you are not using Sequences of Oracle/Postgresql you need to flush operations for this (persist parent, flush, associate and persist child, flush)