Use multiple databases with Editor

Use multiple databases with Editor

gotomediagotomedia Posts: 8Questions: 0Answers: 0
edited October 2012 in General
In the config.php of Editor only one database connection can be provided.
What if I need to connect to multiple databases with one instance of Editor?
Is there any way to do this?

Replies

  • allanallan Posts: 61,892Questions: 1Answers: 10,143 Site admin
    Currently this is not supported in the PHP implementation that Editor comes with. Would you simply want to replicate all edits, etc to the second database, or would you be looking for something more complex? If the former, why not have the database do the sync?

    Allan
  • gotomediagotomedia Posts: 8Questions: 0Answers: 0
    Hi Allan!

    I would like to implement the Editor in a Backend, which is used to edit database content.
    The tables that need to be edited are scattered over different databases.
    I would not want to create redundant tables which have to be synced.
    Rather I would like them to be edited in the correct database.

    Is there any solution for that? Or is anything planned?

    Thanks in advance!
  • allanallan Posts: 61,892Questions: 1Answers: 10,143 Site admin
    > The tables that need to be edited are scattered over different databases.

    Over multiple database servers, or on a single server? In the PHP classes you can use standard SQL notation for accessing different databases. For example>

    [code]
    $data = Editor::inst( $db, 'dt.releases' ) ...
    [/code]

    where `dt` is a database name.

    Allan
  • gotomediagotomedia Posts: 8Questions: 0Answers: 0
    The databases are on the same server!
    But they have of course different login credentials.

    I don't really know yet where and how to implement such a "switch".

    Can you provide an example of to do that?
    This is the only issue I have to know out of the way before purchasing and implementing your solution, which looks very nice in every other aspect!

    Oh, and by the way: Is there any way of supporting MySQL4 databases or is this a PDO Limitation?

    Thank you!

    Lukas
  • gotomediagotomedia Posts: 8Questions: 0Answers: 0
    Oh, I see now. It is fairly easy to add other DBs in the config.php und bootstrap.php and later use theme in the server side processing scripts. Forget the stupid questions from the previous post! :-D

    Maybe you could answer the one about MySQL 4?! Thanks!
  • allanallan Posts: 61,892Questions: 1Answers: 10,143 Site admin
    Hi Lukas,

    > But they have of course different login credentials.

    Why not grant access rights to both databases for a single user? Otherwise all JOINs etc would need to be replicated in program space rather than in the SQL server, which would completely negate the reason for using an SQL database in the first place!

    > Oh, and by the way: Is there any way of supporting MySQL4 databases or is this a PDO Limitation?

    The PHP MySQL PDO driver states ( http://php.net/manual/en/ref.pdo-mysql.php ):

    > PDO_MYSQL is a driver that implements the PHP Data Objects (PDO) interface to enable access from PHP to MySQL 3.x, 4.x and 5.x databases.

    So it should just work :-). I've only tested Editor with MySQL 5, so it is possible there might be a bug or two there, but the SQL that Editor uses is actually relatively simple - and intentionally as database vendor neutral as possible (as much as it is possible to be so with SQL anyway!), so I wouldn't expect there to be any issues.

    Allan
This discussion has been closed.