robotpony/Presto — pull request #90 by ngallagher87 (2013-09-25 19:14:38+00:00)
Title: Including a db wrapper function that will format PDO params for you

## PDO helper

I'm adding a function that makes it a bit easier to generate PDO parameters.

**From this**

$params = array(
'candy' => array('value' => $this->favoriteCandy, 'pdoType' => PDO::PARAM_STR),
'person' => array('value' => $this->person, 'pdoType' => PDO::PARAM_INT)
);
$this->db->insert($sql, $params);

**To this**

$values = array(
'candy' => $this->favoriteCandy,
'person' => $this->person
);
$params = $this->db->generate_params($values);
$this->db->insert($sql, $params);

Pass this function an array of keys and values that you want to use in your DB query. `generate_params()` will return you a valid PDO array to use with your INSERT and UPDATE statements.

Supported types:
=================
PARAM_BOOL
PARAM_NULL
PARAM_INT
PARAM_STR

Unsupported types:
=================
PARAM_LOB
PARAM_INPUT_OUTPUT
PARAM_STMT (No drivers support this anyways)

**Note:**

If you need to use one of these unsupported types, you'll have to generate the params by hand.

Full Example:
========

$sql = << 'tuesday',
'dayNumber' => 2,
'isHoliday' => true
);
$params = $this->db->generate_params($values);
$this->db->insert($sql, $params);