# |
May 5th 2021, 14:02 |
me1367 |
Which is what I'm trying to do but it won't let me (due to this error) |
# |
May 5th 2021, 14:00 |
ndm |
You need to update all your dependencies to compatible versions at once, cakephp, plugins, etc. |
# |
May 5th 2021, 13:55 |
me1367 |
*mild internal annoyance* |
# |
May 5th 2021, 13:40 |
me1367 |
Well, I'm trying to update CakePHP of my main project (my website) to CakePHP 4.x but for that I need to also update some plugins I maintain but it gets all blocked because those plugins rely on CakePHP 3.x and Composer refuses to update to the correct branches (which increase the constraint to `^4.2.5` |
# |
May 5th 2021, 13:37 |
slackebot |
your requirements or minimum-stability. - Installation request for admiral/admiral (locked at dev-master, required as dev-77-make-compatible-with-cakephp-4-x) -> satisfiable by admiral/admiral[dev-master].``` I need to update the package to branch version `dev-77-make-compatible-with-cakephp-4-x` so that I can actually start making it compatible with CakePHP 4.x... |
# |
May 5th 2021, 13:37 |
slackebot |
3.6.3, 3.6.4, 3.6.5, 3.6.6, 3.6.7, 3.6.8, 3.6.9, 3.7.0, 3.7.0-RC1, 3.7.0-RC2, 3.7.0-RC3, 3.7.0-beta1, 3.7.1, 3.7.2, 3.7.3, 3.7.4, 3.7.5, 3.7.6, 3.7.7, 3.7.8, 3.7.9, 3.8.0, 3.8.0-RC1, 3.8.0-RC2, 3.8.0-RC3, 3.8.0-beta1, 3.8.1, 3.8.10, 3.8.11, 3.8.12, 3.8.13, 3.8.2, 3.8.3, 3.8.4, 3.8.5, 3.8.6, 3.8.7, 3.8.8, 3.8.9, 3.9.0, 3.9.0-RC1, 3.9.0-RC2, 3.9.1, 3.9.2, 3.9.3, 3.9.4, 3.9.5, 3.9.6, 3.9.7, 3.9.8, 3.9.9, 3.x-dev] but these conflict with |
# |
May 5th 2021, 13:37 |
slackebot |
3.8.5, 3.8.6, 3.8.7, 3.8.8, 3.8.9, 3.9.0, 3.9.0-RC1, 3.9.0-RC2, 3.9.1, 3.9.2, 3.9.3, 3.9.4, 3.9.5, 3.9.6, 3.9.7, 3.9.8, 3.9.9, 3.x-dev] but these conflict with your requirements or minimum-stability. - admiral/admiral dev-master requires cakephp/cakephp ^3.6 -> satisfiable by cakephp/cakephp[3.10.0-RC1, 3.6.0, 3.6.0-RC1, 3.6.0-RC2, 3.6.0-beta1, 3.6.0-beta2, 3.6.0-beta3, 3.6.1, 3.6.10, 3.6.11, 3.6.12, 3.6.13, 3.6.14, 3.6.15, 3.6.2, |
# |
May 5th 2021, 13:37 |
slackebot |
cakephp/cakephp[3.10.0-RC1, 3.6.0, 3.6.0-RC1, 3.6.0-RC2, 3.6.0-beta1, 3.6.0-beta2, 3.6.0-beta3, 3.6.1, 3.6.10, 3.6.11, 3.6.12, 3.6.13, 3.6.14, 3.6.15, 3.6.2, 3.6.3, 3.6.4, 3.6.5, 3.6.6, 3.6.7, 3.6.8, 3.6.9, 3.7.0, 3.7.0-RC1, 3.7.0-RC2, 3.7.0-RC3, 3.7.0-beta1, 3.7.1, 3.7.2, 3.7.3, 3.7.4, 3.7.5, 3.7.6, 3.7.7, 3.7.8, 3.7.9, 3.8.0, 3.8.0-RC1, 3.8.0-RC2, 3.8.0-RC3, 3.8.0-beta1, 3.8.1, 3.8.10, 3.8.11, 3.8.12, 3.8.13, 3.8.2, 3.8.3, 3.8.4, |
# |
May 5th 2021, 13:37 |
slackebot |
3.7.5, 3.7.6, 3.7.7, 3.7.8, 3.7.9, 3.8.0, 3.8.0-RC1, 3.8.0-RC2, 3.8.0-RC3, 3.8.0-beta1, 3.8.1, 3.8.10, 3.8.11, 3.8.12, 3.8.13, 3.8.2, 3.8.3, 3.8.4, 3.8.5, 3.8.6, 3.8.7, 3.8.8, 3.8.9, 3.9.0, 3.9.0-RC1, 3.9.0-RC2, 3.9.1, 3.9.2, 3.9.3, 3.9.4, 3.9.5, 3.9.6, 3.9.7, 3.9.8, 3.9.9, 3.x-dev] but these conflict with your requirements or minimum-stability. - admiral/admiral dev-master requires cakephp/cakephp ^3.6 -> satisfiable by |
# |
May 5th 2021, 13:37 |
me1367 |
Anyone who knows how I can get around this error: ```Problem 1 - admiral/admiral dev-master requires cakephp/cakephp ^3.6 -> satisfiable by cakephp/cakephp[3.10.0-RC1, 3.6.0, 3.6.0-RC1, 3.6.0-RC2, 3.6.0-beta1, 3.6.0-beta2, 3.6.0-beta3, 3.6.1, 3.6.10, 3.6.11, 3.6.12, 3.6.13, 3.6.14, 3.6.15, 3.6.2, 3.6.3, 3.6.4, 3.6.5, 3.6.6, 3.6.7, 3.6.8, 3.6.9, 3.7.0, 3.7.0-RC1, 3.7.0-RC2, 3.7.0-RC3, 3.7.0-beta1, 3.7.1, 3.7.2, 3.7.3, 3.7.4, |
# |
May 5th 2021, 12:43 |
richard |
also can you not just use if logic blocks - kind of messy i know, but in this case maybe just practical |
# |
May 5th 2021, 12:39 |
richard |
@np some more code would prob be helpful, why are you having trouble over-riding ex, does it not make sense to just create a new controller? can both controllers just rely on a trait that has some logic, can the models just use traits? |
# |
May 5th 2021, 12:24 |
np |
S.O.S => https://discourse.cakephp.org/t/cakephp-4-2-how-to-override-the-mvc-with-the-mvc-from-other-plugin/9308 |
# |
May 5th 2021, 12:15 |
eax |
I’ll check out the PHP Session timeout, thanks! |
# |
May 5th 2021, 08:49 |
rightscoreanalysis |
got it thanks |
# |
May 5th 2021, 08:29 |
kevin.pfeifer |
and if you get inside the if you know that you created an entry and not updating one |
# |
May 5th 2021, 08:29 |
kevin.pfeifer |
correct |
# |
May 5th 2021, 08:28 |
slackebot |
<rightscoreanalysis> |
# |
May 5th 2021, 08:27 |
rightscoreanalysis |
I think this does the same as you're doing in principle: |
# |
May 5th 2021, 08:26 |
rightscoreanalysis |
I mean you can't just throw the data at Cake and it will figure whether to save or update based on what exists in the db? |
# |
May 5th 2021, 08:24 |
kevin.pfeifer |
I dont know what you mean by manual switch |
# |
May 5th 2021, 08:21 |
rightscoreanalysis |
so you are doing a manual switch |
# |
May 5th 2021, 08:17 |
slackebot |
anything with that ID `$entity = $this->MyTable->newEmptyEntity();` The rest is the default patchEntity and save procedure of CakePHP |
# |
May 5th 2021, 08:17 |
slackebot |
{ $entity = $result[0]; } elseif( sizeof( $result ) == 0 ) { $entity = $this->MyTable->newEmptyEntity(); } $entity = $this->MyTable->patchEntity( $entity, $data ); if( $this->MyTable->save( $entity ) ) { // Yay, it saved } else { // Something went wrong }``` As you can see, I first check my Database if I have any entries with `'some_id' => $some_id` If there is one, use that entity `$entity = $result[0];` If I don’t have |
# |
May 5th 2021, 08:17 |
kevin.pfeifer |
you need some sort of ID which identifies each entry in your database. Here is a part of how I sync things with an external API ```$result = $this->MyTable->find() ->where( [ 'some_id' => $some_id ] ) ->toArray(); $data = [ 'data_field1' => $data_field_1, 'data_field2' => $data_field_2, 'data_field3' => $data_field_3, ]; // Update or create depending if the entry is already in DB if( sizeof( $result ) == 1 ) |
# |
May 5th 2021, 08:10 |
rightscoreanalysis |
may I make a save I am getting Integrity constraint violation: 1062 Duplicate entry '1' for key 'type_id' |
# |
May 5th 2021, 08:04 |
rightscoreanalysis |
my data contains an indexed field but not the primary |
# |
May 5th 2021, 08:04 |
rightscoreanalysis |
I am guessing I don't have to do a find and update if records exists |
# |
May 5th 2021, 08:03 |
rightscoreanalysis |
if I am saving data to my model how can ensure records are updated and not new created |
# |
May 5th 2021, 08:02 |
rightscoreanalysis |
I created another project and fixed it - not sure what the issue was |
# |
May 5th 2021, 05:40 |
mehov |
@rightscoreanalysis what do the logs say? |
# |
May 4th 2021, 22:18 |
rightscoreanalysis |
even pages |
# |
May 4th 2021, 22:18 |
rightscoreanalysis |
what's up with a brand new cake4 install - controllers cannot be found |
# |
May 4th 2021, 20:57 |
admad |
Associations can have conditions; normalization can at times go beyond practicality :) |
# |
May 4th 2021, 20:50 |
tyler.adam.lazenby |
I really like that last suggestion... but then I have to figure out how to make sure it works with the type keys. And the reason for the no type enum is because I am a stickler for Normalization level 3 |
# |
May 4th 2021, 20:36 |
admad |
Also instead of Accounts hasMany Addresses you can have Accounts hasOne MailingAddresses and hasOne BillingAddresses (both being aliases of Addresess of specific type). |
# |
May 4th 2021, 20:33 |
admad |
A separate table address types seems unnecessary, why not just use a "type" enum column? |
# |
May 4th 2021, 19:00 |
greg138 |
Sometimes, the alternatives are a little code smell or building a whole new infrastructure to deal with an additional layer of abstraction. |
# |
May 4th 2021, 18:58 |
tyler.adam.lazenby |
see i was almost ok with that... but then I got that "code smell" of the what if situation... but I guess code for simplicity and document it well rather than complexity and think you only have to document "use this simple method to do everything from a to z" |
# |
May 4th 2021, 18:51 |
greg138 |
This would get you to having a reliable order of records, at least, which then lets you do a loop over the present address records in the template and output fields for them with indexes that will match when you go to patch the entity. |
# |
May 4th 2021, 18:49 |
greg138 |
Can you put a sort order column in your address types, and include that in your containment and sort your address records by that? |