1
クラスの機能コール値
public function bind($param, $value, $type = null)
{
if (is_null($type)) {
switch (true) {
case is_int($value):
$type = PDO::PARAM_INT;
break;
case is_bool($value):
$type = PDO::PARAM_BOOL;
break;
case is_null($value):
$type = PDO::PARAM_NULL;
break;
default:
$type = PDO::PARAM_STR;
}
}
$this->stmt->bindValue($param, $value, $type);
}
呼び出し方法
`$this->bind(":id","1","is_int");`
//output = $this->stmt->bindValue(:id,1,is_int);
質問:私は$に値を得ることができるように、私は値を渡すことができますどのようにthis-> stmt-> bindValue( ":id"、 "1"、PDO :: PARAM_INT);
そのコードから教えていますが、PDOクラスを拡張する場合は、'バインドタイプのようなものにそれを拡張するのは難しい:あなたは、関数でパラメータに使用します渡す必要はありません。 –