FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » database access
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: database access [message #174197 is a reply to message #174189] Thu, 26 May 2011 13:05 Go to previous messageGo to previous message
JohnT is currently offline  JohnT
Messages: 16
Registered: April 2011
Karma:
Junior Member
On Wed, 25 May 2011 10:17:48 -0700, Jivanmukta wrote:

> I new relatively new to PHP. I need your opinion if the following set of
> database functions make sense:
>
> function openDatabase() {
> global $db;
> try {
> $db = new PDO('mysql:host=' . MYSQL_SERVER . ';dbname=' .
> MYSQL_DATABASE, MYSQL_USER, MYSQL_PASSWORD);
> $db->exec('SET NAMES latin2');
> $db->exec('SET CHARACTER SET latin2 COLLATE
latin2_general_ci');
> $db->setAttribute(PDO::ATTR_ERRMODE,
PDO::ERRMODE_EXCEPTION);
> register_shutdown_function('closeDatabase');
> } catch (PDOException $e) {
> return false;
> }
> return true;
> }

Looks like real overkill to me.
Do you really need to use PDO ?
Whats wrong with the regular PHP mysql_XXXX() functions ?
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Stats comp.lang.php (last 7 days)
Next Topic: a more elegant way?
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Tue Nov 26 13:55:36 GMT 2024

Total time taken to generate the page: 0.04436 seconds