# |
May 2nd 2019, 10:54 |
neon1024 |
https://book.cakephp.org/3.0/en/orm/database-basics.html#data-types |
# |
May 2nd 2019, 10:53 |
neon1024 |
@hippo In your table class, you’d specify in the schema that the field is an int and not a date |
# |
May 2nd 2019, 10:53 |
slackebot |
<yannickfogang> |
# |
May 2nd 2019, 10:53 |
yannickfogang |
Hello everyone, I used PDO directly in a model Cakephp to make a request a little complex and for reasons of performance, after that my Models lose the connection to my database, how can I reconnect my Models automatically? |
# |
May 2nd 2019, 10:48 |
hippo |
Is there a way to map the it like `['date' => 'integer']` |
# |
May 2nd 2019, 10:47 |
hippo |
for something like that though |
# |
May 2nd 2019, 10:47 |
hippo |
``` ->select([ 'date' => $queryDate ]) ``` |
# |
May 2nd 2019, 10:45 |
neon1024 |
I tend to use type for Telephone, Postcode, and EncryptedString :slightly_smiling_face: |
# |
May 2nd 2019, 10:45 |
neon1024 |
You can create your own Type classes |
# |
May 2nd 2019, 10:43 |
hippo |
to avoid errors like > Notice (8): Undefined index: "date" [CORE/src/Database/FieldTypeConverter.php, line 81] |
# |
May 2nd 2019, 10:42 |
hippo |
Is there a way I can add to the typeMap of a query? |
# |
May 2nd 2019, 10:12 |
hippo |
Going to go with the second one for now :slightly_smiling_face: |
# |
May 2nd 2019, 10:11 |
hippo |
Only that last one worked.. Tried this as well (`->func()->extract('dow', 'Test.timestamp', ['Test.timestamp' => 'literal']);`) |
# |
May 2nd 2019, 10:08 |
hippo |
Would a function like this quote identifiers? (with identifier quoting enabled) ``` ->func()->extract('dow', 'Test.timestamp') ``` Or would this be correct? ``` ->func()->extract('dow', new \Cake\Database\Expression\IdentifierExpression('Test.timestamp')) ``` |
# |
May 2nd 2019, 09:49 |
conehead |
Similar to what I got, but still a bit more clever. Will adjust my code! |
# |
May 2nd 2019, 09:44 |
conehead |
Looks exactly like what I was looking for ;) |
# |
May 2nd 2019, 09:44 |
conehead |
Cheers! I will have a look |
# |
May 2nd 2019, 09:43 |
dereuromark |
Sandbox shows the examples, and Setup plugin has a demo bake template that can auto create everything including forms for it based on the methods. |
# |
May 2nd 2019, 09:42 |
dereuromark |
See either different enum behavior strategies in awesome list, or use what I recommend and call semi-static-enums ( https://www.dereuromark.de/2010/06/24/static-enums-or-semihardcoded-attributes/ ), I use entities for it. |
# |
May 2nd 2019, 09:34 |
conehead |
Hm just wondering....if you have an integer field in a model and each value stands for a specific string. where would you put the logic to transform the integer value to the correct string. Create a helper for that specific model that turns 1 => 'Foo', 2 => 'Bar'? |
# |
May 2nd 2019, 09:15 |
neon1024 |
Could do with a logo update I guess :thinking_face: |
# |
May 2nd 2019, 09:14 |
neon1024 |
https://www.openhub.net/p/cakephp |
# |
May 2nd 2019, 09:14 |
neon1024 |
I was looking at the project openhub page |
# |
May 2nd 2019, 09:01 |
admad |
"COCOMO model" I vaguely remember that term from college days :P |
# |
May 2nd 2019, 08:43 |
conehead |
Haha. I might join one day |
# |
May 2nd 2019, 08:42 |
neon1024 |
Will be an exciting moment when CakePHP breaks 1000 contributors |
# |
May 2nd 2019, 08:41 |
neon1024 |
To build CakePHP |
# |
May 2nd 2019, 08:41 |
neon1024 |
> took an estimated 54 years of effort (COCOMO model) |
# |
May 2nd 2019, 08:05 |
neon1024 |
Morning everyone :wave: |
# |
May 2nd 2019, 06:49 |
conehead |
Still don't really get what you mean. Timestamp is just an integer value. So yes, mysql and cakephp should not care at all |
# |
May 2nd 2019, 06:49 |
COOurb |
aha, it works, thanks |
# |
May 2nd 2019, 06:48 |
COOurb |
does* |
# |
May 2nd 2019, 06:48 |
COOurb |
dow it works with mysql+cakephp stuff? |
# |
May 2nd 2019, 06:47 |
conehead |
dont really get what you want. Why can't you just use php `time()` method? |
# |
May 2nd 2019, 06:40 |
COOurb |
and that sucks |
# |
May 2nd 2019, 06:40 |
COOurb |
I can't iuse behavior without enity |
# |
May 2nd 2019, 06:35 |
COOurb |
how t oset current timestamp in query builder? set(['updated'=>???]) |
# |
May 2nd 2019, 05:39 |
ra7bi |
@dakota @conehead Thanks , at the end i must have two query and combine them to select list |
# |
May 2nd 2019, 05:32 |
slackebot |
``` |
# |
May 2nd 2019, 05:32 |
conehead |
@ra7bi Never tried, but there seems to be a `toList()` method as well. https://book.cakephp.org/3.0/en/orm/retrieving-data-and-resultsets.html#using-finders-to-load-data ``` / Calling all() will execute the query // and return the result set. $results = $query->all(); // Once we have a result set we can get all the rows $data = $results->toList(); // Converting the query to a key-value array will also execute it. $data = $query->toArray(); |
# |
May 2nd 2019, 04:35 |
dakota |
@ra7bi |