Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $host = "localhost";
- $db = "dev";
- $user = "dev";
- $pass = "dev";
- $dsn = "mysql:host=$host;dbname=$db;";
- try
- {
- $pdo = new PDO($dsn, $user, $pass);
- } catch (PDOException $ex) {
- echo 'Connection failed: ' . $ex->getMessage();
- die();
- }
- ?>
- <?php
- include_once('pdo.inc.php');
- class Customers
- {
- function GetCustomerName($pdo, $customer_id)
- {
- $query = "SELECT first_name FROM Customers WHERE customer_id = :customer_id LIMIT 1";
- $stmt = $pdo->prepare($query);
- $stmt->bindParam(':customer_id', $customer_id);
- $stmt->execute();
- return $stmt->fetchColumn();
- }
- }
- ?>
- <?php
- include_once('customers.class.php');
- $a = new Customers();
- echo $a->GetCustomerName($pdo, 1);
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement