Evaluation of insert method from within a class using PDO 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-&gt;prepare($sql);;
        $query-&gt;execute(array($this-&gt;first_name ,$this-&gt;last_name));
    }
}


When I run this...

$user= new User();
$user-&gt;first_name = "test";
$user-&gt;last_name = "test";
$user-&gt;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.
Your design is flawed in the following way:

DO NOT USE GLOBAL.

It is not OO programming and you shouldn't be calling it if you are using PDO - pass your PDO through your function or as part of your user constructors. (see SOLID design patterns)

class User 
{
     //private attributes
     private $_db;
     public function __construct(PDO $pdo)
     {
         $this-&gt;_db = $pdo;
     }
}


your function pdo_create
is too couple with pdo - if you decide to switch off from pdo - you will need to re-write that function call to reflect what you change to - use convention a bit more general: creatingUser(PDO $pdo) for example or even better creatingUser(DBInterface $db) (as part of SOLID

Now as for the function itself:

+1 for using prepare statement however ? is more used for mysqli - it better to use place handler instead. such as VALUES(:first_name, :last_name). When you pass the array you can then use the place handler to effectively assign to which variable its value. It is best for readability later.

Finally: you defeat the purpose of the class if your attributes are PUBLIC. Ideally functions receives parameters by the function itself OR by the constructor of the class which initializes the attributes of the class.