# |
Aug 30th 2019, 05:20 |
javier.villanueva |
morning all |
# |
Aug 30th 2019, 05:14 |
conehead |
If that is the case I would not give the entity the logic to decide if to convert or not |
# |
Aug 30th 2019, 05:13 |
conehead |
You pull the data once and store it into database and then always view/edit them? |
# |
Aug 30th 2019, 05:13 |
turkles |
so if I need to edit entries it isn't as intensive |
# |
Aug 30th 2019, 05:13 |
turkles |
and reference my array using Entity::array |
# |
Aug 30th 2019, 05:12 |
turkles |
I suppose I could move the conversion back to where I am processing the api data |
# |
Aug 30th 2019, 05:11 |
turkles |
I use TINYINT(2) |
# |
Aug 30th 2019, 05:11 |
turkles |
TINYINT(1) yes |
# |
Aug 30th 2019, 05:11 |
conehead |
And maybe you should not use TINYINT. If I am not wrong cake will always interpret tinyint as boolean |
# |
Aug 30th 2019, 05:10 |
conehead |
Yes, once you got it correctly in the database with your int you can use the links I posted above |
# |
Aug 30th 2019, 05:09 |
turkles |
yes but then when I want to display the value back in human readable |
# |
Aug 30th 2019, 05:09 |
conehead |
Well you have to convert it somewhere. Imho it belongs where you get the data from the external api |
# |
Aug 30th 2019, 05:09 |
turkles |
based on const array() |
# |
Aug 30th 2019, 05:09 |
turkles |
and have a setter which converts text to int where it is not already int |
# |
Aug 30th 2019, 05:08 |
turkles |
https://pastebin.com/rWQTcnuS - I use virtual field for retreiving a text value |
# |
Aug 30th 2019, 05:08 |
turkles |
I think I have a solution, but it probably isn't the best |
# |
Aug 30th 2019, 05:03 |
turkles |
that looks good for where I can write the forms etc, but I don't in this case |
# |
Aug 30th 2019, 05:02 |
turkles |
I looked at that, but couldn't work out how to ensure when I save from the api data it converts from the text to an int |
# |
Aug 30th 2019, 05:01 |
conehead |
@turkles If I understood you correctly, maybe have a look at this: https://www.dereuromark.de/2010/06/24/static-enums-or-semihardcoded-attributes/ https://github.com/dereuromark/cakephp-tools/blob/master/docs/Entity/Enum.md |
# |
Aug 30th 2019, 04:50 |
turkles |
Hi all, I am grabbing data from external api - which gives me text 'status' values I want to convert to TINYINT before saving, but if I need to display show the original text. I was hoping I could do this in the entity, has anyone got examples of this? I seem to have ballsed it up so it tries to save the text, but does show text when retreiving the tinyint from db.. |
# |
Aug 29th 2019, 20:24 |
yamcomnet |
https://www.cnizz.com/yummy-demo does not seem to work |
# |
Aug 29th 2019, 20:23 |
jimbo2150 |
Granted, if you are doing searches on DATE only from a DATETIME column, make sure you have appropriate indexes that cast to DATE as well so it is not constantly going through every entry :clock130: |
# |
Aug 29th 2019, 20:23 |
cnizzardini |
i just noticed that too, i haven't really been maintaining my personal site |
# |
Aug 29th 2019, 20:22 |
cnizzardini |
yeah |
# |
Aug 29th 2019, 20:22 |
yamcomnet |
does it have time range search capabilities? |
# |
Aug 29th 2019, 20:22 |
yamcomnet |
yummySearch looks very promising. |
# |
Aug 29th 2019, 20:22 |
challgren |
@cnizzardini FYI https://www.cnizz.com/yummy-demo reports a SSL error and the redirect is all munged up |
# |
Aug 29th 2019, 20:17 |
cnizzardini |
thanks Jim |
# |
Aug 29th 2019, 20:17 |
cnizzardini |
MySQL too |
# |
Aug 29th 2019, 20:16 |
jimbo2150 |
I just checked PostgreSQL and SQLServer documentation and they both seem to support CAST( x as DATE ) - should be pretty safe. |
# |
Aug 29th 2019, 20:16 |
cnizzardini |
id have to use that func() type stuff perhaps |
# |
Aug 29th 2019, 20:16 |
yamcomnet |
would be nice to use https://github.com/ypnos-web/cakephp-datatables just have no idea about be best approach for timerange search |
# |
Aug 29th 2019, 20:15 |
ricksaccous |
i think the functions they provide are all agnostic i could be wrong though |
# |
Aug 29th 2019, 20:15 |
cnizzardini |
is DATE() a SQL standard...? |
# |
Aug 29th 2019, 20:15 |
cnizzardini |
so, i don't want to use a MySQL DATE cast, unless that is standard SQL... |
# |
Aug 29th 2019, 20:14 |
cnizzardini |
Yes, but the plugin is designed to be db agnostic |
# |
Aug 29th 2019, 20:14 |
ricksaccous |
yeah nvm lol |
# |
Aug 29th 2019, 20:14 |
ricksaccous |
hmmm maybe not |
# |
Aug 29th 2019, 20:14 |
ricksaccous |
might be able to do a datediff on a date |
# |
Aug 29th 2019, 20:13 |
ricksaccous |
https://book.cakephp.org/3.0/en/orm/query-builder.html#using-sql-functions |
# |
Aug 29th 2019, 20:13 |
jimbo2150 |
If you do a cast on the value within the database (not the value you are searching for) it should work - it should cast the database datetime to 00:00:00. |