I have the following code where I worked with ´text files´. Here I say if the ´array´ is ´empty´ set user role to ´admin´ , if not set user role to ´user´. How can I do this when I store data to MySQL instead?
$sajUsers = file_get_contents( 'users.txt' );
$ajUsers = json_decode($sajUsers);
// Create the JSON ONBJECT with key values
if ( count( $ajUsers ) === 0 ) { // if the aray is empty create an Admin
//echo( "The array is empty creating admin" );
$jNewUser->role = 'admin';
} else { // if it´s not empty create a user
//echo( "The array isnt empty creating user" );
$jNewUser->role = 'user';
}