Buy Now
Sign in

Example of sql data

ieraora , November 07 2021, 06:44
I
ieraora 169
November 07 2021, 06:44 #397358
Hello, Can I have an example of sql data in Actions Area:
I try, for example, this:
SELECT `Prezzi1`.`cf_id` AS `Prezzi1.cf_id`, `Prezzi1`.`g_id` AS `Prezzi1.g_id` FROM `#_cf_product_data-2` AS `Prezzi1`;
but I don't see in debug the 'Model' that i can use, for example {var:Prezzi1.cf_id}.
Thank you.
S
shahabpk 94
November 16 2021, 17:03 #397410
note the action name. It will be like sql_data_1 or something similar. Then you can access the data by using the short code like
{var:sql_data_1.0.fieldname} 
0 indicates the row number in the array
I
ieraora 169
November 16 2021, 19:18 #397412
Thank You shahabpk for Reply.
Is correct with simple query, but if I've for example:
SELECT `Prezzi1`.`cf_id` AS `Prezzi1.cf_id`, `Prezzi1`.`g_id` AS `Prezzi1.g_id`, `Galleria`.`nome_galleria` AS `Galleria.nome_galleria`
FROM `xijhd_cf_product_data-2` AS `Prezzi1` LEFT JOIN `xijhd_cf_gallerie` AS `Galleria` ON `Prezzi1`.`g_id` = `Galleria`.`id_galleria`;
the debug is
[sql_data_100] => Array
(
[result] => SQL processed successfully!
[sql] => SELECT `Prezzi1`.`cf_id` AS `Prezzi1.cf_id`, `Prezzi1`.`g_id` AS `Prezzi1.g_id`, `Galleria`.`nome_galleria` AS `Galleria.nome_galleria`
FROM `xijhd_cf_product_data-2` AS `Prezzi1` LEFT JOIN `xijhd_cf_gallerie` AS `Galleria` ON `Prezzi1`.`g_id` = `Galleria`.`id_galleria`;
[mode] => select
[var] => Array
(
[0] => Array
(
[Prezzi1.cf_id] => 3228
[Prezzi1.g_id] => 1126
[Galleria.nome_galleria] => Galleria di prova
)

[1] => Array
(
[Prezzi1.cf_id] => 3229
[Prezzi1.g_id] => 1126
[Galleria.nome_galleria] => Galleria di prova
And if I use {var:sql_data_100.0.Galleria.nome_galleria} my result is blank.
GreyHead 65
November 17 2021, 18:50 #397418
Hi ieraora,
I suspect that the problem may be the . in the item names which is breaking the parsing. Please can you try something like SELECT `Prezzi1`.`cf_id' AS 'cf_id`, 'g_id' AS 'Prezzi1.g_id', 'Galleria'.'nome_galleria' AS 'nome_galleria'
That is replacing e.g. AS 'Prezzi1.cf_id` with AS 'cf_id'
Bob
If you'd like to buy me a coffee or two, thank you very much
I
ieraora 169
November 17 2021, 22:19 #397419
I try to use custom because I need to have this result:
1 - A list of products, that I done with REPEATER AREA.
2 - For every product, a dropdown of a list of prices.
I tried also with read data > relations, but I think that is necessary use a CONCAT?
If yes, where I configure this?
GreyHead 65
November 18 2021, 09:43 #397421
Hi ieraora,
Have you tried the change I suggested?
Sorry, but I don't understand your last post. What exactly is the problem you have there?
Bob
If you'd like to buy me a coffee or two, thank you very much
S
shahabpk 94
December 09 2021, 16:51 #397542
This is similar to the help I asked six months before
Hope someone can help help us. I think a solution to this question makes a lot of complex job easier for lots of people.
waiting for Max !
S
shahabpk 94
December 10 2021, 05:19 #397548
Hi ieraora,
As GreyHead suggested the issue is with using table aliases with coloumn name in SQL data. I think Model concept is not applicable to SQL data action . if you use custom name for coloumns it will work. use it like
SELECT `Prezzi1`.`cf_id` AS `cf_id`, `Prezzi1`.`g_id` AS `g_id`, `Galleria`.`nome_galleria` AS `nome_galleria`FROM `xijhd_cf_product_data-2` AS `Prezzi1` LEFT JOIN `xijhd_cf_gallerie` AS `Galleria` ON `Prezzi1`.`g_id` = `Galleria`.`id_galleria`
and use {var:sql_data_100.0.nome_galleria} will return first row data. I tested it and worked
I
ieraora 169
December 13 2021, 12:01 #397592
Hi shahabpk, thank you for your reply.
Is correct yours info. I thought to have a print of Model name, because I wanted get this for Dropdown Dynamic selection.
I am now following another way.
Thank you