I am trying to find the best way to use an instance of my connection inside a function, but I don't know if I should pass it in as a parameter of my function or use a global.
This is my code:
<?php require_once('class/connexion.php'); $cx = Connexion::getConnexion(); function get_customers(){ $query = "SELECT * FROM customers"; $select = $cx->prepare($query); $select->execute(); $result = $select->fetchAll(PDO::FETCH_ASSOC); return $result } get_customers(); ?>