How to fix “Incorrect string value” errors?
Mysql support only 3 bytes in «basic» utf8.
So in case of use some new characters like emoji it gives Incorrect string value error.
To fix this error you need change encoding utf8 to utf8bm4.
Sanasol
How to fix “Incorrect string value” errors?
Mysql support only 3 bytes in «basic» utf8.
So in case of use some new characters like emoji it gives Incorrect string value error.
To fix this error you need change encoding utf8 to utf8bm4.
VPS #1 — Франция
VPS #2 — Канада
VPS #3 — Нидерланды
mysql —
haproxy — балансирует запросы на два mysql мастера.
haproxy.cfg
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
global log 127.0.0.1 local0 notice user haproxy group haproxy defaults log global retries 2 timeout connect 3000 timeout server 5000 timeout client 5000 listen mysql-cluster bind 127.0.0.1:3306 mode tcp option mysql-check user haproxy_check balance roundrobin server mysql-1 vps1:3307 check server mysql-2 vps3:3307 check listen stats 0.0.0.0:8080 mode http stats enable stats uri / stats realm Strictly\ Private stats auth admin:admin |
На каждый сервер идёт свой поддомен.
Чтобы завалить сервис необходимо положить как минимум 2 хоста из 3.
Для этого надо знать какие хосты держат mysql сервера.
В противном случае класть придётся все хосты, дабы вывести из строя сервис.
Class db does not exist eloquent
A facade root has not been set
and other terrible errors.
This post for those who like me using Eloquent outside Laravel.
With config like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
use Devio\Eavquent\Agnostic\BootEavquent; use Illuminate\Database\Capsule\Manager as Capsule; use Illuminate\Events\Dispatcher; use Illuminate\Container\Container; use Illuminate\Support\Facades\Schema; $capsule = new Capsule; $capsule->addConnection([ 'driver' => 'mysql', 'host' => 'localhost', 'database' => 'dbname', 'username' => 'user', 'password' => 'password', 'charset' => 'utf8', 'collation' => 'utf8_unicode_ci', 'prefix' => '', ]); // Set the event dispatcher used by Eloquent models... (optional) $capsule->setEventDispatcher(new Dispatcher(new Container)); // Make this Capsule instance available globally via static methods... (optional) $capsule->setAsGlobal(); // Setup the Eloquent ORM... (optional; unless you've used setEventDispatcher()) $capsule->bootEloquent(); |
Sometime need to log queries or just count it.
Almost all google results show code like this:
1 |
DB::listen(function($query){}); |
But outside Laravel you will get errors written above.
I spent some time to get it work.
And now i got solution 😀
To get work query logs outside Laravel use this 🙂
1 2 3 4 5 6 7 8 9 10 |
// Listening to all queries $capsule->connection()->listen(function ($query) { var_dump($query); }); // Enabling query log $capsule->connection()->enableQueryLog(); // Getting array of executed queries $capsule->connection()->getQueryLog(); |
1 2 3 4 5 6 7 8 9 10 11 |
474 /* . "img-src 'self' data: " 475 . $GLOBALS['cfg']['CSPAllow'] 476 . ($https ? "" : $mapTilesUrls)*/ 487 /* . "img-src 'self' data: " 488 . $GLOBALS['cfg']['CSPAllow'] 489 . ($https ? "" : $mapTilesUrls)*/ 504 /* . "img-src 'self' data: " 505 . $GLOBALS['cfg']['CSPAllow'] 506 . ($https ? "" : $mapTilesUrls)*/ |