Create php function automate code lines

By Kamikaze

guys, I currently use the following code to run a query pdo. Note that I type “SELECT * FROM PRINTERS”. But how do I create a function where I put my querys and just call them via function. It does not have to be the result, it would just be the query itself.


        function db_connect()
     $PDO = new PDO('mysql:host=' . DB_HOST . ';dbname=' . DB_NAME .     ';charset=utf8', DB_USER, DB_PASS);
   return $PDO;
    function make_hash($str)
  return sha1(md5($str));
    // verica se está logado
  * Verifica se o usuário está logado
     function isLoggedIn()
 if (!isset($_SESSION['logged_in']) || $_SESSION['logged_in'] !== true)
    return false;
return true;

index.php ( where i run querys )


Source: Stack Overflow


Share it with your friends!

    Fatal error: Uncaught Exception: 12: REST API is deprecated for versions v2.1 and higher (12) thrown in /home/content/19/9652219/html/wp-content/plugins/seo-facebook-comments/facebook/base_facebook.php on line 1273