Advertisement
cristic84

PDO issue (null values)

Jul 18th, 2013
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.22 KB | None | 0 0
  1.         $updatQuery = $this->dbh->prepare($query);
  2.  
  3.         $paramsUTF8 = array_map('utf8_decode', array_values($paramsForQuery)); // I have french characters, that's why
  4.  
  5.         $count = 1;
  6.         foreach ($paramsUTF8 as $p) {
  7.             $typeBind = \PDO::PARAM_STR;
  8.             $typeBindString = 'string'; // used for displaying the log
  9.  
  10.             if (strtolower($p) == 'null') {
  11.                 $typeBind = \PDO::PARAM_NULL;
  12.                 $typeBindString = 'null';
  13.             }
  14.             else if (is_int($p)) {
  15.                 $typeBind = \PDO::PARAM_INT;
  16.                 $typeBindString = 'int';
  17.             }
  18.             else if (is_string($p)) {
  19.                 $typeBind = \PDO::PARAM_STR;
  20.                 $typeBindString = 'string';
  21.             }
  22.  
  23.             $this->logger->logThis('BIND [' . $count . '] ==> ' . $p . ' [typeBind : ' . $typeBindString . ']');
  24.  
  25.             $updatQuery->bindValue($count, $p, $typeBind);
  26.             $count++;
  27.         }
  28.  
  29.         if ($updatQuery->execute()) {
  30.             $this->logger->logThis('OK - it's working');
  31.            return true;
  32.        }
  33.        else {
  34.            $this->logger->logThis("F*** this! I'm going home!");
  35.        }
  36.        return false;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement