ODBC Functions & MS SQL Server 2005

ODBC Functions & MS SQL Server 2005

am 18.09.2008 15:20:31 von Dan Joseph

------=_Part_29674_22419050.1221744031866
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

Hi,

Anyone else using the odbc_* functions to interact with MS SQL Server 2005?

I'm having a problem getting odbc_num_rows() to return anything other than
-1 when querying a stored procedure. I can get it to work using Top in a
normal query (non-stored procedure).

SELECT Top 1000000 * FROM Table

if I do an odbc_num_rows( result ) on that, I get the number of rows.
However...

EXEC ProcedureName @Var = 'value'

if I do an odbc_num_rows( result), I get -1. The same is true if I did a
straight SELECT * FROM Table. I've tried putting Top in my query in the
stored procedure.

Right now I'm either doing an extra query for @@ROWCOUNT, or I'm doing two
result sets, a counting query, and then the normal query. I am concerned
about performance in doing the two queries, and with @@ROWCOUNT, I feel I'm
just adding extra things to the code that may be unreliable?

From what I've read, its something with the ODBC driver, and updating the
ODBC driver isn't an option.

Anyone else having this problem? Any suggestions?

--
-Dan Joseph

www.canishosting.com - Plans start @ $1.99/month.

"Build a man a fire, and he will be warm for the rest of the day.
Light a man on fire, and will be warm for the rest of his life."

------=_Part_29674_22419050.1221744031866--

Re: ODBC Functions & MS SQL Server 2005

am 18.09.2008 21:36:35 von Dan Shirah

------=_Part_27843_20798129.1221766595404
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

On 9/18/08, Dan Joseph wrote:

> Hi,
>
> Anyone else using the odbc_* functions to interact with MS SQL Server 2005?
>
> I'm having a problem getting odbc_num_rows() to return anything other than
> -1 when querying a stored procedure. I can get it to work using Top in a
> normal query (non-stored procedure).
>
> SELECT Top 1000000 * FROM Table
>
> if I do an odbc_num_rows( result ) on that, I get the number of rows.
> However...
>
> EXEC ProcedureName @Var = 'value'
>
> if I do an odbc_num_rows( result), I get -1. The same is true if I did a
> straight SELECT * FROM Table. I've tried putting Top in my query in the
> stored procedure.
>
> Right now I'm either doing an extra query for @@ROWCOUNT, or I'm doing two
> result sets, a counting query, and then the normal query. I am concerned
> about performance in doing the two queries, and with @@ROWCOUNT, I feel I'm
> just adding extra things to the code that may be unreliable?
>
> From what I've read, its something with the ODBC driver, and updating the
> ODBC driver isn't an option.
>
> Anyone else having this problem? Any suggestions?
>
> --
> -Dan Joseph



Dan,

If you already have your results in an array, try using count($result); That
should count the number of results returned to your result array.

Or you could try uncommenting the mssql extension in your php.ini file and
then try using:

mssql_num_rows() ?

Dan

------=_Part_27843_20798129.1221766595404--

Re: ODBC Functions & MS SQL Server 2005

am 18.09.2008 22:21:27 von Dan Joseph

------=_Part_38366_16762923.1221769287480
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

On Thu, Sep 18, 2008 at 3:36 PM, Dan Shirah wrote:

>
> If you already have your results in an array, try using count($result);
> That should count the number of results returned to your result array.
>
> Or you could try uncommenting the mssql extension in your php.ini file and
> then try using:
>
> mssql_num_rows() ?
>
> Dan
>
>
>
>
I don't have them in an array usually, I just cycle thru each row.

I've thought about using the mssql_* functions. My boss originally pushed
me into odbc posing the question "What if we move to a different database
server type?".

I do have a class for handling all the database functions. Maybe I'll just
go that route. If he changed to Oracle or something, I could modify my
class easy enough.

I'm assuming mssql_num_rows() works fine when calling a stored procedure?

--
-Dan Joseph

www.canishosting.com - Plans start @ $1.99/month.

"Build a man a fire, and he will be warm for the rest of the day.
Light a man on fire, and will be warm for the rest of his life."

------=_Part_38366_16762923.1221769287480--

Re: ODBC Functions & MS SQL Server 2005

am 18.09.2008 22:35:39 von Micah Gersten

If you need abstraction, check this out:
http://us.php.net/pdo

Thank you,
Micah Gersten
onShore Networks
Internal Developer
http://www.onshore.com



