Today I come with a logical problem.
I have a class that gives me complete information of the user. I've created a method that allows me to recover all the data of each user how return me an object.
Here is the method :
public static function getAllUsers(&$rUsersData = null, $sArgs = null) {
// Nouvelle connexion à la base de données
self::$oDatabase = new cMySQLi(DB_USERNAME, DB_PASSWORD, DB_HOSTNAME, DB_HOSTPORT, DB_DATABASE);
// Si on ne passe pas de ressource en paramètre
if(is_null($rUsersData)) {
// Récupère les données de tout les users, actifs ou non
$sReqSelectAllUsers = ' SELECT
*
FROM
'.self::$sTableName.(is_null($sArgs) ? ' '.$sArgs.' ' : null).'
ORDER BY
'.self::$sFieldFirstname.' ASC';
// Exécute la requête
$rUsersData = self::$oDatabase->Query($sReqSelectAllUsers);
}
// Associe les données dans un tableau associatif à 2 dimensions
$aUsersData = self::$oDatabase->Assoc($rUsersData);
// Parcours chaque utilisateurs
while($aData = $aUsersData) {
// Retourne un objet avec les données de l'user
return new cUser($aData[self::$sFieldId]);
}
}
And here is the call that I use to recover all data :
while($aUser = cUser::getAllUsers()) {
print_r($aUser);
}
Here is my cMySQLi class if it can also help you : https://github.com/SatanicGeek/S.A.V-Team-Manager/blob/master/www/classes/mysqli.class.php
Could you help me to get all the users without any param in the method call (I can get of the users if I pass a sql ressource to my method) ?