# |
Jun 27th 2018, 12:48 |
sharnaaysha23 |
File uploaded https://cakesf.slack.com/files/UBEP09PKM/FBECLFESV/cakephp_database_error.png / https://slack-files.com/T053DPNCM-FBECLFESV-1f7c416ef3 - I make a simple registration and log in website using CakePHP 3.6. It works fine in my local machine. Then I upload the project in another server and my database is another server. Now when I go to log in or register the project does not get database connection. I configure |
# |
Jun 27th 2018, 12:19 |
adriencs |
@sharnaaysha23 :wave: welcome |
# |
Jun 27th 2018, 12:18 |
hmic |
!tell sharnaaysha23 about ask |
# |
Jun 27th 2018, 12:17 |
sharnaaysha23 |
hello I am new in this group. I am learning cakephp as a beginner. I face some problem in my project. Can I post here? |
# |
Jun 27th 2018, 12:09 |
a.francazi |
thanks guys, was just attempting the single action solution, will also look into the custom SlugRoute class method though |
# |
Jun 27th 2018, 12:00 |
josbeir |
although in the case above you are right :slightly_smiling_face: |
# |
Jun 27th 2018, 11:59 |
josbeir |
@neon1024 isn't a custom route class the better solution here ? |
# |
Jun 27th 2018, 11:20 |
neon1024 |
Although routing is parsed procedurally, so the first routing rule will always be hit first |
# |
Jun 27th 2018, 11:19 |
neon1024 |
Then you can check that param in the controller |
# |
Jun 27th 2018, 11:19 |
neon1024 |
The other way I can think of, is passing a param from the routing, which I do sometimes |
# |
Jun 27th 2018, 11:18 |
neon1024 |
I would compile two custom finders in that method |
# |
Jun 27th 2018, 11:18 |
neon1024 |
Personally I would route the url to a single action, and deal with it there |
# |
Jun 27th 2018, 11:18 |
edgaras.jan |
here is cake 2 sample https://gist.github.com/gapple/4069038, cake3 looks very similar |
# |
Jun 27th 2018, 11:14 |
edgaras.jan |
https://book.cakephp.org/3.0/en/development/routing.html#custom-route-classes |
# |
Jun 27th 2018, 11:14 |
edgaras.jan |
you need custom SlugRoute class to match if `:slug` is author or tag |
# |
Jun 27th 2018, 10:57 |
a.francazi |
if i go to /tagSlug it tries to find authorSlug and can't find it. I'd like to check it both for author and tag-slug, then open either author or tag page. |
# |
Jun 27th 2018, 10:55 |
a.francazi |
File uploaded https://cakesf.slack.com/files/U7T7YBECA/FBFUBPPBR/-.php / https://slack-files.com/T053DPNCM-FBFUBPPBR-5bff78812f |
# |
Jun 27th 2018, 10:54 |
a.francazi |
is there an easy way to have one route point to multiple actions? |
# |
Jun 27th 2018, 10:19 |
josbeir |
ah you just typed that nm :P |
# |
Jun 27th 2018, 10:19 |
josbeir |
@turkles array_keys($collection->toArray()) ? |
# |
Jun 27th 2018, 10:10 |
turkles |
well.. array_keys($collection->toArray()) works.. eww |
# |
Jun 27th 2018, 10:09 |
neon1024 |
Well it implements Iterator, so perhaps you could just do `array_keys($collection)` ? |
# |
Jun 27th 2018, 10:06 |
turkles |
extract wants a path.. but I can see you can do a callback.. hrm |
# |
Jun 27th 2018, 10:05 |
turkles |
my collection does.. it's come from json data and is in the form 123 => ['data' => 'blah, 'etc' => 'blah], 456 =>... |
# |
Jun 27th 2018, 10:02 |
neon1024 |
https://book.cakephp.org/3.0/en/core-libraries/collections.html#Cake\Collection\Collection::extract |
# |
Jun 27th 2018, 10:02 |
neon1024 |
Probably `extract()` I’d think |
# |
Jun 27th 2018, 10:01 |
neon1024 |
Do they even have keys? |
# |
Jun 27th 2018, 09:56 |
turkles |
Is there a quick way to get a list of keys in a collection? |
# |
Jun 27th 2018, 09:37 |
neon1024 |
Also do check the execution time without debug on |
# |
Jun 27th 2018, 09:37 |
itamer |
My pleasure @gs13006, nice to be able to help and be helped |
# |
Jun 27th 2018, 09:36 |
gs13006 |
@itamer thankyou very much |
# |
Jun 27th 2018, 09:34 |
gs13006 |
Yes, i did it. may be i need to check this again. |
# |
Jun 27th 2018, 09:34 |
itamer |
I run some massive queries, and they're fast - you will be able to fix this |
# |
Jun 27th 2018, 09:33 |
itamer |
Once it's fast in the database, then you can look to see if there are any inefficiencies in your controller and models |
# |
Jun 27th 2018, 09:33 |
itamer |
use debug tools to get the query and see if you can get it running faster in phpMyAdmin or whatever tool you are using. |
# |
Jun 27th 2018, 09:32 |
itamer |
and look at the table type - is it optimised for the type of data you have |
# |
Jun 27th 2018, 09:32 |
itamer |
look at your indexes in the database |
# |
Jun 27th 2018, 09:32 |
itamer |
consider unbinding those tables if the data isn't needed |
# |
Jun 27th 2018, 09:31 |
itamer |
Have a look at your recursive value - cut that down |
# |
Jun 27th 2018, 09:31 |
gs13006 |
yes it is associated with each other. |
# |
Jun 27th 2018, 09:31 |
itamer |
do you need those extra tables loaded every time? |