# |
Feb 20th 2020, 18:34 |
jh |
i just tinkered around it it works |
# |
Feb 20th 2020, 18:22 |
phantomwatson |
I'd like to help, but I'm having a hard time understanding your question. |
# |
Feb 20th 2020, 18:11 |
jh |
damn i hate this guessing/magic :E |
# |
Feb 20th 2020, 18:02 |
jh |
in patchEntity i use 'TariffsDocuments' => ['onlyIds' => true], |
# |
Feb 20th 2020, 18:01 |
jh |
tariffs_documents._ids.0 tariffs_documents._ids.1 etc contents each is just the foreign key to the tariff document |
# |
Feb 20th 2020, 18:01 |
jh |
What could probably stop _ids BTM to save the association? |
# |
Feb 20th 2020, 17:57 |
kaliel |
:) |
# |
Feb 20th 2020, 17:57 |
wizardfix |
@kaliel yes what was I thinking! Of course I have this data from the request! Just had a blind spot lol! It all works now! :) |
# |
Feb 20th 2020, 17:45 |
slackebot |
https://github.com/cakephp/cakephp/commit/0cf9921798d823fa87b61bb93f908c57a132a53f#diff-525e59c1441ed03389d3cf0ac1198130R186 |
# |
Feb 20th 2020, 17:45 |
phantomwatson |
The core uses a colon, the letter C, and a number for placeholders. The colon, I assume is so it's easier to parse the SQL and find those placeholders. The numbers are to differentiate each placeholders from the others. But I don't know why the letter C is used. The commit history for the relevant code suggests that it might be short for "comparison". |
# |
Feb 20th 2020, 17:35 |
wizardfix |
@phantomwatson ok, great, `$query->getValueBinder()->bindings()[':c1']['value']` gets me the value in a `debug()` call so now I'll try getting it in the form. But I wonder where this `':c1'` property comes from... :thinking_face: |
# |
Feb 20th 2020, 17:32 |
kaliel |
Don't you get these values in requested data ? |
# |
Feb 20th 2020, 17:29 |
wizardfix |
Calling `toArray()` just gives me the users without the params. The situation is: 1. User selects "Inactive", "Active" or "All". These map to values 0, 1, 2 respectively. So this value is in the query object and I want to use it to prepopulate the HTML select element in the form when I return the response. ` |
# |
Feb 20th 2020, 17:27 |
phantomwatson |
It looks like all of those methods are public, so it should work. |
# |
Feb 20th 2020, 17:26 |
phantomwatson |
So I'd try `$query->getValueBinder()->bindings()` and see if that works. |
# |
Feb 20th 2020, 17:26 |
phantomwatson |
It looks like `$params` isn't part of the query object per se, but generated by its `__debugInfo()` method. That method uses `$this->getValueBinder()->bindings()` to populate `'params'`. |
# |
Feb 20th 2020, 17:25 |
phantomwatson |
Is there any way to sidestep the problem by just capturing that data at the point that the query object is being built? |
# |
Feb 20th 2020, 17:24 |
phantomwatson |
I think that John's asking about getting the parameters that were passed into the query object via the `->where()` method, not getting data from the database. |
# |
Feb 20th 2020, 17:22 |
kaliel |
`$query->toArray()` |
# |
Feb 20th 2020, 17:20 |
slackebot |
variety of ways and am not finding any good examples of getting data from a query object. I need to access this value to prepopulate a form selector. :thinking_face: |
# |
Feb 20th 2020, 17:20 |
slackebot |
'params' => [ ':c0' => [ 'value' => (int) 2, 'type' => 'tinyinteger', 'placeholder' => 'c0' ], ':c1' => [ 'value' => (int) 1, 'type' => 'tinyinteger', 'placeholder' => 'c1' ] ], 'defaultTypes' => [ 'Users__id' => 'integer', 'Users.id' => 'integer', 'id' => 'integer', 'Users__name' => 'string', 'Users.name' => 'string',``` How to I get the `'value' => (int) 1` from the `':c1'` element of `params`? I've tried a |
# |
Feb 20th 2020, 17:20 |
slackebot |
`Creators__id`, Creators.name AS `Creators__name`, Creators.email AS `Creators__email`, Creators.admin AS `Creators__admin`, Creators.password AS `Creators__password`, Creators.status AS `Creators__status`, Creators.created_by AS `Creators__created_by`, Creators.created_on AS `Creators__created_on` FROM users Users LEFT JOIN users Creators ON Creators.id = (Users.created_by) WHERE (Users.status < :c0 AND Users.status = :c1) LIMIT 30 OFFSET 0', |
# |
Feb 20th 2020, 17:20 |
wizardfix |
I have a `Query` object that starts like this: ```'(help)' => 'This is a Query object, to get the results execute or iterate it.', 'sql' => 'SELECT Users.id AS `Users__id`, Users.name AS `Users__name`, Users.email AS `Users__email`, Users.admin AS `Users__admin`, Users.password AS `Users__password`, Users.status AS `Users__status`, Users.created_by AS `Users__created_by`, Users.created_on AS `Users__created_on`, Creators.id AS |
# |
Feb 20th 2020, 17:10 |
dereuromark |
afaik they still dont use any static analyzer, e.g. phpstan, as such the functional part is also quite bad. |
# |
Feb 20th 2020, 17:10 |
dereuromark |
I know^^ worst code in general |
# |
Feb 20th 2020, 17:09 |
kaliel |
you wan to see a real mess in doc ? try symfony and its annotations :) |
# |
Feb 20th 2020, 17:08 |
dereuromark |
doc vs functional part |
# |
Feb 20th 2020, 17:07 |
dereuromark |
no, it makes them independant from the source code (and included use). |
# |
Feb 20th 2020, 17:06 |
phantomwatson |
It looks like this was added last November to the CakePHP codesniffer ruleset, and I'm _just_ now pulling those changes for some projects and noticing failing tests. Is the rationale that it makes doc comments more human-readable? |
# |
Feb 20th 2020, 16:56 |
phantomwatson |
This convention is new to me. I've always seen recommendations to put the fully-qualified names in `use` statements at the top to simplify the rest of your code. PhpStorm kind of nags me with notifications to do that, too. Is there some pitfall to that approach that I've been overlooking? |
# |
Feb 20th 2020, 16:53 |
dereuromark |
sure, always use fqcn here |
# |
Feb 20th 2020, 16:53 |
slackebot |
Class name \Cake\Mailer\Mailer in @return should be referenced via a fully qualified name. |
# |
Feb 20th 2020, 16:53 |
phantomwatson |
Anyone see this PHP codesniffer error before? This code: ```declare(strict_types=1); namespace App\Mailer; use Cake\Mailer\Mailer; class AdminAlertMailer extends Mailer { ... /** * Sets mailer configuration shared by multiple methods in this class * * @param array $data Metadata * @return Mailer */ private function setStandardConfig($data) { ...``` generates this codesniffer violation: > |
# |
Feb 20th 2020, 16:04 |
spriz |
In default cake it means something and in that otherwise awesome app template it means something else - rather contradictory I'd say :) |
# |
Feb 20th 2020, 16:04 |
spriz |
On another note - is it just me or is this a bit confusing? :) https://github.com/josegonzalez/app/blob/master/src/Controller/AppController.php#L66-L72 vs https://book.cakephp.org/3/en/controllers/components/authentication.html#configuration-options |
# |
Feb 20th 2020, 16:00 |
sdevore |
I made a trait for that ;) |
# |
Feb 20th 2020, 15:59 |
spriz |
Ah yes, that could work but I'd still have to manually set variables for 'success' and 'data' for the response :S |
# |
Feb 20th 2020, 15:59 |
sdevore |
you may be able to use something like that with out the extract step |
# |
Feb 20th 2020, 15:58 |
sdevore |
@spriz I have done a trick like this |
# |
Feb 20th 2020, 15:55 |
spriz |
I would like to just tap into all existing crud logic about failed saves for an entity with 422 http response code etc |
# |
Feb 20th 2020, 15:54 |
spriz |
I could do a Modelless Form AFAIK - but it just seems like a lot of work |