blob: 892396e479122f040b63d36b32a97b4328723ead (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
<?php
namespace Micropoly;
use SQLite3Stmt;
class BoundVal
{
private $val;
private $type = null;
public function __construct($val, $type = null)
{
$this->val = $val;
$this->type = $type;
}
public function getVal() { return $this->val; }
public function getType() { return $this->type; }
public static function ofInt($val): self { return new self($val, SQLITE3_INTEGER); }
public static function ofFloat($val): self { return new self($val, SQLITE3_FLOAT); }
public static function ofText($val): self { return new self($val, SQLITE3_TEXT); }
public static function ofBlob($val): self { return new self($val, SQLITE3_BLOB); }
public static function ofNull(): self { return new self(null, SQLITE3_NULL); }
public function bind(SQLite3Stmt $stmt, $where): void
{
if ($this->type === null)
$stmt->bindValue($where, $this->val);
else
$stmt->bindValue($where, $this->val, $this->type);
}
}
|