function getPageById($id) { // connect to database $db = new PDO('mysql:host=localhost;dbname=my_database', 'username', 'password'); // prepare SQL statement $stmt = $db->prepare('SELECT * FROM pages WHERE id = :id'); // bind parameters $stmt->bindParam(':id', $id); // execute query $stmt->execute(); // fetch page data $page = $stmt->fetch(PDO::FETCH_ASSOC); // return page data return $page; } // get page by ID $page = getPageById(1); // output page data echo $page['title']; echo $page['content'];In this example, we are connecting to a MySQL database and preparing an SQL statement that will retrieve all data from a table called "pages" where the ID matches a parameter we pass into the function. We then bind the ID parameter to the statement, execute the query, and fetch the data into an associative array. Finally, we return the page data so it can be used elsewhere in our code. The package library used in this example is PDO, which is a PHP extension used for working with databases. Other package libraries that could be used include mysqli and Doctrine.