Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Object oriented mysqli connection function

432 views

Published on

Published in: Technology
  • Be the first to comment

  • Be the first to like this

Object oriented mysqli connection function

  1. 1. Object Oriented mysqli connection function
  2. 2. PsychoCoder Recently a friend was having a hard time connecting using mysqli, so I showed an OOExperway of accomplishing the task with this codet Mod100+Expand|Select|Wrap|Line Numbers P: 131 1. class db_connection extends mysqli 2. { 3. public function __construct($dbhost, $username, $password , $db) 4. { 5. parent::__construct($dbhost, $username, $password, $d b); 6. 7. if (mysqli_connect_error()) 8. { 9. die(Connection Error: ( . mysqli_connect_errno( ) . ) . mysqli_connect_error()); 10. } 11. } 12.} 13. 14.$db = new db_connection(localhost, username, password, db); 15. 16.echo Success... . $db->mysqli_get_host_info($db) . "n"; 17. 18.$db->close();

×