Jump to content

I am working on a project that is based of the the Huge PHP login Framework on Github. I am Working on adding in the other database tables for the users and I want to make it so I can see the data in the table on the admin page. The Admin index page has this implemented for the current table but I have created a page that is for the rest of less accessed information that an admin does not need to look at on a regular basis. I copy and pasted the getPublicProfilesOfAllUsers() from the UserModel.php and added it right below along with the changes to the code that I saw as necessary. Then I mapped the function and values on the admin controller page. I also created a basic html page that was based of the admin page that showed normal user information and I removed the code that I felt was not necessary. I know I have data in my Mysql Database in the table so I really don't know why its not being passed through to the html page. I have tried setting default values on the model page and still I get no information passed through to the webpage I don't know that I did wrong and it would be a big help if I could get some pointers. 

UserModel.php

index.php

private.php

AdminController.php

Link to comment
Share on other sites

Link to post
Share on other sites

public function index()
    {
        
		dd(UserModel::getPublicProfilesOfAllUsers());
		$this->View->render('admin/index', array(
                'users' => UserModel::getPublicProfilesOfAllUsers(),
				'extension' => UserModel::getUserExtensionOfAllUsers()
		)
        );
    }

why don't you try to test if the data is there with dd().

Ryzen 5700g @ 4.4ghz all cores | Asrock B550M Steel Legend | 3060 | 2x 16gb Micron E 2666 @ 4200mhz cl16 | 500gb WD SN750 | 12 TB HDD | Deepcool Gammax 400 w/ 2 delta 4000rpm push pull | Antec Neo Eco Zen 500w

Link to comment
Share on other sites

Link to post
Share on other sites

 I just did that and the getPublicProfilesOfAllUsers() function returns data just fine but getUserExtensionOfAllUsers() function does not return any data what so ever. Is there some differences in the functions that I am missing that would affect if there is data being returned?

    public static function getPublicProfilesOfAllUsers()
    {
        $database = DatabaseFactory::getFactory()->getConnection();

        $sql = "SELECT user_id, user_name, user_email, user_active, user_has_avatar, user_deleted FROM users";
        $query = $database->prepare($sql);
        $query->execute();

        $all_users_profiles = array();

        foreach ($query->fetchAll() as $user) {

            // all elements of array passed to Filter::XSSFilter for XSS sanitation, have a look into
            // application/core/Filter.php for more info on how to use. Removes (possibly bad) JavaScript etc from
            // the user's values
            array_walk_recursive($user, 'Filter::XSSFilter');

            $all_users_profiles[$user->user_id] = new stdClass();
            $all_users_profiles[$user->user_id]->user_id = $user->user_id;
            $all_users_profiles[$user->user_id]->user_name = $user->user_name;
            $all_users_profiles[$user->user_id]->user_email = $user->user_email;
            $all_users_profiles[$user->user_id]->user_active = $user->user_active;
            $all_users_profiles[$user->user_id]->user_deleted = $user->user_deleted;
            $all_users_profiles[$user->user_id]->user_avatar_link = (Config::get('USE_GRAVATAR') ? AvatarModel::getGravatarLinkByEmail($user->user_email) : AvatarModel::getPublicAvatarFilePathOfUser($user->user_has_avatar, $user->user_id));
        }


        return $all_users_profiles;
    }
	    public static function getUserExtensionOfAllUsers()
    {
        $database = DatabaseFactory::getFactory()->getConnection();

        $sql = $sql = "SELECT * FROM userextension WHERE userid > 10";
        $query = $database->prepare($sql);
        $query->execute();
	
        $all_users_profiles = array();

        foreach ($query->fetchAll() as $user) {

            // all elements of array passed to Filter::XSSFilter for XSS sanitation, have a look into
            // application/core/Filter.php for more info on how to use. Removes (possibly bad) JavaScript etc from
            // the user's values
             array_walk_recursive($user, 'Filter::XSSFilter');
			
            $all_users_stuff[$user->userid] = new stdClass();
			$all_users_stuff[$user->userid]->all = $user;
            $all_users_stuff[$user->userid]->user_id = $user->userid;
            $all_users_stuff[$user->userid]->address1 = $user->address1;
            $all_users_stuff[$user->userid]->address2 = $user->address2;
            $all_users_stuff[$user->userid]->state = $user->state;
            $all_users_stuff[$user->userid]->city = $user->city;
			$all_users_stuff[$user->userid]->zipcode = $user->zipcode;
			$all_users_stuff[$user->userid]->fullname = $user->fullname;
			$all_users_stuff[$user->userid]->stripeid = $user->stripeid;
			$all_users_stuff[$user->userid]->balance = $user->balance;
			$all_users_stuff[$user->userid]->totalpay = $user->totalpay;
			$all_users_stuff[$user->userid]->totaljobs = $user->totaljobs;
			$prints = "3dprints";
			$all_users_stuff[$user->userid]->$prints = $user->$prints;
			$all_users_stuff[$user->userid]->weld = $user->weld;
			$all_users_stuff[$user->userid]->cnc = $user->cnc;
			$all_users_stuff[$user->userid]->solder = $user->solder;
			$all_users_stuff[$user->userid]->phone = $user->phone;
			$all_users_stuff[$user->userid]->num = "100";
        }

        return $all_users_profiles;
    }

Any Help would be great. 

Link to comment
Share on other sites

Link to post
Share on other sites

Update: I changed the SQL Query and now it magically works without a problem. Hmm I guess I should not use the generated phpmyadmin Query

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×