Dan Joseph wrote:
> On Thu, Sep 18, 2008 at 3:36 PM, Dan Shirah wrote:
>
>
>> If you already have your results in an array, try using count($result);
>> That should count the number of results returned to your result array.
>>
>> Or you could try uncommenting the mssql extension in your php.ini file and
>> then try using:
>>
>> mssql_num_rows() ?
>>
>> Dan
>>
>>
>>
>>
>>
> I don't have them in an array usually, I just cycle thru each row.
>
> I've thought about using the mssql_* functions. My boss originally pushed
> me into odbc posing the question "What if we move to a different database
> server type?".
>
> I do have a class for handling all the database functions. Maybe I'll just
> go that route. If he changed to Oracle or something, I could modify my
> class easy enough.
>
> I'm assuming mssql_num_rows() works fine when calling a stored procedure?
>
>

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: ODBC Functions & MS SQL Server 2005

am 18.09.2008 22:38:31 von Dan Joseph

------=_Part_38710_9067056.1221770311524
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

On Thu, Sep 18, 2008 at 4:35 PM, Micah Gersten wrote:

> If you need abstraction, check this out:
> http://us.php.net/pdo
>
> Thank you,
> Micah Gersten
> onShore Networks
> Internal Developer
> http://www.onshore.com
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
I looked at PDO, and liked it, but it seems really buggy in the version of
php we're running. I had to stop using it. We're running 5.1.2.

--
-Dan Joseph

www.canishosting.com - Plans start @ $1.99/month.

"Build a man a fire, and he will be warm for the rest of the day.
Light a man on fire, and will be warm for the rest of his life."

------=_Part_38710_9067056.1221770311524--

Re: ODBC Functions & MS SQL Server 2005

am 18.09.2008 23:35:16 von Micah Gersten

You can't upgrade PHP?

Thank you,
Micah Gersten
onShore Networks
Internal Developer
http://www.onshore.com



Dan Joseph wrote:
> On Thu, Sep 18, 2008 at 4:35 PM, Micah Gersten wrote:
>
>
>> If you need abstraction, check this out:
>> http://us.php.net/pdo
>>
>> Thank you,
>> Micah Gersten
>> onShore Networks
>> Internal Developer
>> http://www.onshore.com
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>>
> I looked at PDO, and liked it, but it seems really buggy in the version of
> php we're running. I had to stop using it. We're running 5.1.2.
>
>

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Re: ODBC Functions & MS SQL Server 2005

am 19.09.2008 04:53:47 von Dan Joseph

------=_Part_41432_4654594.1221792827579
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

On Thu, Sep 18, 2008 at 5:35 PM, Micah Gersten wrote:

> You can't upgrade PHP?
>
> Thank you,
> Micah Gersten
> onShore Networks
> Internal Developer
> http://www.onshore.com
>
>
>
> Dan Joseph wrote:
> > On Thu, Sep 18, 2008 at 4:35 PM, Micah Gersten
> wrote:
> >
> >
> >> If you need abstraction, check this out:
> >> http://us.php.net/pdo
> >>
> >> Thank you,
> >> Micah Gersten
> >> onShore Networks
> >> Internal Developer
> >> http://www.onshore.com
> >>
> >> --
> >> PHP General Mailing List (http://www.php.net/)
> >> To unsubscribe, visit: http://www.php.net/unsub.php
> >>
> >>
> >>
> > I looked at PDO, and liked it, but it seems really buggy in the version
> of
> > php we're running. I had to stop using it. We're running 5.1.2.
> >
> >
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
No, unfortunately not. My boss is opposed to it (or atleast was a while
back). He wasn't sure how some of his stuff would react to the upgarde.

--
-Dan Joseph

www.canishosting.com - Plans start @ $1.99/month.

"Build a man a fire, and he will be warm for the rest of the day.
Light a man on fire, and will be warm for the rest of his life."

------=_Part_41432_4654594.1221792827579--

Re: ODBC Functions & MS SQL Server 2005

am 19.09.2008 08:55:09 von Goltsios Theodore

--------------080603000508030304030700
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit


> On Thu, Sep 18, 2008 at 4:35 PM, Micah Gersten wrote:
>
>
>> If you need abstraction, check this out:
>> http://us.php.net/pdo
>>
>> Thank you,
>> Micah Gersten
>> onShore Networks
>> Internal Developer
>> http://www.onshore.com
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>>
> I looked at PDO, and liked it, but it seems really buggy in the version of
> php we're running. I had to stop using it. We're running 5.1.2.
>
>
Well from my experience with PDO the does the job pretty well and
although I use it for mysql I haven't noticed any obvious bug. Update is
always needed and since I despise development is M$ windowz I don't know
if there are bugs there.

Well using PDO will do the magic for you if you plan to migrate to
another database. Since you are writing in an object oriented way as far
as I can tell then data objects is more suited to your style.

--
Thodoris


--------------080603000508030304030700--