diff options
author | Laria Carolin Chabowski <laria@laria.me> | 2020-02-07 09:44:59 +0100 |
---|---|---|
committer | Laria Carolin Chabowski <laria@laria.me> | 2020-02-07 09:44:59 +0100 |
commit | 2eb5a432d2229788ce2fdb09f36c6f4bebdea813 (patch) | |
tree | ab57978bdda34c82b025b897cfb6825b1fd1e654 /src/BoundVal.php | |
download | micropoly-2eb5a432d2229788ce2fdb09f36c6f4bebdea813.tar.gz micropoly-2eb5a432d2229788ce2fdb09f36c6f4bebdea813.tar.bz2 micropoly-2eb5a432d2229788ce2fdb09f36c6f4bebdea813.zip |
Initial commit
Diffstat (limited to 'src/BoundVal.php')
-rw-r--r-- | src/BoundVal.php | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/BoundVal.php b/src/BoundVal.php new file mode 100644 index 0000000..7a3560a --- /dev/null +++ b/src/BoundVal.php @@ -0,0 +1,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($val): self { return new self($val, 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); + } +}
\ No newline at end of file |