I am learning PDO. I have a class - User...
class User {
protected static $table_name="users";
public $id;
public $first_name;
public $last_name;
public function pdo_create() {
global $handler;
$sql = " INSERT INTO users (first_name, last_name)";
$sql .= " VALUES (?, ?)";
$query = $handler->prepare($sql);;
$query->execute(array($this->first_name ,$this->last_name));
}
}
When I run this...
$user= new User();
$user->first_name = "test";
$user->last_name = "test";
$user->pdo_create();
It works fine. I know it's a bit odd posting when things are working, but I have suspicions that this is not the best approach. I am still learning PDO and about the convert my MySQLi site over to PDO. I want to make sure the PDO veterans think this is a reasonable approach.