Overview
Comment: | Correction pour que simpleStatementFetch* soit fonctionnel |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: |
f811c29a1a0e7ef9133aa56d33d6474c |
User & Date: | bohwaz on 2011-12-13 19:41:16 |
Other Links: | manifest | tags |
Context
2011-12-13
| ||
19:41 | Page de liste des membres check-in: 005cb17aa9 user: bohwaz tags: trunk | |
19:41 | Correction pour que simpleStatementFetch* soit fonctionnel check-in: f811c29a1a user: bohwaz tags: trunk | |
12:40 | Plan comptable des assos 1901 check-in: 0fa6198131 user: bohwaz tags: trunk | |
Changes
Modified include/class.db.php from [43a2014608] to [7a556aeae3].
︙ | ︙ | |||
49 50 51 52 53 54 55 | return SQLITE3_NULL; elseif (is_string($arg)) return SQLITE3_TEXT; else throw new InvalidArgumentException('Argument '.$name.' is of invalid type '.gettype($arg)); } | | > | | | | | | | | > > > > > > | > | | 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 | return SQLITE3_NULL; elseif (is_string($arg)) return SQLITE3_TEXT; else throw new InvalidArgumentException('Argument '.$name.' is of invalid type '.gettype($arg)); } public function simpleStatement($query, $args = array()) { $statement = $this->prepare($query); $nb = $statement->paramCount(); if (count($args) == 1 && is_array($args[0])) { if (count($args[0]) != $nb) { throw new LengthException('Only '.count($args[0]).' arguments in array, but '.$nb.' are required by query.'); } foreach ($args[0] as $key=>$value) { if (is_int($key)) { throw new InvalidArgumentException(__FUNCTION__ . ' requires second argument to be a named-associative array, but key '.$key.' is an integer.'); } $statement->bindValue(':'.$key, $value, $this->_getArgType($value, $key)); } } else { if (count($args) != $nb) { throw new LengthException('Only '.count($args).' arguments, but '.$nb.' are required by query.'); } for ($i = 1; $i <= count($args); $i++) { $arg = $args[$i - 1]; $statement->bindValue($i, $arg, $this->_getArgType($arg, $i)); } } return $statement->execute(); } public function simpleStatementFetch($query, $mode = SQLITE3_BOTH) { if ($mode != SQLITE3_BOTH && $mode != SQLITE3_ASSOC && $mode != SQLITE3_NUM) { throw new InvalidArgumentException('Mode argument should be either SQLITE3_BOTH, SQLITE3_ASSOC or SQLITE3_NUM.'); } $args = array_slice(func_get_args(), 2); return $this->_fetchResult($this->simpleStatement($query, $args), $mode); } public function simpleStatementFetchAssoc($query) { $args = array_slice(func_get_args(), 1); $result = $this->simpleStatement($query, $args); $out = array(); while ($row = $result->fetchArray(SQLITE3_NUM)) { $out[$row[0]] = $row[1]; } |
︙ | ︙ |