title: User defined MySQL function not accessible with PHP PDO connection
body: <p>I've got a trivial MySQL function:</p>
  
  <pre><code>DELIMITER $$
  DROP FUNCTION IF EXISTS `mydb`.`CALC` $$
  CREATE FUNCTION `mydb`.`CALC_IT`(Flag VARCHAR(1), One FLOAT, Other FLOAT) 
  RETURNS FLOAT
  BEGIN
      IF One IS NULL THEN RETURN 0; END IF;
      IF Other IS NULL THEN RETURN 0; END IF;
      IF Flag = 'Y' THEN
          RETURN Other - One;
      ELSE
          RETURN Other
      END IF;
  END $$
  DELIMITER ;
  </code></pre>
  
  <p>And it's called in a query from PHP using a PDO connection:</p>
  
  <pre><code>$query = 'SELECT CALC_IT(`Flag`, `One`, `Two`) FROM `mydb`.`table` WHERE `Condition` = 1';
  $db = new PDO('mysql:host=localhost', 'user', 'pass');
  $stmt = $db-&gt;prepare($query);
  if (!$stmt-&gt;execute()) {
      var_dump($stmt-&gt;errorInfo());
  }
  </code></pre>
  
  <p>But, it reports the following:</p>
  
  <pre><code>array
    0 =&gt; string '42000' (length=5)
    1 =&gt; int 1305
    2 =&gt; string 'FUNCTION CALC_IT does not exist' (length=37)
  </code></pre>
  
  <p>And, if you try it with the legacy Mysql code, it works:</p>
  
  <pre><code>$db = mysql_connect('localhost', 'user', 'pass');
  $result = mysql_query($query);
  if (mysql_error()) {
      var_dump(mysql_error());
  }
  </code></pre>
  
  <p>The query also works if you try it with any other mysql client.</p>
  
  <p>So <strong>why doesn't <em>some</em> user defined MySQL functions work in PHP's PDO library?</strong></p>