I am basically using the same code that works in another scrip into this new class and somehow is not working. I really don't understand why is not working right now.
I keep getting the error "Call to a member function query() on a non-object"
Could anyone tell me what I've done wrong?
<?php
class ldcStepOne {
public $JSON;
private $db;
public function __contruct () {
$this->JSON = $JSON;
$this->db = new PDO ('mysql:host=localhost;dbname=X','X','X');
}
public function stepOne ( $JSON ) {
$sql = 'SELECT * FROM ldc_user_details WHERE uID=101';
$result = $this->db->query($sql)->fetch(PDO::FETCH_ASSOC);
return $result;
}
}