Laravel MySQL PHP

Mysql General Error 1364 Field Doesn’t Have Default Value

Hi All,

Since I’ve updated my homestead to 0.3.0 and mysql version is upgrade to 5.7.4. From that moment, my old projects has been started to throw problems which is Mysql General Error 1364 Field doesn’t have default value.

Even migrations was not working, there has to be a problem. After my first research I’ve found a solution for Php Laravel Projects there is a “strict” parameter for mysql connection, when I set it true migrations worked well.. But, in some cases, I let the mysql to set default value such as integer fields are sets to ‘0’ and varchar fields are empty strings etc.. I need to use default values as before..

Laravel MySQL PHP

Laravel Eloquent Model Events

Hi All ,

In this post , I’ll talk about Eloquent Model Events.

Looks Like Database Trigger Isn’t it?

When I read the documentation , I said “Mysql already doing this so..”. Personally, still I prefer to use Mysql Triggers for database operations. It’s more faster and guaranteed. But day by day NoSQL solutions or Hybrid database solutions like using MongoDB and Mysql together becoming as a popular solutions.  Also each NoSQL database is different, but MongoDB doesn’t support  actually stored procedures or triggers. In that case , we need to handle this kind of situations.

If you are interested in MySQL-NoSQL Hybrid Solution with Laravel. You can check this package by Jessenger.

For More

Laravel site has a simple usage example for Eloquent Model Events for “Validation”. In real projects , we have to validate every input , when model “updating” and “creating” its very important. So, Model Events is amazingly useful for this job. You can check the JeffreyWay Model Validation package from github.  This package supports model based validation rules.

Generaly, we need to delete photos , avatars , attachments from FTP too or Logging Model actions We can add more usages examples depends on situation. Let’s see abilities of Model Events.


MySQL Limitli Sorgu Toplam Satır Sayısı

Merhaba Arkadaşlar  ,

Web uygulamalarımızın vazgeçilmezi olan Ajax uzun database sorgularında bizi çok işten kurtarıyor. Ama sayfalama yaparken , datatables kullanırken  veya search gibi karmaşık sorgularımızın gerçek uzunluğuna ihtiyacımız oluyor.  MySQL’in bunun için çözümü şu şekilde

SELECT SQL_CALC_FOUND_ROWS user_id , username FROM users LIMIT 10

Bu sorgudan sonra;


sorgusunu çalıştırırsanız , sorgunun limitsiz sonucuna ulaşabiliyorsunuz. Tabiki önemli nokta asıl sorgunuzda SELECT ‘den sonra  “SQL_CALC_FOUND_ROWS”  kodunu eklemelisiniz.