Skip to main content
16 votes

Craft CLI RC1 Connectivity Issues with MAMP Pro

I gave everything a try, but the only thing that worked for me was ensuring "Allow network access to MySQL" was ticked in MAMP. Screenshot: http://c42.co/Ur30EJ
Andrew Hahn's user avatar
14 votes

Filtering entries based on category?

Craft has a pretty solid engine for relational queries, so unless what you want to do is totally outside the box, there's a good chance you can accomplish what you want by using the relatedTo ...
Mats Mikkel Rummelhoff's user avatar
14 votes
Accepted

Craft CLI RC1 Connectivity Issues with MAMP Pro

After playing with this a little further it seems the unixSocket setting is necessary to get this working so I added: 'unixSocket' => getenv('DB_SOCKET') To config/db.php and then added: ...
Tim Knight's user avatar
  • 1,022
11 votes

Getting this SQL Error: GROUP BY incompatible with sql_mode=only_full_group_by

For UBUNTU 16.04 LTS commands: cd /etc/mysql sudo nano my.cnf add these two lines: [mysqld] sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,...
Juan Gabriel's user avatar
9 votes
Accepted

PHP notice unserialize(): Unexpected end of serialized data

Update: Craft 2.6.2957 added support for PHP 7.1 There's a lot going on here, but 1st thing is 1st. The vagrant box is running PHP 7.1 Craft 2 (and the current latest version of the Yii ...
Brad Bell's user avatar
  • 67.5k
7 votes

Reset password with MySQL

If you don't want to mess about trying to insert code in the Craft/Yii stack, v3 just calls password_hash(): password_hash($your_password_string, PASSWORD_DEFAULT, ['cost' => 13]); As a possibly ...
tjbp's user avatar
  • 171
7 votes
Accepted

MySQL Collation: utf8mb4_unicode_ci (emojis)

When you create a database in MySQL in Craft 2, you can set the default charset and collation, so that any SQL statements that get executed that don't explicitly specify what charset/collation to use, ...
Brad Bell's user avatar
  • 67.5k
7 votes

Is there a way to convert a Craft MySQL database to PostgreSQL?

First, I'm glad you've realized what a mistake you made. There's not a fool-proof way to do this, other than to do a fresh installation of Craft using PostgreSQL and migrate the content over. There is ...
Brad Bell's user avatar
  • 67.5k
6 votes

Dump SQL query in Twig template

In Craft 3 you can use getRawSql() at the end of the element query. {% set entries = craft.entries.section('blog').getRawSql() %} {{ entries }}
CraftQuest's user avatar
  • 1,122
6 votes

Getting this SQL Error: GROUP BY incompatible with sql_mode=only_full_group_by

Here are some fairly specific instructions if you happen to be hosted on a server configured through ServerPilot. https://serverpilot.io/community/articles/how-to-disable-strict-mode-in-mysql-5-7....
Philip Jones's user avatar
5 votes

Craft CMS with Google Cloud SQL as backend database

Craft currently won't operate properly if you have GTID enabled because GTID enforces that every table involved in a SQL statements in one transaction have to utilize the same storage engine. While ...
Brad Bell's user avatar
  • 67.5k
5 votes

Randomly getting the "Integrity constraint violation" sql error on saving entry

It's not a Craft bug. The error means that the data in your craft_relations table is out of sync with the data in the your craft_elements table. i.e. an ID exists in craft_relations.targetId that ...
Brad Bell's user avatar
  • 67.5k
5 votes
Accepted

Local DB SQL 'CDbException' Errors on Craft 2 site

this is a MySQL/i version issue on Craft 2 sites. You'll need to add this to your database config (craft/config/db.php): 'initSQLs' => array("SET SESSION sql_mode='STRICT_TRANS_TABLES,...
Cole Henley's user avatar
  • 1,741
4 votes

Getting this SQL Error: GROUP BY incompatible with sql_mode=only_full_group_by

The proper fixes have already been answered here; but I'd like to note that another fix is to use MariaDB instead of MySQL. It's a drop-in replacement for it, it's more performant for a number of ...
andrew.welch's user avatar
  • 11.6k
4 votes
Accepted

Alternatives to Mamp Pro – which works with Craft CMS

