Exemple #1
0
 /**
  * Retrieve one or all settings from the Db as a string or an array;
  *
  * @param null $setting	Name of setting to retrieve, or null for all settings
  *
  * @return string|array|bool
  */
 function getSetting($setting = null)
 {
     $results = [];
     $table = $this->_db->table();
     $sql = "SELECT setting, value FROM {$table} ";
     if ($setting !== null) {
         $sql .= "WHERE setting = '{$setting}' ";
     }
     $sql .= 'ORDER BY setting';
     $result = $this->_db->queryArray($sql);
     if ($result instanceof \Traversable) {
         foreach ($result as $row) {
             $results[$row['setting']] = $row['value'];
         }
     }
     return count($results) === 1 ? $results[$setting] : $results;
 }