Custom sql query for getting values of a checkbox field

More
11 years 3 months ago - 11 years 1 month ago #51289 by rafah
Hi,

I have created a checkbox field in my application.I have added multiple values to it through admin panel in this field.My question is how to get these values(also insert new values) and corresponding text from database by using custom sql query.Please help me
Last edit: 11 years 1 month ago by rafah.

Please Log in or Create an account to join the conversation.

More
11 years 3 months ago #51295 by micker
read config of sql value input all is in
ex :

This mode allows you to build the list dynamically with SQL queries. If you select this mode, put you query in the field elements. It must return a text and a value, for example SELECT id AS value, name AS text from #__users . You can put replacement of item data like: {item->created_by} {item->catid} etc and field replacement like: {field->id} etc and for language (in frontend) like: {curr_userlang_shorttag} {curr_userlang_fulltag}


FLEXIcontent is Free but involves a very big effort on our part.
Like the our support? (for a bug-free FC, despite being huge extension) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing reviews. Thanks![/size]

Please Log in or Create an account to join the conversation.

More
11 years 1 month ago #52116 by rafah
Hi,

Still I dint get an idea.sorry.
The value I am having in database is

{"display_label":"1","show_acc_msg":"0","no_acc_msg":"","sql_mode":"0","field_elements":"1::Hair Salon%% 2::Unisex Salon%% 3::Spa Service%% 4::Skin care%%5::Hair Colouring%% 6::Manicure & Pedicure%%7::Foot massage%%8::Gym Service%%9::Luxury Spa%%","text_or_value":"1","display_all":"0","trigger_onprepare_content":"0","remove_space":"0","pretext":" ","posttext":":","separatorf":"5","opentag":"Category-","closetag":"","ns_pretext":"","ns_posttext":"","default_values":"","required":"0","pretext_form":"","posttext_form":"","separator":"0","opentag_form":"","closetag_form":"","max_values":"0","min_values":"0","exact_values":"0","filter_customize_options":"0","filter_custom_options":"SELECT value, value as text FROM #__flexicontent_fields_item_relations WHERE field_id='{field_id}' AND value != '' GROUP BY value","filter_default_value":"","filter_usefirstoption":"1","filter_firstoptiontext":"FLEXI_ALL","filter_compare_type":"0","filter_values_require_all":"0","filter_values_require_all_tip":"0","display_label_filter":"2","display_filter_as":"4","faceted_filter":"2","show_matching_items":"1","hide_disabled_values":"0","display_label_filter_s":"2","display_filter_as_s":"0","faceted_filter_s":"2","show_matching_items_s":"1","hide_disabled_values_s":"0"}


From this how can I get text values of 1,2,3 for eg.hair salon,unisex salon,spa service.etc

Please Log in or Create an account to join the conversation.

More
11 years 1 month ago #52132 by micker
put your sql request

FLEXIcontent is Free but involves a very big effort on our part.
Like the our support? (for a bug-free FC, despite being huge extension) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing reviews. Thanks![/size]

Please Log in or Create an account to join the conversation.

More
11 years 1 month ago #52135 by rafah
Hi,

sorry I dint get it.I tried your query.But I am not getting the text value.

Please Log in or Create an account to join the conversation.

More
11 years 1 month ago #52151 by micker
its an exemple :lol:

FLEXIcontent is Free but involves a very big effort on our part.
Like the our support? (for a bug-free FC, despite being huge extension) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing reviews. Thanks![/size]

Please Log in or Create an account to join the conversation.

More
11 years 1 month ago #52175 by rafah
This is my sql query.

SELECT attribs FROM `xrlwc_flexicontent_fields` WHERE id=17


Then result is