I'd highly recommend you check out Laravel Valet. Here's an article on it that may be useful to you as well: Running Craft CMS 3 on Laravel Valet
andrew.welch's user avatar
  • 11.6k
4 votes
Accepted

Find entries that use a specific block in their Matrix field?

You can join your matrix table and check for elements with a certain type and your owner id Craft 3 {% set entries = craft .entries() .section(['your-section']) .leftJoin('{{%matrixblocks}}...
Robin Schambach's user avatar
3 votes
Accepted

How would I write this differently to make it compatible with MYSQL 5.7

Turns out this is a bug as of Craft 2.6.2931 with the ColumnType::PK enum in a record's attribute type definition. Pretty sure it'd be a bug in < MySQL 5.7 because it's invalid SQL syntax as well ...
Brad Bell's user avatar
  • 67.5k
3 votes
Accepted

Dump SQL query in Twig template

You can see each SQL query that is run for a page by turning devMode on and opening your console to read the 'Profiling Summary Report'. You can see a total query count and each query beings with ...
Luke Pearce's user avatar
  • 3,863
3 votes
Accepted

map values from checkbox field into category field using SQL

FeedMe plugin imports categories, so you could create an xml template file that outputs your entries and their checkbox values(separated by commas), then use FeedMe to import that file back in and map ...
AbbeyDesign's user avatar
  • 1,527
3 votes
Accepted

Tracking SQL queries from CP changes

Lots of smart people have tried to solve this problem and it's a tough one to solve, not just in Craft land but WP, and others. And because of Craft's flexible nature, a change in one table usually ...
RitterKnight's user avatar
  • 6,582
3 votes

createCommand sql query not working in plugin

Thanks to @carlcs for pointers managed to get this working with the following: $criteria = craft()->elements->getCriteria(ElementType::User); $criteria->limit = NULL; $query = craft()->...
Lettie's user avatar
  • 2,033
3 votes

See the SQL query that gets executed when saving entry

If you add the devMode setting to your config, you should then be able to view the Javascript Console in your browser to see the SQL Queries being run. In particular you're looking for the Profiling ...
Steve Holland's user avatar
3 votes
Accepted

Help with admin panel errors. Fresh install. Mysql version issue?

You need to tweak your MySQL 5.7.5+ config for it to play nicely with Craft. MySQL 5.7.5 changed the behaviour of the GROUP_BY statement, affecting some of the core Craft queries. The preferred ...
Stephen Lewis's user avatar
3 votes

Craft CLI RC1 Connectivity Issues with MAMP Pro

Jason Mayo's strategy of changing localhost to 127.0.0.1 in .env file worked for me as well 👍🏻 (MAMP Pro v6 on Mac OS 11.4 Big Sur)
Roger Glenn's user avatar
3 votes

Workflow for re-using data structures and setups across projects?

You have several options to solve this issue. Import fields via plugin You could create a plugin that handles all these function in it's installation callback so you would install the plugin and ...
Robin Schambach's user avatar
3 votes

MySql 5.7 error - field doesn't have a default value

The STRICT_TRANS_TABLES mode was added to the default SQL mode in MySQL 5.7.5 and is likely causing the error to be thrown: https://dev.mysql.com/doc/refman/5.7/en/sql-mode.html You can either ...
Ben Croker's user avatar
  • 7,536
3 votes

Find entries that use a specific block in their Matrix field?

Compelled to provide a third answer here to help avoid the unnecessary complexity of working with SQL joins—and the headache that comes with having to match Craft's own criteria when fetching rows ...
August Miller's user avatar
3 votes

Craft CMS Entries Disappearing

I finally got to the bottom of what happened. I deleted a user about a month ago and after 30 days (the soft delete period) Craft deleted all related pages that the user had originally created. ...
Austin's user avatar
  • 151
3 votes

Nitro: how risky is it to dev using MariaDB and then go live with MySQL?

My view on this would be it's risky because any environments for a project should ideally all match the same core versions of CMS, PHP version (at minimum same major version) and whatever database ...
James White's user avatar
  • 1,171
2 votes

Internal Server Error: SQLSTATE[42000] 1118 Row size too large

I know this is an old post, but another area to consider aside from information architecture/field structure is you have a lot of Plain Text fields but haven't set a max length. I'm not sure if this ...
James White's user avatar
  • 1,171

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