Sybase NNTP forums - End Of Life (EOL)

The NNTP forums from Sybase - forums.sybase.com - are now closed.

All new questions should be directed to the appropriate forum at the SAP Community Network (SCN).

Individual products have links to the respective forums on SCN, or you can go to SCN and search for your product in the search box (upper right corner) to find your specific developer center.

Re: Connecting to multiple databases with PHP

2 posts in PHP Last posting was on 2010-09-18 00:40:18.0Z
Sam Weber Posted on 2010-09-16 13:42:02.0Z
From: "Sam Weber" <samw@associatedbilling.com>
Subject: Re: Connecting to multiple databases with PHP
Newsgroups: Advantage.PHP
Date: Thu, 16 Sep 2010 09:42:02 -0400
NNTP-Posting-Host: 24.173.168.198
Message-ID: <4c921e23@solutions.advantagedatabase.com>
X-Trace: 16 Sep 2010 07:39:47 -0700, 24.173.168.198
Lines: 27
Path: solutions.advantagedatabase.com!24.173.168.198
Xref: solutions.advantagedatabase.com Advantage.PHP:1102
Article PK: 1135586

Lance,

If I go about using the first solution and create a connection to each data dictionary, I would then have to create more prepare statements, strings, etc. for each dictionary, correct? As we have more than 50 different data dictionaries, it would become quite cumbersome to have to do so.

For example:

$rConn1 = ads_connect( "DataDirectory=\\\\server1\\share\\"."adsbook1\\mwddf.add;ServerTypes=2;","username", "password" );
$rConn2 = ads_connect( "DataDirectory=\\\\server1\\share\\"."adsbook2\\mwddf.add;ServerTypes=2;","username", "password" );

$rStmt1 = ads_prepare( $rConn1, "SELECT * FROM mwpat "."WHERE [Chart Number] = ?" );
$rStmt2 = ads_prepare( $rConn2, "SELECT * FROM mwpat "."WHERE [Chart Number] = ?" );
$rResult1 = ads_execute( $rStmt1, $aParams );
$rResult2 = ads_execute( $rStmt2, $aParams );

$strFirstName = ads_result( $rStmt1, "First Name" );
$strFirstName = ads_result( $rStmt2, "First Name" );


If I use the second option (I'd have to research exactly how to do it), we would just connect to a single common dictionary, correct? We currently use a pretty buggy peice of medical software that is built on these Advantage dictionaries, so I'm just worried that doing this might create some issues for us in the software. Also, creating dictionary links don't actually share the data in any way besides that common database right? Given our sensitive material, we can't have any data shared with one another outside of the one common database.

Thank you for your responses.


--------------= Posted using GrabIt =----------------
------= Binary Usenet downloading made easy =---------
-= Get GrabIt for free from http://www.shemes.com/ =-


Lance Schmidt Posted on 2010-09-18 00:40:18.0Z
From: "Lance Schmidt" <LanceSc@ExtendSys.com>
Newsgroups: Advantage.PHP
References: <4c921e23@solutions.advantagedatabase.com>
Subject: Re: Connecting to multiple databases with PHP
Date: Fri, 17 Sep 2010 18:40:18 -0600
Lines: 68
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.5931
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.5994
X-RFC2646: Format=Flowed; Original
NNTP-Posting-Host: 10.24.40.138
Message-ID: <4c9409ae@solutions.advantagedatabase.com>
X-Trace: 17 Sep 2010 18:37:02 -0700, 10.24.40.138
Path: solutions.advantagedatabase.com!10.24.40.138
Xref: solutions.advantagedatabase.com Advantage.PHP:1103
Article PK: 1135587

Hi Sam,

Your example is a correct implementation of my first solution. If you have
50 data dictionaries this could become quite slow and very painful.
Creating a function that handles just the prepare\execute\retrived result
would make that part of the code less painful.

For solution 2 data dictionary links can be configured to use the
credentials of the current connection on the linked connection. So the user
name and password of the current connection would be passed to the data
dictionary link. Any permissions assigned to the username in the target
data dictionary would then be respected.

Best Regards,

Lance Schmidt
Advantage R&D

"Sam Weber" <samw@associatedbilling.com> wrote in message
news:4c921e23@solutions.advantagedatabase.com...
> Lance,
>
> If I go about using the first solution and create a connection to each
> data dictionary, I would then have to create more prepare statements,
> strings, etc. for each dictionary, correct? As we have more than 50
> different data dictionaries, it would become quite cumbersome to have to
> do so.
>
> For example:
>
> $rConn1 = ads_connect(
> "DataDirectory=\\\\server1\\share\\"."adsbook1\\mwddf.add;ServerTypes=2;","username",
> "password" );
> $rConn2 = ads_connect(
> "DataDirectory=\\\\server1\\share\\"."adsbook2\\mwddf.add;ServerTypes=2;","username",
> "password" );
>
> $rStmt1 = ads_prepare( $rConn1, "SELECT * FROM mwpat "."WHERE [Chart
> Number] = ?" );
> $rStmt2 = ads_prepare( $rConn2, "SELECT * FROM mwpat "."WHERE [Chart
> Number] = ?" );
> $rResult1 = ads_execute( $rStmt1, $aParams );
> $rResult2 = ads_execute( $rStmt2, $aParams );
>
> $strFirstName = ads_result( $rStmt1, "First Name" );
> $strFirstName = ads_result( $rStmt2, "First Name" );
>
>
> If I use the second option (I'd have to research exactly how to do it), we
> would just connect to a single common dictionary, correct? We currently
> use a pretty buggy peice of medical software that is built on these
> Advantage dictionaries, so I'm just worried that doing this might create
> some issues for us in the software. Also, creating dictionary links don't
> actually share the data in any way besides that common database right?
> Given our sensitive material, we can't have any data shared with one
> another outside of the one common database.
>
> Thank you for your responses.
>
>
> --------------= Posted using GrabIt =----------------
> ------= Binary Usenet downloading made easy =---------
> -= Get GrabIt for free from http://www.shemes.com/ =-
>