Pyh.conf’25: a new PHP conference for the Russian-speaking community

Voting

: max(zero, six)?
(Example: nine)

The Note You're Voting On

Ofir Attia
11 years ago
/*
method for pdo class connection, you can add your cases by yourself and use it.
*/
class Conn{
....
....
private $stmt;
public function bind($parameter, $value, $var_type = null){
if (is_null($var_type)) {
switch (true) {
case is_bool($value):
$var_type = PDO::PARAM_BOOL;
break;
case is_int($value):
$var_type = PDO::PARAM_INT;
break;
case is_null($value):
$var_type = PDO::PARAM_NULL;
break;
default:
$var_type = PDO::PARAM_STR;
}
}
$this->stmt->bindValue($parameter, $value, $var_type);
}

<< Back to user notes page

To Top