Raised This Month: $51 Target: $400
 12% 

SQLx and arrays


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Sputnik53
Senior Member
Join Date: Jun 2005
Old 11-28-2008 , 09:39   SQLx and arrays
Reply With Quote #1

Hi, I've got SQLx to connect to db succesfully. Then I got confused about reading stuff to arrays, so I'm asking what would be a way to read SQL data to an array?

In php I used mysql_fetch_row($sql); so is there a corresponding function in SQLx?
Sputnik53 is offline
danielkza
AMX Mod X Plugin Approver
Join Date: May 2007
Location: São Paulo - Brasil
Old 11-28-2008 , 10:02   Re: SQLx and arrays
Reply With Quote #2

The SQLx approach is different, you have to read it row in separate with SQL_ReadResult. If you really need to read it to arrays, you can use the functions from cellarray.inc to achieve it.

Ask if you need an example.
__________________

Community / No support through PM
danielkza is offline
Sputnik53
Senior Member
Join Date: Jun 2005
Old 11-28-2008 , 10:15   Re: SQLx and arrays
Reply With Quote #3

I'd love an example, no idea how am I gonna do this without one. :/
Sputnik53 is offline
danielkza
AMX Mod X Plugin Approver
Join Date: May 2007
Location: São Paulo - Brasil
Old 11-28-2008 , 10:46   Re: SQLx and arrays
Reply With Quote #4

What exactly do you want to do? Just read data from an simple query? Do you need to store it for later use?
__________________

Community / No support through PM
danielkza is offline
Sputnik53
Senior Member
Join Date: Jun 2005
Old 11-28-2008 , 10:59   Re: SQLx and arrays
Reply With Quote #5

I want to read 1 row from the table.

SELECT * FROM table

and get all the values into the array.
Sputnik53 is offline
danielkza
AMX Mod X Plugin Approver
Join Date: May 2007
Location: São Paulo - Brasil
Old 11-28-2008 , 11:28   Re: SQLx and arrays
Reply With Quote #6

Quote:
Originally Posted by Sputnik53 View Post
I want to read 1 row from the table.

SELECT * FROM table

and get all the values into the array.
As I said, this is not the normal approach in AMXX. Tell me if you need the data for imediate use or for long-term storage.
__________________

Community / No support through PM
danielkza is offline
Sputnik53
Senior Member
Join Date: Jun 2005
Old 11-28-2008 , 11:29   Re: SQLx and arrays
Reply With Quote #7

Immediate use.
Sputnik53 is offline
danielkza
AMX Mod X Plugin Approver
Join Date: May 2007
Location: São Paulo - Brasil
Old 11-28-2008 , 11:45   Re: SQLx and arrays
Reply With Quote #8

Quote:
Originally Posted by Sputnik53 View Post
Immediate use.
I'll post a working example in a few minutes.
__________________

Community / No support through PM
danielkza is offline
Sputnik53
Senior Member
Join Date: Jun 2005
Old 11-28-2008 , 11:46   Re: SQLx and arrays
Reply With Quote #9

Quote:
Originally Posted by danielkza View Post
I'll post a working example in a few minutes.
Great thanks alot. +karma'd
Sputnik53 is offline
|PJ| Shorty
Veteran Member
Join Date: Aug 2005
Location: Bavaria, Germany
Old 11-28-2008 , 15:44   Re: SQLx and arrays
Reply With Quote #10

a function like in php is not accessable.
you have to save the results manually like:
Code:
 
new g_var[10][36]
...
SQL_ReadResult(Query,0,g_var[0],35);
SQL_ReadResult(Query,1,g_var[1],35);
SQL_ReadResult(Query,2,g_var[2],35);
 
... and so on
example for strings...
__________________
There are only 10 types of people in the world:
Those who understand binary, and those who don´t.
|PJ| Shorty is offline
Send a message via ICQ to |PJ| Shorty Send a message via AIM to |PJ| Shorty Send a message via MSN to |PJ| Shorty Send a message via Yahoo to |PJ| Shorty Send a message via Skype™ to |PJ| Shorty
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 20:56.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode