title: SQL requests optimization using OO PHP
body: <p>I'd like to know if there's a way to fully optimize my SQL requests using OO PHP. Let's take an example, we have 3 object classes named like 3 tables :</p>
  
  <ul>
  <li>Product : id, name, price, color...</li>
  <li>Customer : id, name, surname, email...</li>
  <li>Cart : id, id_product, id_customer...</li>
  </ul>
  
  <p>All getters and setters are made classically.
  Now, I only want to display Product[name] and Customer[surname] on my payment page.
  The corresponding fully optimized request is </p>
  
  <p><code>SELECT product.name, customer.surname FROM cart INNER JOIN product ON product.id = cart.id_product INNER JOIN customer ON customer.id = cart.id_customer</code></p>
  
  <p>Where or how can I generate this fully optimized request using OOP ? And not having to retrieve entire objects and treat them later ? Do I have to create a method for each sql request I need to be optimized ? Maybe a request generator ?</p>