This topic is locked

2 DB Connections

12/27/2007 12:16:27 AM
PHPRunner General questions
B
barbary author

Dears,

I have a projet which has a table that needs to obtain its data from another table in another MySQL database.
how can I do that??
BR

A
acpan 12/27/2007

Hi,
here's how i do it for my web.

  1. In Database 1, create view for target table 1 from Database 2.

    I use webyog, an open source version to create view.
  2. In phprunner, create project that connects to database 1,

    you will see table 1 from database 2 inside the database 1.
  3. do as normal what you will do using phprunner.
    hope it helps.

    Dex

B
barbary author 12/27/2007

Dear,

I really appreciate your reply, but can you give me an example for the code to be used to create view???
Thanks

A
acpan 12/27/2007
  1. First. Creating view within mysql is transparent to phprunner.

    phprunner will treat view created in mysql as another table.
  2. In mysql, assuming you have 2 seperate databases,

    database1 and database2, each with their own tables.
    Database1's tables:

    School

    Course

    Student_Name
    Database2's tables:

    Student_Contact
  3. You want to 'mirror' Student_Contact in database2 into Database1,

    so Database1 will have:
    School

    Course

    Student_Name

    v_Student_Contact
  4. Using Webyog client software for mysql,

    when create view you will see a window with the following

    sample codes:
    --

    DROP VIEW IF EXISTS `database1`.`v_Student_Contact`;
    CREATE

    /[ALGORITHM = {UNDEFINED | MERGE | TEMPTABLE}]

    [DEFINER = { user | CURRENT_USER }]

    [SQL SECURITY { DEFINER | INVOKER }]
    /

    VIEW `database1`.`table1`

    AS

    (SELECT * FROM Database2.Student_Contact )
  5. execute it to create the view and you will see a new view created

    under the view section of webyog.
  6. Connect phprunner to the database1 and you will see a list of tables

    under database1 which includes v_Student_Contact. You will then

    be able to perform update/insert/delete/query on the table as per normal.
  7. If your database are in 2 different servers, this may not work.

    Your 2 databases should be under the same mysql server for views to be

    created, as far as i had tried.
    Hope it helps.
    Rgds

    Dex

A
acpan 12/27/2007

Also, as memtioned, within mysql you can combine tables from 2 databases

using views and we use the open source tool webyog to create the views in mysql.

and later use phprunner to work on the "combined" database. Be sure to allow

permission in mysql for the users after creating view.
Views in phprunner are use to present/filter the tables in CURRENT

databases. So do not use views in phprunner to achieve what you want here.
Dex

B
barbary author 12/31/2007

Dear,

I really appreciate your effort and the info you gave me.

But, I still have a problem as the 2 DBs are not on the same server <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=24511&image=1&table=forumreplies' class='bbc_emoticon' alt=':(' />

Isn't there a way to do this??