Board index   FAQ   Search  
Register  Login
Board index php forum :: Database Other Database Engines

PHP & MS SQL on LINUX

Do you have questions regarding other database enginges (not MySQL) -- ask here!

Moderators: macek, egami, gesf

PHP & MS SQL on LINUX

Postby schwabbie » Mon Nov 17, 2008 10:12 pm

I am testing in windows and I have no issues, but when I test my code on Linux my code does not work. I do not get any value returned. I have validated that my code returns a value from query analyzer.

Here is my code:
<?
$query = " set nocount on declare @PaymentKey int select top 1 @PaymentKey = PaymentKey from arPayments order by PaymentKey desc select PaymentKey = @PaymentKey";

$result = odbc_exec($database1, $query);

//get payment key
while ($result && $row = odbc_fetch_object($result)) {
$PaymentKey = $row->PaymentKey;
}
?>

my query is simplified from the original version but is basically doing the same thing. Any help would be GREATLY appreciated.
schwabbie
New php-forum User
New php-forum User
 
Posts: 2
Joined: Mon Nov 17, 2008 9:59 pm

Re: PHP & MS SQL on LINUX

Postby schwabbie » Tue Nov 18, 2008 12:08 am

I was able to determine that the driver used on linux was easysoft and I did figure out a work around for anyone that might have this same problem. I took the variable and inserted it to a temp table and executed the query. Then I selected the value from the temp table and executed to a result set. This works for now although i am not happy with it from a database perspective. But don't get me wrong I am SO HAPPY IT WORKS!

FYI my original code exec a stored procedure that returned the result to an OUTPUT variable and this solution works for that as well.

<?
$query = " set nocount on declare @PaymentKey int select top 1 @PaymentKey = PaymentKey from arPayments order by PaymentKey desc select PaymentKey = @PaymentKey into #temp";

odbc_exec($database1, $query);

$query = "select PaymentKey from #temp ";

$result = odbc_exec($database1, $query);

//get payment key
while ($result && $row = odbc_fetch_object($result)) {
$PaymentKey = $row->PaymentKey;
}
?>
schwabbie
New php-forum User
New php-forum User
 
Posts: 2
Joined: Mon Nov 17, 2008 9:59 pm

Re: PHP & MS SQL on LINUX

Postby admin » Tue Nov 18, 2008 4:52 am

excellent .
User avatar
admin
Site Admin
Site Admin
 
Posts: 123
Joined: Wed Apr 17, 2002 7:49 am
Location: Rome, Italy


Return to Other Database Engines

Who is online

Users browsing this forum: No registered users and 1 guest

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron