Overview
Comment:rendre publique ces méthodes bien utiles
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1: 9e037ff8543fc30c3d3ac20dda5e5fa8e387a822
User & Date: bohwaz on 2014-03-21 03:44:44
Other Links: manifest | tags
Context
2014-03-21
03:45
Donner l'URL vers un plugin check-in: e57c4023d7 user: bohwaz tags: trunk
03:44
rendre publique ces méthodes bien utiles check-in: 9e037ff854 user: bohwaz tags: trunk
03:43
Mise en avant des numéros dans les listes check-in: 84fea36049 user: bohwaz tags: trunk
Changes

Modified src/include/class.db.php from [5025f71f76] to [aedffdc1cb].

    16     16   
    17     17   class DB extends \SQLite3
    18     18   {
    19     19       static protected $_instance = null;
    20     20   
    21     21       protected $_running_sum = 0.0;
    22     22   
           23  +    const NUM = \SQLITE3_NUM;
           24  +    const ASSOC = \SQLITE3_ASSOC;
           25  +    const BOTH = \SQLITE3_BOTH;
           26  +
    23     27       static public function getInstance($create = false)
    24     28       {
    25     29           return self::$_instance ?: self::$_instance = new DB($create);
    26     30       }
    27     31   
    28     32       private function __clone()
    29     33       {
................................................................................
   202    206       {
   203    207           if ($mode != SQLITE3_BOTH && $mode != SQLITE3_ASSOC && $mode != SQLITE3_NUM)
   204    208           {
   205    209               throw new \InvalidArgumentException('Mode argument should be either SQLITE3_BOTH, SQLITE3_ASSOC or SQLITE3_NUM.');
   206    210           }
   207    211   
   208    212           $args = array_slice(func_get_args(), 2);
   209         -        return $this->_fetchResult($this->simpleStatement($query, $args), $mode);
          213  +        return $this->fetchResult($this->simpleStatement($query, $args), $mode);
   210    214       }
   211    215   
   212    216       public function simpleStatementFetchAssoc($query)
   213    217       {
   214    218           $args = array_slice(func_get_args(), 1);
   215         -        return $this->_fetchResultAssoc($this->simpleStatement($query, $args));
          219  +        return $this->fetchResultAssoc($this->simpleStatement($query, $args));
   216    220       }
   217    221   
   218    222       public function simpleStatementFetchAssocKey($query, $mode = SQLITE3_BOTH)
   219    223       {
   220    224           if ($mode != SQLITE3_BOTH && $mode != SQLITE3_ASSOC && $mode != SQLITE3_NUM)
   221    225           {
   222    226               throw new \InvalidArgumentException('Mode argument should be either SQLITE3_BOTH, SQLITE3_ASSOC or SQLITE3_NUM.');
   223    227           }
   224    228   
   225    229           $args = array_slice(func_get_args(), 2);
   226         -        return $this->_fetchResultAssocKey($this->simpleStatement($query, $args), $mode);
          230  +        return $this->fetchResultAssocKey($this->simpleStatement($query, $args), $mode);
   227    231       }
   228    232   
   229    233       public function escapeAuto($value, $name = '')
   230    234       {
   231    235           $type = $this->_getArgType($value, $name);
   232    236   
   233    237           switch ($type)
................................................................................
   291    295           {
   292    296               return $row;
   293    297           }
   294    298       }
   295    299   
   296    300       public function queryFetch($query, $mode = SQLITE3_BOTH)
   297    301       {
   298         -        return $this->_fetchResult($this->query($query), $mode);
          302  +        return $this->fetchResult($this->query($query), $mode);
   299    303       }
   300    304   
   301    305       public function queryFetchAssoc($query)
   302    306       {
   303         -        return $this->_fetchResultAssoc($this->query($query));
          307  +        return $this->fetchResultAssoc($this->query($query));
   304    308       }
   305    309   
   306    310       public function queryFetchAssocKey($query, $mode = SQLITE3_BOTH)
   307    311       {
   308         -        return $this->_fetchResultAssocKey($this->query($query), $mode);
          312  +        return $this->fetchResultAssocKey($this->query($query), $mode);
   309    313       }
   310    314   
   311         -    protected function _fetchResult($result, $mode)
          315  +    public function fetchResult($result, $mode = \SQLITE3_BOTH)
   312    316       {
   313    317           $out = [];
   314    318   
   315    319           while ($row = $result->fetchArray($mode))
   316    320           {
   317    321               $out[] = $row;
   318    322           }
................................................................................
   319    323   
   320    324           $result->finalize();
   321    325           unset($result, $row);
   322    326   
   323    327           return $out;
   324    328       }
   325    329   
   326         -    protected function _fetchResultAssoc($result)
          330  +    protected function fetchResultAssoc($result)
   327    331       {
   328    332           $out = [];
   329    333   
   330    334           while ($row = $result->fetchArray(SQLITE3_NUM))
   331    335           {
   332    336               $out[$row[0]] = $row[1];
   333    337           }
................................................................................
   334    338   
   335    339           $result->finalize();
   336    340           unset($result, $row);
   337    341   
   338    342           return $out;
   339    343       }
   340    344   
   341         -    protected function _fetchResultAssocKey($result, $mode)
          345  +    protected function fetchResultAssocKey($result, $mode = \SQLITE3_BOTH)
   342    346       {
   343    347           $out = [];
   344    348   
   345    349           while ($row = $result->fetchArray($mode))
   346    350           {
   347    351               $key = current($row);
   348    352               $out[$key] = $row;