# |
Jul 19th 2017, 08:43 |
saeideng |
if someone use `contain` for nested association(more than 3 table) with different type of association connect |
# |
Jul 19th 2017, 08:40 |
saeideng |
i have a question |
# |
Jul 19th 2017, 08:38 |
neon1024 |
I can only assume it’s the EagerLoader |
# |
Jul 19th 2017, 08:38 |
neon1024 |
Why does a call to `contain()` need a data source configuration? |
# |
Jul 19th 2017, 08:38 |
rogerpro |
Maybe, instead, ->sum() could make the conversion to sum time properly when summing MySQL time fields. Do you think guys that this would success as a PR? |
# |
Jul 19th 2017, 08:38 |
rogerpro |
Those SEC_TO_TIME() and TIME_TO_SEC() functions are not implemented on CakePHP (https://book.cakephp.org/3.0/en/orm/query-builder.html#using-sql-functions). |
# |
Jul 19th 2017, 08:37 |
rogerpro |
I need to use SEC_TO_TIME() and TIME_TO_SEC() MySQL functions but then the app becomes not portable to PostgreSQL; so finally I will save and sum seconds. The simples the better :slightly_smiling_face: |
# |
Jul 19th 2017, 08:37 |
slackebot |
SEC_TO_TIME(SUM(TIME_TO_SEC(foo))) FROM test_time_sum; ` |
# |
Jul 19th 2017, 08:37 |
rogerpro |
Hi folks! Just a tip because I spent some time with this: be aware that MySQL is not summing time values as (I) expected. `/* MySQL test_time_sum */ CREATE TABLE test_time_sum ( id int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY, foo time ); INSERT INTO test_time_sum VALUES (1, ‘00:00:55’), (2, ‘00:00:13’), (3, ‘00:09:51’); /* returns 1019; expected 10:59 */ SELECT SUM(foo) FROM test_time_sum; /* returns 10:59 as expected */ S |
# |
Jul 19th 2017, 08:36 |
saeideng |
you can send `html` or `json` in cell,helper and controller |
# |
Jul 19th 2017, 08:35 |
neon1024 |
Plus it avoids the problem of introducing HTML markup into your javascript |
# |
Jul 19th 2017, 08:33 |
maymeow |
old but i like it because i can use helpers from cakephp ;) |
# |
Jul 19th 2017, 08:32 |
admad |
and yeah returning html fragments is old school. Return a json object and build required dom elements on client side |
# |
Jul 19th 2017, 08:31 |
admad |
returning html for ajax request is not different than return html for a normal request, using cell or otherwise. Only difference is for you case you return only required html fragment instead of full html document |
# |
Jul 19th 2017, 08:28 |
maymeow |
so... its possible to get cell over ajax or i have to call for json and render it with VueJS for example? |
# |
Jul 19th 2017, 08:26 |
admad |
afaik that's not possible |
# |
Jul 19th 2017, 08:24 |
ldsign |
(so cascade operations work) |
# |
Jul 19th 2017, 08:24 |
ldsign |
Do you know how to set such a foreign key constraint in mysql...so a joined foreignKey with "model"-column and "foreign_key"-column? |
# |
Jul 19th 2017, 08:23 |
hmic |
this said: cells are not meant to be accessed via ajax, but used inside your templates |
# |
Jul 19th 2017, 08:22 |
ldsign |
This approach works :slightly_smiling_face: Is it possible to get the model name which has triggered the save operation here? E.g. get Companies alias in Addresses beforeSave... |
# |
Jul 19th 2017, 08:16 |
admad |
also if you want the html you have to render() the cell, what you have shown above is the cell object itself. |
# |
Jul 19th 2017, 08:08 |
hmic |
turn it into an action callable from the web |
# |
Jul 19th 2017, 08:07 |
maymeow |
how can i do this??? `$this->set('html', $this->viewBuilder()->build()->cell('CakeStorage.Projects', ['2']));` ? |
# |
Jul 19th 2017, 08:07 |
maymeow |
I need update View Cell over AJAX call |
# |
Jul 19th 2017, 08:01 |
saeideng |
3.4.0 Mutable response methods are deprecated. Use withBody() and getBody() instead. |
# |
Jul 19th 2017, 08:01 |
saeideng |
Deprecated |
# |
Jul 19th 2017, 07:56 |
saeideng |
probably you need return `$request` |
# |
Jul 19th 2017, 07:52 |
mriec |
Oh I think I found it in docs. let me try |
# |
Jul 19th 2017, 07:50 |
mriec |
any further information? I have updated from lower version of CakePHP, I do not even have an Application class. what should I do? |
# |
Jul 19th 2017, 07:45 |
neon1024 |
Perhaps you need to enable the PSR7 middleware |
# |
Jul 19th 2017, 07:34 |
mriec |
it works fine when I use old $response->body() method |
# |
Jul 19th 2017, 07:31 |
mriec |
hello guys. How can I change response body since 3.4.0? In my component's shutdown event I have $controller->response = $controller->response->withStringBody($modifiedBody); rendered page is not modified. $modifiedBody does contain what I want when I debug it. any hint? |
# |
Jul 19th 2017, 07:01 |
ldsign |
Ok fine :slightly_smiling_face: |
# |
Jul 19th 2017, 07:00 |
admad |
i wouldn't use join table :slightly_smiling_face: |
# |
Jul 19th 2017, 06:59 |
admad |
you can set the model in beforesave |
# |
Jul 19th 2017, 06:59 |
ldsign |
Or is a join table (Addresses-ForeignModel) a better way? |
# |
Jul 19th 2017, 06:58 |
ldsign |
Ok, thanks. And how can I achieve that on every save operation the Addresses.model will be injected? Is there an automatic way or should I use beforeSave for that? |
# |
Jul 19th 2017, 06:57 |
admad |
you can use $this->alias() instead of 'Companies' |
# |
Jul 19th 2017, 06:57 |
admad |
@ldsign nothing wrong with thats, that how you handle polymorphic relations |
# |
Jul 19th 2017, 06:07 |
ldsign |
Ive tried it with'$this->hasMany('Addresses', [ 'foreignKey' => 'foreign_key', 'conditions' => ['Addresses.model' => 'Companies'] ]);' |
# |
Jul 19th 2017, 06:06 |
ldsign |
Hi. Say I have an Addresses model which stores street, zipcode, city a.s.o. and I would like to attach this model to several other models (e.g. company, user) so one ore more address could be saved for this model...how can I achieve this? And whats the name of such a relation? Polymorphic? |