Forums

Where conditions in cc v5

vales 07 Feb, 2014
In chronoconnectivity v4 was possible to use SQL functions and comparison operators <>! or etc. To construct complex queries
This is an example of code used

(((MONTH (dates) = MONTH (now ()) AND YEAR (dates) = YEAR (now ()) AND enddates = '0000-00-00 ') OR (MONTH (now ()) BETWEEN MONTH (dates) AND MONTH (enddates) AND YEAR (now ()) BETWEEN YEAR (dates) AND YEAR (enddates))))

How can I do this with version 5
Max_admin 10 Feb, 2014
Hi Vales,

Please try this, you must have the last version:

<?php
return array(":(((MONTH (dates) = MONTH (now ()) AND YEAR (dates) = YEAR (now ()) AND enddates = '0000-00-00 ') OR (MONTH (now ()) BETWEEN MONTH (dates) AND MONTH (enddates) AND YEAR (now ()) BETWEEN YEAR (dates) AND YEAR (enddates))))");
?>


Pay attention to the quotes, no values will be escaped in this string since it starts with ":", so any user entered values must be escaped.

You can escape values using this:

\GCore\Models\MODEL_ID::getInstance()->dbo->quote("value here");


Regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
vales 10 Feb, 2014
Thank you very much. Now I'll take practice tests for the new.

hi, Valerio
vales 11 Feb, 2014
I did some basic tests.

With the new method it is necessary to use the model to define the fields

eg. model = test

return array (":test.id>". JRequest :: getvar ('rec','', 'get'));
return array (":test.id prova.id = 2 or test.id = 3");


This are ok.

I did not understand the use of the other method

\GCore\Models\MODEL_ID::getInstance()->dbo->quote("value here");
This topic is locked and no more replies can be posted.