note 102934 deleted from function.ini-get by danbrown

From: Date: Tue, 15 Mar 2011 15:34:24 +0000
Subject: note 102934 deleted from function.ini-get by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-177903@lists.php.net to get a copy of this message
Note Submitter: noreply at DeveloperER dot com ---- Here is a php function that will return MySQL configuration variables: function GET_MYSQL_VARS($name=NULL,$single=false) { // Purpose: Return array of mysql variables and their associated values, or false if the variable is not found. // Usage: GET_MYSQL_VARS(); GET_MYSQL_VARS("max_%"); GET_MYSQL_VARS("datadir",true); // Notes: If a single variable is requested and $single = true, it's value (instead of an array) will be returned // Requirements: a current open database connection to MySQL // ------------------------------------------- // Copyright (c) Peter Kionga-Kamau http://www.DeveloperER.com - Free for unrestricted use under two conditions: // 1. NOT FOR SALE! You may USE this function for any purpose (including using it in products that you sell), however: // YOU MAY NOT SELL THIS FUNCTION, even if it is bundled with other functions. // 2. This comment and copyright notice must not be changed at any time. // ------------------------------------------- $o = array(); $r = mysql_query("SHOW VARIABLES".($name?" LIKE '".mysql_real_escape_string($name)."'":"")); while($t = mysql_fetch_array($r,MYSQL_NUM))$o[$t[0]]=$t[1]; return mysql_num_rows($r)>0? ($single&&mysql_num_rows($r)==1? $o[$name]:$o):false; }

« previous php.notes (#177903) next »