AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   SQLx and arrays (https://forums.alliedmods.net/showthread.php?t=81123)

Sputnik53 11-28-2008 09:39

SQLx and arrays
 
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?

danielkza 11-28-2008 10:02

Re: SQLx and arrays
 
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.

Sputnik53 11-28-2008 10:15

Re: SQLx and arrays
 
I'd love an example, no idea how am I gonna do this without one. :/

danielkza 11-28-2008 10:46

Re: SQLx and arrays
 
What exactly do you want to do? Just read data from an simple query? Do you need to store it for later use?

Sputnik53 11-28-2008 10:59

Re: SQLx and arrays
 
I want to read 1 row from the table.

SELECT * FROM table

and get all the values into the array.

danielkza 11-28-2008 11:28

Re: SQLx and arrays
 
Quote:

Originally Posted by Sputnik53 (Post 719606)
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.

Sputnik53 11-28-2008 11:29

Re: SQLx and arrays
 
Immediate use.

danielkza 11-28-2008 11:45

Re: SQLx and arrays
 
Quote:

Originally Posted by Sputnik53 (Post 719628)
Immediate use.

I'll post a working example in a few minutes.

Sputnik53 11-28-2008 11:46

Re: SQLx and arrays
 
Quote:

Originally Posted by danielkza (Post 719634)
I'll post a working example in a few minutes.

Great thanks alot. +karma'd

|PJ| Shorty 11-28-2008 15:44

Re: SQLx and arrays
 
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...


All times are GMT -4. The time now is 04:14.

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