Creating new user in mysql as :
$query = $dbconnection->prepare("CREATE USER 'john'@'localhost' IDENTIFIED BY 'mypass'");
$query->execute();
$counts = $query->rowCount();
return $counts;
Generally in other queries, I use rowCount() to check whether the query got successful or not. if rowCount() >1, query successful. But I realised this doesnt work in creating user.
In this case, user is created, but rowCount() still results the value 0. Is there any way, to check whether this query is successful.
UPDATE in @GHOST comment: This query returns the value 1, to confirm that data is inserted, or a row is affected.
$query = $this->link->prepare("INSERT INTO agent(uname,password,) VALUES(?,?");
$values = array($uname,$pw);
$query->execute($values);
$counts=$query->rowCount();
return $counts;
I am looking for some way, to check in same way for the previous case.
Thanks for the additional code
$query->execute();
This will return True on a successful query and False if there was an error when executing the query