4

"Digital Ocean through Forge" is a good solution. Sounds like you're on a well-powered droplet as well. I'd recommend moving your assets into the cloud to speed things up a bit. Something like Amazon S3 with CloudFront. Honestly, the biggest drag is probably the use of multiple locales. Craft is making duplicates of pretty much all of the content in your ...


3

You're not misunderstanding anything, and your concerns are perfectly valid. I feel like many developers using Craft do not realise that .one() and .all() are in fact database calls, and pretty expensive ones at that. Do it your way, watch the number of DB queries go down in the debug toolbar and feel all warm and fuzzy. (Also, you don't need parentheses in ...


3

If you really, really want to create an entry from within the database (you must have a VERY good reason to do so), then you should create a row in: entries elements elements_sites content If you'd like the easier path, use Content migrations. Create a migration, and then add something like: // Create the entry $myNewEntry = new craft\elements\Entry(); $...


2

Nothing to see here. We had a corrupt index. Running this command in the DB brought our searches down from 90 seconds to 1 or 2 seconds. I'd still love it to be faster. But we can live with 2 seconds: optimize table searchindex;


2

I believe you can use getLastInsertID to fetch the ID: Craft::$app->db->getLastInsertID();


1

I restarted my DB server and it fixed the issue. Sorry for the false alarm, but I've never seen something like that before. Should have tried the DB restart before.


1

The database backup from Craft is slightly different to the SQL export in phpMyAdmin. Craft’s export (presumably) assumes you’re going to want to import that data into an existing site, whereas phpMyAdmin’s default (presumably) assumes you’ll want to import it into an empty database. However you can do exactly as you suggest — export from phpMyAdmin locally, ...


1

I'm not sure why you would do two different servers. Your front end can be cached with Blitz / NGINX which will take a load off the server and admin. How often are you aggregating the data? I've just imported 10k records from a source and I would recommend writing your own module to handle the imports as commands. From there you could set up a cron which ...


1

Have a look at your .env file on the production system and your config/db.php file your repo. Craft has changed the way db access data is stored and must now be provided as a DSN This is now config/db.php return [ 'dsn' => getenv('DB_DSN'), 'user' => getenv('DB_USER'), 'password' => getenv('DB_PASSWORD'), 'schema' => getenv('...


1

From Craft Support: Assuming the credentials in your .env are correct on that site, could you run ./craft clear-caches/all (or manually empty your web/cpresources and storage/runtime


1

Yes, it would be possible. I don't think there's an easy (plugin) solution for this purpose, though. If your project has an active module, you could use that to save the click count and retrieve it from the DB. Make sure your module works (in the default Craft project, it's as simple as uncommenting the module line in config/app.php) Create a migration to ...


1

Command ./craft migrate/all fixed this issue.


1

You would not use the headless API to submit content in into Craft, as neither the GraphQL or Element APIs support writing. The frontend entry form functionality is fairly well documented. You would just need your frontend to build out a post request including the correct action, CSRF token, and whatever fields are needed. The action endpoint will ...


1

there should be execute() fn at the last to execute the sql query craft()->db->createCommand() ->insert('mytablename', array( 'field1' => 'foo', 'field2' => 'bar' )) ->execute();


1

When you do your export in phpmyadmin, make sure you check the 'disable foreign key checks' box in the custom options:


1

It's from the top of my head here so no idea if this is going to work, but my idea is: Get all active alerts order by postDate (just their ID's to make it faster) Retrieve all related countries and take the first 5 (You can do a relatedTo with more than 1 entry.) {% set alerts = craft.entries({ section: 'alert', orderBy: 'postDate desc', ...


1

OK, here is one solution I've come up with, which seems to work and (I think) avoids 1+ queries: {% set groups = craft.entries({ section: 'alert', with: [ 'country', ] }).orderBy('postDate desc').status('live').all() | group(alert => alert.country[0]) %} <ul> {% for country, alerts in groups | slice(0, 5) %} <li&...


Only top voted, non community-wiki answers of a minimum length are eligible