note 116808 added to mysqli.construct

From: Date: Tue, 03 Mar 2015 11:28:14 +0000
Subject: note 116808 added to mysqli.construct
Groups: php.notes 
Request: Send a blank email to php-notes+get-201845@lists.php.net to get a copy of this message
A far more secure and language independent way of connecting to mysql is to use the READ_DEFAULT_FILE options. This passes the workload over to the mysql library, which allows for the configuration file itself to be outside of the scope of the language. The config file itself is something like this: [client] user=user_u password=user_password host=dbhost port=3306 database=the_database default-character-set=utf8 The following code fragment (in OO mysql_i format) $sqlconf='/var/private/my.cnf'; $sql = new mysqli; $sql->init(); $sql->options(MYSQLI_READ_DEFAULT_FILE,$sqlconf); $sql->real_connect(); ---- Server IP: 72.52.91.14 Probable Submitter: 217.37.70.209 ---- Manual Page -- http://php.net/manual/en/mysqli.construct.php Edit -- https://master.php.net/note/edit/116808 Del: integrated -- https://master.php.net/note/delete/116808/integrated Del: useless -- https://master.php.net/note/delete/116808/useless Del: bad code -- https://master.php.net/note/delete/116808/bad+code Del: spam -- https://master.php.net/note/delete/116808/spam Del: non-english -- https://master.php.net/note/delete/116808/non-english Del: in docs -- https://master.php.net/note/delete/116808/in+docs Del: other reasons-- https://master.php.net/note/delete/116808 Reject -- https://master.php.net/note/reject/116808 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#201845) next »