title: Object of class Database could not be converted to string
body: <p>i'm using this methode to get data from db </p>
  
  <pre><code>class Database {
      private static $_instance = null;
      private $_pdo,
              $_query,
              $_error = false,
              $_results,
              $_count = 0;
  
      private function __construct() {
          try {
              $this-&gt;_pdo = new PDO('mysql:host='.Config::get('mysql/host').';dbname='.Config::get('mysql/db'),Config::get('mysql/username'),Config::get('mysql/password'));
          } catch (PDOException $e) {
              die($e-&gt;getMessage());
          }
      }
  
      public static function getInstance() {
          if (!isset(self::$_instance)) {
              self::$_instance = new Database();
          }
          return self::$_instance;
      }
  
      public function query($sql, $params = array()) {
          $this-&gt;_error = false;
          if ($this-&gt;_query = $this-&gt;_pdo-&gt;prepare($sql)) {
              $x = 1;
              if (count($params)) {
                  foreach ($params as $param) {
                      $this-&gt;_query-&gt;bindValue($x, $param);
                      $x++;
                  }
              }
  
              if ($this-&gt;_query-&gt;execute()) {
                  $this-&gt;_results = $this-&gt;_query-&gt;fetchAll(PDO::FETCH_OBJ);
                  $this-&gt;_count   = $this-&gt;_query-&gt;rowCount();
              } else {
                  $this-&gt;_error = true;
              }
          }
  
          return $this;
      }
  
      public function action($action, $table, $where = array()) {
          if (count($where) === 3) {
              $operators = array('=','&gt;','&lt;','&gt;=','&lt;=','&lt;&gt;');
  
              $field      = $where[0];
              $operator   = $where[1];
              $value      = $where[2];
  
              if (in_array($operator, $operators)) {
                  $sql = "{$action} FROM {$table} WHERE ${field} {$operator} ?";
                  if (!$this-&gt;query($sql, array($value))-&gt;error()) {
                      return $this;
                  }
              }
          }
          return false;
      }
  
      public function get($table, $where) {
          return $this-&gt;action('SELECT *', $table, $where); 
      }
  
      public function delete($table, $where) {
          return $this-&gt;action('DELETE', $table, $where);
      }
  
      public function insert($table, $fields = array()) {
          if (count($fields)) {
              $keys   = array_keys($fields);
              $values = null;
              $x      = 1;
  
              foreach ($fields as $field) {
                  $values .= '?';
                  if ($x&lt;count($fields)) {
                      $values .= ', ';
                  }
                  $x++;
              }
  
              $sql = "INSERT INTO {$table} (`".implode('`,`', $keys)."`) VALUES({$values})";
  
              if (!$this-&gt;query($sql, $fields)-&gt;error()) {
                  return true;
              }
          }
          return false;
      }
  
      public function update($table, $id, $fields = array()) {
          $set    = '';
          $x      = 1;
  
          foreach ($fields as $name =&gt; $value) {
              $set .= "{$name} = ?";
              if ($x&lt;count($fields)) {
                  $set .= ', ';
              }
              $x++;
          }
  
          $sql = "UPDATE {$table} SET {$set} WHERE id = {$id}";
  
          if (!$this-&gt;query($sql, $fields)-&gt;error()) {
              return true;
          }
          return false;
      }
  
      public function results() {
          return $this-&gt;_results;
      }
  
      public function first() {
          return $this-&gt;_results[0];
      }
  
      public function error() {
          return $this-&gt;_error;
      }
  
      public function count() {
          return $this-&gt;_count;
      }
  }
  </code></pre>
  
  <p><a href="http://i.stack.imgur.com/O587t.png" rel="nofollow">this is what i want to get</a> <strong>AND</strong>
  <a href="http://i.stack.imgur.com/YFDVF.png" rel="nofollow">this is my table</a></p>
  
  <p>this is my code ...</p>
  
  <pre><code>public function getModule() {
      $epreuve = $this-&gt;_db-&gt;get('epreuve', array('concour_code', '=', $this-&gt;data()-&gt;concour_code));
      foreach($epreuve-&gt;results() as $epreuve){
          echo "&lt;tr&gt;&lt;td&gt;".$epreuve-&gt;designation."&lt;/td&gt;"
          .$module = $this-&gt;_db-&gt;get('module', array('epreuve_code', '=', $epreuve-&gt;code ));               
          foreach($module-&gt;results() as $module){
          echo "&lt;tr&gt;&lt;td&gt;".$epreuve-&gt;designation."&lt;/td&gt;";
          }
          "&lt;/tr&gt;";
  
      }
  }
  </code></pre>
  
  <p>but i have this error </p>
  
  <p><strong>'' Catchable fatal error: Object of class Database could not be converted to string ''</strong></p>