This topic is locked

PostgreSQL Help

7/20/2010 6:58:09 AM
PHPRunner General questions
B
bedri author

Hello everyone,
I have this situation.

  1. I'm running PostgreSQL database and I have two databases traffic and traffic_log, these two databases are acessed remotely with different username and password,
  2. so I have to create two different connections, i have created an interface to access traffic_logfor each user, the user login credentials are in two tables user and user-1 in database traffic
    ex [traffic-db]: SELECT a.username, b.pwd FROM user a, user-1 b WHERE a.usr_id = b.usr_id
  3. The username is in 'user' and pwd is in 'user-1'table and the 'usr_id'is Unique ID matching the correct user, I see that PHPRunner does not allow to create Login page with two tables,
    WHAT SHOULD I CHANGE TO GET THIS WORKING...
  4. If the user passes the login form then it should connect to the second database [traffic_log] which contains the needed informations

    The second database has a table-3 containing 'usr_id'which is also the Unique ID for matching the correct user logged in
    PLEASE SOMEONE HELP...

    KIND REGARDS

A
ann 7/20/2010

Hi,
unfortunately, PHPRunner do not support usage of two databases in one project.

As workaround you can create a view in the database which joins tables from databases:

CREATE VIEW name AS

SELECT a.username, b.pwd FROM a JOIN b WHERE a.usr_id = b.usr_id



Then you can use this view in the project.

B
bedri author 7/20/2010

Thank You Very much I'll try
Regards

B
bedri author 7/20/2010

Hello,
I did the login form and it takes users to a table for ex: table-5 which is in the first database db1, I need to make this:
When a user types the login credentials and it passes the login form, I want these user to view a table from another database traffic_log in which database there is a table traffic_table holding the unique key usr_id which identifies 'which user to view what'.
Connectiong to database:

db1: traffic : username=postgres pwd=postgres

db2: traffic_log : username=postgres_viewer pwd=postgres
So connecting to db1 is clear now after users login I want them to view data on the other database db2 identifying their data by usr_id field which is in table table_traffic in db2 and also is in table, table-2 in db1 where I did the filter
OK I HOPE YOU WILL HELP ME
KIND REGARDS

A
ann 7/20/2010

Hi,
unfrotunately you can't use two database in one PHPRunner project.

As workaround you can use custom view or connect to other database in the events.

B
bedri author 7/20/2010

Hello Ann
Can you give me a simple scenario how to do this in the events
Regards

J
Jane 7/21/2010

Hi,
here is just a sample:

//open new connection

$conn2 = pg_connect("...");

$str = "select Field1,Field2 from TableName ";

$rs = db_query($str,$conn2);

$data = db_fetch_array($rs);

//pritn selected data manually if needed here

//close connection

pg_close($conn2);



More info here:

http://www.php.net/manual/en/book.pgsql.php

B
bedri author 7/21/2010

Hello,
It is impossible with this situation to compare usr_id from db1 with usr_id from db2, maybe this could be done with $_SESSION.
Can I create two projects 1-connecting to db1, 2-connecting to db2 and then merge two projects into one but making unique the $_SESSION for comparing two $_rows from different tables in different databases.
ex: $_SESSION["usr_id"] registered in the login project1 then to check this session in the second project2 where the data are showing for each user filtered by usr_id but compared with the previously usr_id saved in $_SESSION["usr_id"] because i have to make a clause[... WHERE usr_id="$usr_id" ] here the first usr_id is in db2 traffic-table and the $usr_id is the usr_id saved in $_SESSION from the first connection to db1... Is this possible with phprunner, I hope you can understand me.
REGARDS

A
ann 7/22/2010

Hi,
you can share sessions between different projects and fill session variables for another projects in the After successful login event. In this case you don't need to re-login again in another project. Please note security settings on the Security tab should be the same for both projects.

B
bedri author 7/22/2010

Hi
How to do it.



Hi,
you can share sessions between different projects and fill session variables for another projects in the After successful login event. In this case you don't need to re-login again in another project. Please note security settings on the Security tab should be the same for both projects.

J
Jane 7/23/2010

Hi,
use After Successful Login event to fill session variables for all your projects.

All values from users table are in the $data array:

http://xlinesoft.com/phprunner/docs/after_successful_login.htm
Here is list of PHPRunner session variables:

http://xlinesoft.com/phprunner/docs/phprunner_session_variables.htm