CakePHP finds the result of the call in many queries "SET CHARACTER SET utf8". What for?

What is the reason CakePHP makes the query β€œSET CHARACTER SET utf8” 38 times in a row for a simple find (β€œall”) (the default recursive property is 0)?

I use MySQL as a database and I can say that I am creating a user table that looks like this:

CREATE TABLE users (
id INT NOT NULL AUTO_INCREMENT,
username char(50) UNIQUE,
password char(40),
post_id INT,
created DATETIME,
modified DATETIME,
CONSTRAINT PRIMARY KEY (id),
CONSTRAINT FOREIGN KEY (post_id) REFERENCES posts (id)
    ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE=INNODB;

and a message table that looks like this:

CREATE TABLE posts (
id INT NOT NULL AUTO_INCREMENT,
title VARCHAR(30) NOT NULL,
content TEXT NOT NULL,
CONSTRAINT PRIMARY KEY (id)
) ENGINE=INNODB;

In my users_controller.php, I write in action:

$log = $this->User->getDataSource()->getLog(false, false);
$this->User->find("all",
array(
   'conditions' => array('id' => 3),
   'recursive' => 0
));
debug($log);

I did not test this with the above data, but showed the above tables because they are similar to my current database. I use 25 tables with engine = innodb.

Debugging is an array of 41 requests, where 2 requests retrieve the user and the message. The remaining 39 queries are identical and look like this:

    Array
(
    [log] => Array
    (
        [0] => Array
            (
                [query] => SET CHARACTER SET utf8;
                [error] => 
                [affected] => 0
                [numRows] => 
                [took] => 0
            )

        [1] => Array
            (
                [query] => SET CHARACTER SET utf8;
                [error] => 
                [affected] => 0
                [numRows] => 
                [took] => 0
            )
                 .
                 .
                 .
            [38] => Array
            (
                [query] => SET CHARACTER SET utf8;
                [error] => 
                [affected] => 0
                [numRows] => 
                [took] => 0
            )

? config/database.php , "utf8" . "utf8", 38 .

var $default = array(
    'driver' => 'mysql',
    'persistent' => false,
    'host' => 'localhost',
    'login' => 'mylogin',
    'password' => 'mypassword',
    'database' => 'mydatabase',
            'encoding' => 'utf8'
);
+3
2

, . ,

+1

. . AppModel :

$this->query( "SET CHARACTER SET utf8;" );
+1

All Articles