Skip to content

Instantly share code, notes, and snippets.

@DavidMellul
Created March 14, 2018 23:19
Show Gist options
  • Select an option

  • Save DavidMellul/7f2907e769367c243f7769455b5d7e6c to your computer and use it in GitHub Desktop.

Select an option

Save DavidMellul/7f2907e769367c243f7769455b5d7e6c to your computer and use it in GitHub Desktop.
<?php
// Could have broken request clauses line by line
// SELECT X FROM Y WHERE Z
// ->
// SELECT X
// FROM Y
// WHERE Z
final class RequestHolder {
// Query a list of users without ordering
const USERS = 'SELECT * FROM USERS';
// Query all the messages of a user identified by @id_user, ordered by sending date
const USER_MESSAGES = 'SELECT * FROM Messages WHERE id_user = ? ORDER BY date_sent';
// And so on
// ...
private function __construct(){
// Stuff
}
}
$this->db->query(RequestHolder.USERS);
$this->db->query(RequestHolder.USER_MESSAGES, array('id_user' => 58));
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment