[Phpmyadmin-devel] current user

Michal Čihař michal at cihar.com
Wed Jul 15 09:43:32 CEST 2009


Hi

Dne Wed, 15 Jul 2009 01:45:36 -0400
Zeeshan Mughal <zeeshanmughal at ieee.org> napsal(a):

> Hi, I am using the following code to extract currently logged user name from
> PMA_DBI_fetch_value('SELECT USER();')
> 
> //        $userAndHost = PMA_DBI_fetch_value('SELECT USER();');
> //        $userAndHost = str_split($userAndHost);
> //        while ($i=0 < count($userAndHost)-1) {
> //            $username += $userAndHost[$i];
> //            $i++;
> //            if ($userAndHost[$i] == "@") {
> //                break;
> //            }

Going chars one by one is not a good idea. How about just explode('@',
$userAndHost)[0]?

But anyway current user is available as
$GLOBALS['cfg']['Server']['user'] without need for any parsing and
querying MySQL.

-- 
	Michal Čihař | http://cihar.com | http://phpmyadmin.cz
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
URL: <http://lists.phpmyadmin.net/pipermail/developers/attachments/20090715/507cd59a/attachment.sig>


More information about the Developers mailing list