How to get data from database - Forum

Forum Navigation
You need to log in to create posts and topics.

How to get data from database

Hi Luis,

I try the load data from a mysql database.I see the examples and configure everything as they show.

the query I use is the following:

$sqlAlias[0]="getcomname";
$sqlQuerys[0]="SELECT `value` FROM `llxyb_const` WHERE `name` = 'MAIN_INFO_SOCIETE_NOM'";
$sqlMaxUserLevel[0]=-1;

and the subroutine(getcomname) I use is:

CreateEmptyArray [tableData]
SetVar [tableData] [data]
ArrayLen [tableData] [totalRecords]
SetVar [currentRecord] 0
SetVar [comname] [tableData(0)('value')]

the result is only one value (actually is a company name)

I try many hours and make a lot of compinations but no luck to take the result value.

What I do wrong please help?

 

Hi @ecotip

Thats exactly what you are asking for in your SQL query:

SELECT `value` FROM `llxyb_const` WHERE `name` = 'MAIN_INFO_SOCIETE_NOM'

In plain english your SQL is telling the database to get the value from the "value" field within the "llxyb_const" table only for the record which "name" field is exactly "MAIN_INFO_SOCIETE_NOM".

You should use something like this to get all the information from the table:

SELECT * FROM 'llxyb_const'

If you want to get information from some records use the "?" symbol instead of a real value so you can send it from your App.
Please take a look at this thread for more information:
https://visualneo.com/forum/topic/tuto-database

Regards.

Hi Luis,

thank you for your answer the problem was that on subroutine I create I did not notice I have to create variable alias for the variable I use to get data from database.

When create it everything worked fine.

You must find little time to make a full tutorial about databases and how to work with them.

Thank you very much for your help.