Jump to content

supertrucker

Members
  • Posts

    171
  • Joined

  • Last visited

About supertrucker

  • Birthday 07/24/1978

Previous Fields

  • Languages
    Learning, forgetting, and learning again: Java,PHP, HTML/XHTML, SQL, Pascal

Profile Information

  • Location
    The sticks, Michigan!
  • Interests
    Gadgets that beep and make noise, my children, my bike, and getting lost on the internet.

supertrucker's Achievements

Member

Member (2/7)

0

Reputation

  1. Wow, I feel a little dumb now! I was calling the method with '::' instead of '->', thanks!
  2. Hello,I have written a custom class that is going to handle all of my CRUD operations for my "user" table. Below is the class: <?php class UserDb { const TABLE = "users"; const KEY_ID = "Id"; const KEY_EMAIL = "email"; const KEY_JOIN_DATE = "joinDate"; const KEY_VERIFIED = "verified"; const KEY_LAST_LOGIN = "lastLogin"; const KEY_FIRST_NAME = "firstName"; const KEY_LAST_NAME = "lastName"; const KEY_PASSPHRASE = "passphrase"; private $db = null; public function __construct() { $this->db = new PDO( 'mysql:host=' . HOST_NAME . ';dbname=' . DATABASE_NAME . ';charset=utf8', DATABASE_USER, DATABASE_PASS ); $this->db->setAttribute(PDO::ATTR_EMULATE_PREPARES, false); $this->db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION); } public function userExists($email) { $sql = $this->db->prepare("SELECT * FROM " . self::TABLE . " WHERE " . self::KEY_EMAIL . " = :email"); $sql->execute(array(':email' => $email)); $row_count = $sql->rowCount(); if ($row_count > 0) { return true; } else { return false; } } public function insertUser($user = null) { if (is_null($user)) { $user = new User(); } } } ?> When I run this, I get: Can anyone tell me what I've done wrong? I've never worked with classes in php before.Thank you in advance!
×
×
  • Create New...