# |
Jul 5th 2018, 08:58 |
steinkel |
a better answer could be found here > https://stackoverflow.com/questions/30845997/how-to-generate-sql-function-calls-with-the-cakephp-query-builder |
# |
Jul 5th 2018, 08:45 |
liaogz82 |
ah ok ok thanks! |
# |
Jul 5th 2018, 08:44 |
steinkel |
@liaogz82 last resort is format your query this way `$t->find()->select(["time_worked" => "TIMEDIFF(DATE_FORMAT(modified, '%H:%i'), DATE_FORMAT(created, '%H:%i'))"])` but keep in mind you'll need to escape variables if any |
# |
Jul 5th 2018, 08:44 |
portilloster |
I believe I need to use some helper but I cannot find any up to date related information. |
# |
Jul 5th 2018, 08:43 |
portilloster |
Any ideas on how to save an show rich html text? |
# |
Jul 5th 2018, 08:43 |
portilloster |
Hi to all! |
# |
Jul 5th 2018, 08:40 |
tim |
It also supports times |
# |
Jul 5th 2018, 08:40 |
tim |
`dateDiff() Get the difference between two dates/times` |
# |
Jul 5th 2018, 08:37 |
liaogz82 |
no example for `TIMEDIFF(DATE_FORMAT(transactions.modified, '%H:%i'), DATE_FORMAT(transactions.created, '%H:%i')) as time_worked` |
# |
Jul 5th 2018, 08:35 |
liaogz82 |
@steinkel seems that the query builder do not have `TIMEDIFF` |
# |
Jul 5th 2018, 08:12 |
steinkel |
@liaogz82 check https://book.cakephp.org/3.0/en/orm/query-builder.html#using-sql-functions |
# |
Jul 5th 2018, 08:11 |
liaogz82 |
and I need the query to work with the CsvView to export data |
# |
Jul 5th 2018, 08:05 |
neon1024 |
Morning all :wave: |
# |
Jul 5th 2018, 07:57 |
liaogz82 |
it is a mysql query |
# |
Jul 5th 2018, 07:56 |
slackebot4 |
sites, transactions where employees.id = transactions.employee_id and sites.id = transactions.site_id; ``` |
# |
Jul 5th 2018, 07:56 |
liaogz82 |
how to I translate this in the cakephp query form?? ``` select employees.pin_code, employees.name, DATE_FORMAT(transactions.created, '%d-%b-%Y') as date, DATE_FORMAT(transactions.created, '%H:%i') as time_in, DATE_FORMAT(transactions.modified, '%H:%i') as time_out, TIMEDIFF(DATE_FORMAT(transactions.modified, '%H:%i'), DATE_FORMAT(transactions.created, '%H:%i')) as time_worked, sites.name as site from employees, |
# |
Jul 5th 2018, 07:56 |
liaogz82 |
hi guys I need some help in the cakephp query |
# |
Jul 5th 2018, 00:48 |
ricksaccous |
it seems i needed to specify an array in the type method which shows up as deprecated... |
# |
Jul 5th 2018, 00:48 |
ricksaccous |
https://book.cakephp.org/3.0/en/controllers/request-response.html#dealing-with-content-types |
# |
Jul 5th 2018, 00:45 |
ricksaccous |
hmm that didn't seem to help |
# |
Jul 5th 2018, 00:42 |
ricksaccous |
text/csv |
# |
Jul 5th 2018, 00:42 |
ricksaccous |
csv/text instead |
# |
Jul 5th 2018, 00:42 |
ricksaccous |
actually it seems i should be using uhhh |
# |
Jul 5th 2018, 00:40 |
ricksaccous |
if I just do $response->type('csv') it seems to work... and change $response->getType(); to the proper type |
# |
Jul 5th 2018, 00:35 |
ricksaccous |
am i misunderstanding the function of withType? |
# |
Jul 5th 2018, 00:35 |
ricksaccous |
when i do $response->withType('csv'); and then $response->getType(); it still returns text/html |
# |
Jul 5th 2018, 00:34 |
ricksaccous |
I'm doing $reponse->getType(); and by default it's text/html |
# |
Jul 5th 2018, 00:34 |
ricksaccous |
in the use Cake\Http\Response class |
# |
Jul 5th 2018, 00:33 |
ricksaccous |
about to celebrate the 4th but i'm curious about something |
# |
Jul 4th 2018, 22:33 |
ojtibi |
@josbeir yes, but I found other core classes referring to `new CakeRequest()` by name. I doubt I can do a drop-in extended replacement for CakeRequest without modifying other files. Eg: `Object::requestAction()` has `new CakeRequest()` somewhere in its body. Unfortunately it's exactly requested actions and query strings I'm having problems with. I'm not sure if I can easily upgrade to the 2.9 series at the moment. |
# |
Jul 4th 2018, 21:08 |
michaelze |
@admad thanks for your help! Going to bed now ;) gn8! |
# |
Jul 4th 2018, 20:51 |
michaelze |
and essentially duplicate the code but not quite (validation vs. application rule) |
# |
Jul 4th 2018, 20:51 |
michaelze |
okay, so that means I also have to convert not empty or format (e.g. date) validations to application rules... |
# |
Jul 4th 2018, 20:50 |
admad |
"validation on create and application rule on edit" |
# |
Jul 4th 2018, 20:47 |
michaelze |
@admad thanks for your reply. Please see my latest comment on the question. The problem that I have now, is that the application rules don't execute until all the validations succeed... |
# |
Jul 4th 2018, 20:47 |
admad |
or validation on create and application rule on edit |
# |
Jul 4th 2018, 20:46 |
admad |
@michaelze you need to use application rule instead of validatoin |
# |
Jul 4th 2018, 18:55 |
michaelze |
I'm trying to solve a problem that I have regarding the interaction between validations and application rules. I already posted a question on stackoverflow (https://stackoverflow.com/questions/51124471/validate-against-not-edited-properties). I would really appreciate any input on that... Thx :slightly_smiling_face: |
# |
Jul 4th 2018, 16:44 |
flavius |
such confuse. |
# |
Jul 4th 2018, 16:44 |
flavius |
i always get it the 2nd or 3rd try myself, never the 1st try |
# |
Jul 4th 2018, 16:43 |
flavius |
heaven forbid you pluralize the model word to models, that wouldn't work either :P |