Giter VIP home page Giter VIP logo

conexao-firebird-php's Introduction

Firebird Database Connection in PHP

This repository contains a PHP script that demonstrates how to connect to a Firebird database and perform a simple SELECT query. The script uses the PDO extension for database connectivity.

Prerequisites

Before running the script, ensure that you have the following:

  • PHP installed on your system
  • Firebird database server installed
  • Access to a Firebird database with the specified credentials

Configuration

Modify the following variables in the script to match your database configuration:

$host = 'localhost';
$database = 'C:\Users\otacio.barbosa\Desktop\db_2_5\db_2_5\examples.fdb';
$user = 'SYSDBA';
$password = 'masterkey';
  • $host: The host or IP address of your Firebird database server.
  • $database: The path to your Firebird database file.
  • $user: The username for connecting to the database (default is 'SYSDBA').
  • $password: The password for the specified user.

Running the Script

Execute the script in a PHP environment. You can run it through the command line or set up a web server to execute the script via a browser.

php your_script_name.php

Script Explanation

The script connects to the Firebird database using PDO and performs a SELECT query on the "CUSTOMER" table. It then fetches the results and prints information for each customer, including CUSTOMER_ID, NAME, ADDRESS, ZIPCODE, and PHONE.

$sql = "SELECT * FROM CUSTOMER";
$stmt = $pdo->query($sql);

while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) {
    // Print customer information
    echo "CUSTOMER_ID: " . $row['CUSTOMER_ID'] . "<br>";
    echo "NAME: " . $row['NAME'] . "<br>";
    echo "ADDRESS: " . $row['ADDRESS'] . "<br>";
    echo "ZIPCODE: " . $row['ZIPCODE'] . "<br>";
    echo "PHONE: " . $row['PHONE'] . "<br>";
    echo "<br>";
}

Error Handling

The script includes error handling to catch any connection or query-related errors and display them.

catch (PDOException $e) {
    echo 'Connection error: ' . $e->getMessage();
}

Feel free to adapt and expand upon this script for your specific use case. If you encounter any issues, refer to the error messages for troubleshooting.

conexao-firebird-php's People

Contributors

otaciobarbosa avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.