Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 10 |
CRAP | |
0.00% |
0 / 27 |
| iaSqlite | |
0.00% |
0 / 1 |
|
0.00% |
0 / 10 |
380.00 | |
0.00% |
0 / 27 |
| __construct | |
0.00% |
0 / 1 |
2.00 | |
0.00% |
0 / 1 |
|||
| openOrCreate | |
0.00% |
0 / 1 |
2.00 | |
0.00% |
0 / 2 |
|||
| exec | |
0.00% |
0 / 1 |
2.00 | |
0.00% |
0 / 1 |
|||
| selectArrayIndex | |
0.00% |
0 / 1 |
20.00 | |
0.00% |
0 / 9 |
|||
| single_read | |
0.00% |
0 / 1 |
2.00 | |
0.00% |
0 / 1 |
|||
| begin | |
0.00% |
0 / 1 |
2.00 | |
0.00% |
0 / 1 |
|||
| commit | |
0.00% |
0 / 1 |
2.00 | |
0.00% |
0 / 1 |
|||
| rollback | |
0.00% |
0 / 1 |
2.00 | |
0.00% |
0 / 1 |
|||
| close | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 3 |
|||
| getColNames | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 7 |
|||
| lastErrorCode | n/a |
0 / 0 |
1 | n/a |
0 / 0 |
|||||
| lastErrorMsg | n/a |
0 / 0 |
1 | n/a |
0 / 0 |
|||||
| geto_version | n/a |
0 / 0 |
1 | n/a |
0 / 0 |
|||||
| get_sqlite3 | n/a |
0 / 0 |
1 | n/a |
0 / 0 |
|||||
| <?php | |
| /** | |
| * @author Informática Asocaida SA de CV | |
| * @version 1.0.0 | |
| * @copyright 2017 | |
| */ | |
| class iaSqlite { | |
| protected $db; | |
| public function __construct() { | |
| } | |
| public function openOrCreate($fileName) { | |
| $this->db = new SQLite3($fileName); | |
| } | |
| public function exec($query) { | |
| return $this->db->exec($query); | |
| } | |
| public function selectArrayIndex($query) { | |
| $result = $this->db->query($query); | |
| if($result === false) { | |
| return false; | |
| } | |
| if($result === true) { | |
| return true; | |
| } | |
| $return = []; | |
| while($row = $result->fetchArray(SQLITE3_ASSOC)) { | |
| $return[] = $row; | |
| } | |
| return $return; | |
| } | |
| public function single_read($query) { | |
| return $this->db->querySingle($query, false); | |
| } | |
| public function begin() { | |
| return $this->db->exec("BEGIN TRANSACTION"); | |
| } | |
| public function commit() { | |
| return $this->db->exec("commit"); | |
| } | |
| public function rollback() { | |
| return $this->db->exec("rollback"); | |
| } | |
| public function close() { | |
| if($this->db != null) { | |
| return $this->db->close(); | |
| } | |
| return false; | |
| } | |
| public function getColNames($table){ | |
| $colName = []; | |
| $qry = "SELECT * FROM $table LIMIT 1"; | |
| $result = $this->db->query($qry); | |
| $nCols = $result->numColumns(); | |
| for ($i = 0; $i < $nCols; $i++) { | |
| $colName[] = $result->columnName($i); | |
| } | |
| return $colName; | |
| } | |
| public function lastErrorCode() { return $this->db->lastErrorCode();} | |
| public function lastErrorMsg() { return $this->db->lastErrorMsg();} | |
| public function geto_version() {return $this->db->version (); } | |
| public function get_sqlite3() { return $this->db;} | |
| } | |