{"display_label":"1","show_acc_msg":"0","no_acc_msg":"","sql_mode":"0","field_elements":"1::Hair Salon%% 2::Unisex Salon%% 3::Spa Service%% 4::Skin care%%5::Hair Colouring%% 6::Manicure & Pedicure%%7::Foot massage%%8::Gym Service%%9::Luxury Spa%%","text_or_value":"1","display_all":"0","trigger_onprepare_content":"0","remove_space":"0","pretext":" ","posttext":":","separatorf":"5","opentag":"Category-","closetag":"","ns_pretext":"","ns_posttext":"","default_values":"","required":"0","pretext_form":"","posttext_form":"","separator":"0","opentag_form":"","closetag_form":"","max_values":"0","min_values":"0","exact_values":"0","filter_customize_options":"0","filter_custom_options":"SELECT value, value as text FROM #__flexicontent_fields_item_relations WHERE field_id='{field_id}' AND value != '' GROUP BY value","filter_default_value":"","filter_usefirstoption":"1","filter_firstoptiontext":"FLEXI_ALL","filter_compare_type":"0","filter_values_require_all":"0","filter_values_require_all_tip":"0","display_label_filter":"2","display_filter_as":"4","faceted_filter":"2","show_matching_items":"1","hide_disabled_values":"0","display_label_filter_s":"2","display_filter_as_s":"0","faceted_filter_s":"2","show_matching_items_s":"1","hide_disabled_values_s":"0"}


How to get only text values from this?

Please Log in or Create an account to join the conversation.

More
11 years 1 month ago #52186 by ggppdk
Hello

attribs is not the value of the field

it is the parameters


you should use "value" column


-- Flexicontent is Free but involves a big effort on our part.
Like the our support? (for a bug-free FC, despite having a long list of functions) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing with a 5-star review. Thanks!

Please Log in or Create an account to join the conversation.

More
11 years 1 month ago #52190 by rafah
Hi,

Then how to get the predefined values of this checkbox field.All value to text relations?

value column is present in xrlwc_flexicontent_fields_item_relations.Here only the number value is present.How to get its corresponding text?

when I use this query,I get only numbers
SELECT value as text FROM `xrlwc_flexicontent_fields_item_relations` where field_id=17 and item_id=1.

how to do this?please help me

Please Log in or Create an account to join the conversation.

More
11 years 1 month ago #52194 by ggppdk
Hello


the easiest way is to use FLEXIcontent helper functions


-- but first tell where do you need this ?

1. is it inside a FLEXIcontent component view (item view, category view, search view, etc ?)

2. is it inside any Joomla view ?

3. is it inside some custom script that does not load Joomla Framework ?



-- the Field configuration is in 1 table:
_flexicontent_fields


-- and the values are inside:
_flexicontent_fields_item_relations



you can use this:
www.flexicontent.org/documentation/faq/ ... -code.html


then you can use this for parameters:
$p = $item->fields->parameters->get('VARIABLE');




and this for values:
$field_id = 19;

// Use in ITEM view
$fvals = $item->fieldvalues[$field_id]; // or use $this->item


// Use in CATEGORY view (and in category layouts: author, mcat, myitems)
$fvals = $items[$i]->fieldvalues[$field_id]; // or use $item

if (!empty($fvals)) foreach ($fvals as $v) {
if ( @unserialize($v)!== false || $v=== 'b:0;' ) $v = unserialize($v);
var_dump($v);
}


-- Flexicontent is Free but involves a big effort on our part.
Like the our support? (for a bug-free FC, despite having a long list of functions) Like the features? Like the ongoing development and future commitment to FLEXIcontent?
-- Add your voice to the FLEXIcontent JED listing with a 5-star review. Thanks!

Please Log in or Create an account to join the conversation.

Moderators: vistamediajoomlacornerggppdk
Cookies user preferences
We use cookies to ensure you to get the best experience on our website. If you decline the use of cookies, this website may not function as expected.
Accept all
Decline all
Essential
These cookies are needed to make the website work correctly. You can not disable them.
Display
Accept
Analytics
Tools used to analyze the data to measure the effectiveness of a website and to understand how it works.
Google Analytics
Accept
Decline
Save