Jump to content

  •  

Photo

query_sql to Array


Best Answer Sunzuki, 30 June 2014 - 11:16 PM

no it wouldn't. if it would work it would be

.@tempvar$[0] = 1

.@tempvar$[1] = 2

you have to add more variables to the end.

 

query_sql[color=rgb(102,102,0);]([/color][color=rgb(0,136,0);]"SELECT * FROM `awesome_table` WHERE `ID`=1"[/color][color=rgb(102,102,0);], .[/color][color=rgb(0,102,102);]@ID, [/color][color=rgb(102,102,0);].[/color][color=rgb(0,102,102);]@[/color]Name[color=#ff0000]$[/color], .@val1, .@val2, .@val3[color=rgb(102,102,0);]);[/color]

.@ID[0] = 1; [color=rgb(102,102,0);].[/color][color=rgb(0,102,102);]@[/color]Name$[0] = Hi

.@ID[1] = 2; [color=rgb(102,102,0);].[/color][color=rgb(0,102,102);]@[/color]Name$[0] = Hello

 

basically you just put the columns (from after select, * = all) in the second part of the query_sql command

 

$ because it is a string not an integer

Go to the full post


  • Please log in to reply
4 replies to this topic

#1 joecalis

joecalis

    Member

  • Members
  • PipPip
  • 21 posts

Posted 30 June 2014 - 10:01 PM

I was just wondering what the outcome will be if I do the following:

query_sql("SELECT * FROM `awesome_table` WHERE `ID`=1",.@tempvar$); 

awesome_table:

ID Name Val1   Val2   Val3

(int) (string) (int)   (int)   (int)

1   Hi 0 1 0

2   Hello   1 1 1

 

My question is, would it automatically store all the information in the row selected into the array like so:

.@tempvar$[0] = 1

.@tempvar$[1] = "Hi"

.@tempvar$[2] = 0

.@tempvar$[3] = 1

.@tempvar$[4] = 0

 

or would it only store the first value in the row?

also would it automatically store the "int" values as "string"?

 

Need reply fast please and thank you :D


Edited by joecalis, 30 June 2014 - 10:02 PM.


#2 Sunzuki

Sunzuki

    Member

  • Members
  • PipPip
  • 22 posts

Posted 30 June 2014 - 11:16 PM   Best Answer

no it wouldn't. if it would work it would be

.@tempvar$[0] = 1

.@tempvar$[1] = 2

you have to add more variables to the end.

 

query_sql[color=rgb(102,102,0);]([/color][color=rgb(0,136,0);]"SELECT * FROM `awesome_table` WHERE `ID`=1"[/color][color=rgb(102,102,0);], .[/color][color=rgb(0,102,102);]@ID, [/color][color=rgb(102,102,0);].[/color][color=rgb(0,102,102);]@[/color]Name[color=#ff0000]$[/color], .@val1, .@val2, .@val3[color=rgb(102,102,0);]);[/color]

.@ID[0] = 1; [color=rgb(102,102,0);].[/color][color=rgb(0,102,102);]@[/color]Name$[0] = Hi

.@ID[1] = 2; [color=rgb(102,102,0);].[/color][color=rgb(0,102,102);]@[/color]Name$[0] = Hello

 

basically you just put the columns (from after select, * = all) in the second part of the query_sql command

 

$ because it is a string not an integer


Edited by Sunzuki, 30 June 2014 - 11:18 PM.


#3 joecalis

joecalis

    Member

  • Members
  • PipPip
  • 21 posts

Posted 30 June 2014 - 11:29 PM

no it wouldn't. if it would work it would be

.@tempvar$[0] = 1

.@tempvar$[1] = 2

you have to add more variables to the end.

 

query_sql[color=rgb(102,102,0);]([/color][color=rgb(0,136,0);]"SELECT * FROM `awesome_table` WHERE `ID`=1"[/color][color=rgb(102,102,0);], .[/color][color=rgb(0,102,102);]@ID, [/color][color=rgb(102,102,0);].[/color][color=rgb(0,102,102);]@[/color]Name[color=#ff0000]$[/color], .@val1, .@val2, .@val3[color=rgb(102,102,0);]);[/color]

.@ID[0] = 1; [color=rgb(102,102,0);].[/color][color=rgb(0,102,102);]@[/color]Name$[0] = Hi

.@ID[1] = 2; [color=rgb(102,102,0);].[/color][color=rgb(0,102,102);]@[/color]Name$[0] = Hello

 

basically you just put the columns (from after select, * = all) in the second part of the query_sql command

 

$ because it is a string not an integer

Thank you, just as I expected it would do that.

But now I have alot to do, because I have like 25 columns to copy.



#4 Sunzuki

Sunzuki

    Member

  • Members
  • PipPip
  • 22 posts

Posted 01 July 2014 - 12:02 AM

You could use sql command: "[color=rgb(221,0,0);font-family:'Fira Mono', 'Source Code Pro', monospace;]SHOW COLUMNS FROM sometable"[/color]



#5 joecalis

joecalis

    Member

  • Members
  • PipPip
  • 21 posts

Posted 01 July 2014 - 01:35 AM

You could use sql command: "[color=rgb(221,0,0);font-family:'Fira Mono', 'Source Code Pro', monospace;]SHOW COLUMNS FROM sometable"[/color]

But can I get the data from the columns selected and store it in an array?






1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users


This topic has been visited by 20 user(s)