title: CakePHP find call result in many "SET CHARACTER SET utf8" queries. Why?
body: <p>What is the reason for CakePHP to do the query "SET CHARACTER SET utf8" 38 times in a row for a simple find("all") (recursive property default at 0) ?</p>
  
  <p>I use MySQL as database and let's say I create a users table which looks like this:</p>
  
  <pre><code>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;
  </code></pre>
  
  <p>and a posts table which looks like this:</p>
  
  <pre><code>CREATE TABLE posts (
  id INT NOT NULL AUTO_INCREMENT,
  title VARCHAR(30) NOT NULL,
  content TEXT NOT NULL,
  CONSTRAINT PRIMARY KEY (id)
  ) ENGINE=INNODB;
  </code></pre>
  
  <p>In my users_controller.php, I write in an action:</p>
  
  <pre><code>$log = $this-&gt;User-&gt;getDataSource()-&gt;getLog(false, false);
  $this-&gt;User-&gt;find("all",
  array(
     'conditions' =&gt; array('id' =&gt; 3),
     'recursive' =&gt; 0
  ));
  debug($log);
  </code></pre>
  
  <p>I haven't tested this with the data above, but showed the tables above because they are similar to my current database. I use 25 tables with engine=innodb.</p>
  
  <p>The debug is an array of 41 queries, where 2 queries retrieves the user and the post. The other 39 queries are identical and looks as follows:</p>
  
  <pre><code>    Array
  (
      [log] =&gt; Array
      (
          [0] =&gt; Array
              (
                  [query] =&gt; SET CHARACTER SET utf8;
                  [error] =&gt; 
                  [affected] =&gt; 0
                  [numRows] =&gt; 
                  [took] =&gt; 0
              )
  
          [1] =&gt; Array
              (
                  [query] =&gt; SET CHARACTER SET utf8;
                  [error] =&gt; 
                  [affected] =&gt; 0
                  [numRows] =&gt; 
                  [took] =&gt; 0
              )
                   .
                   .
                   .
              [38] =&gt; Array
              (
                  [query] =&gt; SET CHARACTER SET utf8;
                  [error] =&gt; 
                  [affected] =&gt; 0
                  [numRows] =&gt; 
                  [took] =&gt; 0
              )
  </code></pre>
  
  <p>Is this supposed to happen? In my config/database.php file, it doesn't matter if I set encoding to 'utf8' or not. I do want 'utf8', but I don't want 38 unnecessary queries.</p>
  
  <pre><code>var $default = array(
      'driver' =&gt; 'mysql',
      'persistent' =&gt; false,
      'host' =&gt; 'localhost',
      'login' =&gt; 'mylogin',
      'password' =&gt; 'mypassword',
      'database' =&gt; 'mydatabase',
              'encoding' =&gt; 'utf8'
  );
  </code></pre>