Modification of PDO() in database

Share your custom plugins/apps/modules for the desktop

Modification of PDO() in database

Postby sosy on Thu Jul 29, 2010 8:31 am

Hi users..

Today i noticed that special chars (UTF8) was not displayed correctly, so i made the following mod in server/lib/database.php

Change this

Code: Select all
public function connect($conn_string, $username, $password, $error_mode)
   {
       if(isset($conn_string, $username, $password, $error_mode))
      {
           try
         {
               $this->conn = new PDO($conn_string, $username, $password);
               $this->conn->setAttribute(PDO::ATTR_ERRMODE, $error_mode);
               return true;
            }
         catch(PDOException $e)
         {
            //print $e->getMessage();
            }
         }
         return false;
   } // end connect()


in this

Code: Select all
public function connect($conn_string, $username, $password, $error_mode)
   {
       if(isset($conn_string, $username, $password, $error_mode))
      {
           try
         {
               $this->conn = new PDO($conn_string, $username, $password);
      //
      // Mod by sosy
      //
      $this->conn->exec('SET CHARACTER SET utf8');
      //
      //
      //
               $this->conn->setAttribute(PDO::ATTR_ERRMODE, $error_mode);
               return true;
            }
         catch(PDOException $e)
         {
            //print $e->getMessage();
            }
         }
         return false;
   } // end connect()


For those who are working with Todd's new Membersystem, and who need special chars (i live in Germany) like ä,ü etc. its probably usefull.

Regards
Sosy
I prefer a sister in the red-light district to an brother with Internet Explorer..
User avatar
sosy
 
Posts: 9
Joined: Tue Jul 06, 2010 6:42 am
Location: Oldenburg, Germany

Return to User Plugins

Who is online

Users browsing this forum: No registered users and 1 guest

cron