Wednesday, 18 March 2015

How to get a list of MySQL user accounts?

How to get a list of MySQL user accounts?

In MySQL, you can get list of user account with user details. Just execute following Query of PHPMySQL/SQL Yog/Other MySQL Tools.

List of MySQL users.
SELECT User FROM mysql.user


List of MySQL unique users.
select distinct User from mysql.user;

List of MySQL users with password and host.
SELECT Host,User, Password FROM mysql.user


List of MySQL unique Users with password and host.
SELECT Host,User, Password FROM mysql.user  group by User



List of MySQL users with all permissions.
SELECT * FROM mysql.user WHERE 1






Tuesday, 17 March 2015

What is stdClass? and How to create stdClass class?

What is stdClass class?
stdClass is Generic empty class in PHP.
OR
stdClass is universal base class in PHP.



Question: Why stdClass class is used?
stdClass is used to create anonymous objects with properties.



Question: Where it is used?
When we need to create an object without having new class. then we used stdClass class which is inbuilt in PHP.
After create object, we can add properties.



Question: How to create stdClass class?
$object=new stdClass();



Question: Can we set different variables in StdClass?
Yes, We can do both get and set.
See Example Below:
//First, create an object with use of stdClass
$object=new stdClass();

//Set new variables in $object 
$object->name='Web Technology Experts Notes';
$object->url='web-technology-experts-notes.in';

//Get the variables values
echo $object->name;
echo $object->url;