Jump to content
MakeWebGames

Recommended Posts

Posted

For your class like that (especially with classes like GRPG V1) you could use the __get($var) magic method to retrieve all your stats so that you don’t have to keep editing your array each time you make a change to the database

Posted
9 hours ago, urbanmafia said:

im playing around with the classes currently and changing them. For the stats ive decided to just go with this to save editing it all the time

public function getStats() { $stmt = $this->db->prepare("SELECT * FROM user_stats WHERE US_id = (:id) LIMIT 1"); $stmt->bindParam(":id", $this->id, PDO::PARAM_INT); if($stmt->execute()): if($stmt->rowCount() > 0): $result = $stmt->fetch(); endif; endif; return $result; }


public function getStats()
{
	$stmt = $this->db->prepare("SELECT * FROM user_stats WHERE US_id = (:id) LIMIT 1");
    $stmt->bindParam(":id", $this->id, PDO::PARAM_INT);
		
	if($stmt->execute()):
    	if($stmt->rowCount() > 0):
		$result = $stmt->fetch();
        endif;
    endif;
  return $result;
}

 

Ok, I see what you are doing there. One more recommendation:

You should return a result if nothing is found for whatever reason. If there isn’t any rows, it returns absolutely nothing at all because $result is only defined if there are rows found

Posted
3 hours ago, KyleMassacre said:

[...]

If there isn’t any rows, it returns absolutely nothing at all because $result is only defined if there are rows found

With strict standards, it'd throw an error (Undefined variable: result)

Posted

I'd be happy to donate you some free MakeWebGames hosting with a sub-domain to host a demo for the community if you'd like. PM me if you're interested!

  • Like 1
Posted
41 minutes ago, urbanmafia said:

Thankyou dave for the offer im currently hosting it on my dedicated server might be a good idea to host it here after it is completed. The demo should be released around Wednesday after the base is all finished.

Okay great! You do whatever you thinks best, excited to see it.

Will it be open source?

  • 3 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...