First, I'd like to thank the developers behind Fabrik; it really is a great product.
As a general rule, when I hit a hurdle, I read the Fabrik Wiki and Forum, and of course Google is my friend, until I can find out what I've done incorrectly (although as a novice, responses on StackOverflow or reading the PHP manual is more than a little difficult to then apply to what I need to do within Fabrik).
I believe I have a syntax issue when writing the Calculation field in a Calc Element. Unfortunately, this is something I am currently developing on a WAMP server and have no way to provide access.
This is Fabrik 3.0.X and Joomla 2.5
This is what I have
$v = '{dqw3l_sis_tsh_equip_detail___id}';
$s = '{dqw3l_sis_tsh_equip_detail___alias_number_raw}';
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query
->select('r_m_category')
->from('dqw3l_sis_tsh_equip')
->where('id = ' . $db->quote($v));
$db->setQuery($query);
$category = $db->loadResult();
$query = $db->getQuery(true);
$query
->select('category_vendor')
->from('dqw3l_sis_tsh_vc')
->where('alias_number = ' . $db->quote($s))
and ('category = ' .$db->quote($category));
$db->setQuery($query);
$vendor = $db->loadResult();
return $vendor;
I can't seem to get the "and" evaluation to work. The table 'dqw3l_sis_tsh_vc' is a one to many, where one "alias_number" can relate to many "category". An "alias_number":"category" relationship will produce a single "category_vendor" value. As written, $vendor returns the same value for all "category" for a particular "alias_number". If I delete the portion "and ('category = ' .$db->quote($category))" there is no change (same value for all "category"). I have also reversed the two where statements. In that instance, it returns different "category" values, but the values are the same regardless of the "alias_number" It's demo data and the same categories repeat as the alias_number changes creating effectively the opposite effect - seemingly not using the evaluation after the "and".
I'm hoping that I'm making some obvious structural or syntax mistake; the answer may also be a simple "you can't do that, that way". Any help in correcting the structure, syntax, or pointing me to a "do it this way" code example would be greatly appreciated.
As a general rule, when I hit a hurdle, I read the Fabrik Wiki and Forum, and of course Google is my friend, until I can find out what I've done incorrectly (although as a novice, responses on StackOverflow or reading the PHP manual is more than a little difficult to then apply to what I need to do within Fabrik).
I believe I have a syntax issue when writing the Calculation field in a Calc Element. Unfortunately, this is something I am currently developing on a WAMP server and have no way to provide access.
This is Fabrik 3.0.X and Joomla 2.5
This is what I have
$v = '{dqw3l_sis_tsh_equip_detail___id}';
$s = '{dqw3l_sis_tsh_equip_detail___alias_number_raw}';
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query
->select('r_m_category')
->from('dqw3l_sis_tsh_equip')
->where('id = ' . $db->quote($v));
$db->setQuery($query);
$category = $db->loadResult();
$query = $db->getQuery(true);
$query
->select('category_vendor')
->from('dqw3l_sis_tsh_vc')
->where('alias_number = ' . $db->quote($s))
and ('category = ' .$db->quote($category));
$db->setQuery($query);
$vendor = $db->loadResult();
return $vendor;
I can't seem to get the "and" evaluation to work. The table 'dqw3l_sis_tsh_vc' is a one to many, where one "alias_number" can relate to many "category". An "alias_number":"category" relationship will produce a single "category_vendor" value. As written, $vendor returns the same value for all "category" for a particular "alias_number". If I delete the portion "and ('category = ' .$db->quote($category))" there is no change (same value for all "category"). I have also reversed the two where statements. In that instance, it returns different "category" values, but the values are the same regardless of the "alias_number" It's demo data and the same categories repeat as the alias_number changes creating effectively the opposite effect - seemingly not using the evaluation after the "and".
I'm hoping that I'm making some obvious structural or syntax mistake; the answer may also be a simple "you can't do that, that way". Any help in correcting the structure, syntax, or pointing me to a "do it this way" code example would be greatly appreciated.