Flux rss

Connecting to an Ingres database with PHP

Published by netty5, last update on Sunday November 16, 2008 09:09:05 AM by netty5

Connecting to an Ingres database with PHP







This tip is based on following Ingres documentation:

Getting started


Ingres ® 2006 Release 2 for Windows Quick Start Guide (qs_windows.pdf)
Ingres ® 2006 Release 2 for Linux Quick Start Guide (qs_linux.pdf)

Download PECL


Windows (driver) http://pecl4win.php.net/ext.php/php_ingres.dll
Linux & Unix (code source) http://pecl.php.net/package/ingres

Installation


Windows


Copy the file php_ingres.dll in the directory of PHP extensions.
Edit your php.ini and add the following line:
extension = php_ingres.dll

Linux & Unix


Locate the directory where the command phpize or php-config lies.
On some Linux distributions it is necessary to rename these files to avoid conflicts.
To compile the Ingres PECL library you need a compiler.
Make sure that the variable II_SYSTEM is valued.
echo $II_SYSTEM

Move to the directory containing the source code for the extension :


Generate configuration for the extension:

phpize

Build the Makefile:
./configure --with-ingres

Compile the extension:

make

Install the extension:

make install

Edit php.ini and add the following line extension = ingres.so
If you use Apache, use the directive users of httpd.conf
to make sure that Apache will run well with a valid Ingres user

===Apache for Linux & Unix===
In the Apache configuration, add the following lines

LoadModule env_module modules/mod_env.so
SetEnv II_SYSTEM votre-répertoire-II_SYSTEM
SetEnv LD_LIBRARY_PATH votre-répertoire-II_SYSTEM/ingres/lib

Getting connected


Connection
<?php
$link = ingres_connect(“mydb”, “username”, “password”);
or die(“Could not connect”);
echo “Connected successfully”;
ingres_close($link);
?>


Error testing
<?php
$link = ingres_connect(“mydb”, “username”, “password”);
if (ingres_errno($link) != 0) {
echo ingres_errno($link) . “ : “ . ingres_error($link) . “<BR/>\n”;
}
?>


Simple request
<?php
$link = ingres_connect(“mydb”, “username”, “password”);
// Gives a list of the tables
$sql = “select * from iirelation order by relid asc”;
$rc = ingres_query($sql,$link);
// Do some error checking...
while ( $iirelation = ingres_fetch_object($link) ) {
echo $iirelation->relid “<BR/>\n”;
}
?>


Request with specific parameters
<?php
$link = ingres_connect(“iidbdb”, “ingres”, “ingres”);
// Gives a list of the tables based on a parameter
$sql = “select * from iirelation where relowner = ? order by relid asc”;
$params[“owner1”] = (“usrname”);
$rc = ingres_query($sql,$link,$params);
// Do some error checking...
while ( $iirelation=ingres_fetch_object($link) ) {
echo $iirelation->relid “<BR/>\n”;
}
?>


Loading a BLOB
<?php
// Fetch the image to be inserted
$handle = fopen (“usrname.png”,”r”);
$login_image = stream_get_contents($handle);
fclose($handle);
// Set up the query
$sql = “insert into login_images values (?,?)”;
// Type the parameters being passed
$types = “vB”; // varchar, BLOB
// Set up the parameter values
$params[“login”] = “usrname”;
$params[“image”] = $login_image;
// Execute
$rc = ingres_query($sql,$link,$params,$types);
?>
MySQL Help, PHP and Database help (Solved) Hello, I am building a form/blog/personal site for a small company. I was wondering if someone could help me in setting up my database. i have thought of a few options but i am not quite sure what one is the best. each user have a person page, they... en.kioskea.net/forum/affich-21728-mysql-help-php-and-database-help
Databases - ODBC (Open Database Connectivity) ODBC stands for Open Database Connectivity. This is a Microsoft-defined format for communicating between Windows database clients and consumer DBMSs. The ODBC managier can be found in Windows 3.1 and 9x. In Windows 95 and 98, it is available in the... en.kioskea.net/bdd/odbc.php3
The MySQL adapter "mysql" is not availab hi,i going to install joomla in XP,but I get the following error message... Unable to connect to the database:The MySQL adapter "mysql" is not available. MySql is running smoothly when i login through the command line. Im using Apache. Please help... en.kioskea.net/forum/affich-18884-the-mysql-adapter-mysql-is-not-availab
Connecting to Oracle via phpConnecting to Oracle via php Settings Requirements Example of code Settings Below is an article based on an example of connection to an Oracle database through a php script. However it is not designed to configure your oracle... en.kioskea.net/faq/sujet-887-connecting-to-oracle-via-php
Getting connected to Ingres: the nodeGetting connected to Ingres: the node Node structure Testing Installation password On server side On client side: Making use of the node. An important feature when using Ingres is the node (vnode). This is where the Ingres/Net... en.kioskea.net/faq/sujet-919-getting-connected-to-ingres-the-node
Ingres DocumentationIngres Documentation INGRES is the acronym for INteractive Graphics REtrieval System is initially a research project that started at Berkeley. It was an open source that was meant for database management and searches. It is now known to be a... en.kioskea.net/faq/sujet-494-ingres-documentation
Mysql and Navicat Table DesignHello, I am really new to this . I am using Navicat with MySql. I have created a Database and a table. However, when I try to set a field type to text and the length to say 20 it always reverts back to 0 and will not import any data. It is probably... en.kioskea.net/forum/affich-4826-mysql-and-navicat-table-design
Error 322 Router not connected properlyA message just been deposited in the concierge. It covers the following message, posted by soft.8 the 2008/7/21 at 10:45 : http://en.kioskea.net/forum/affich.php3?ID=15936#1 Here is the problem as it was described : Error 322 Router not connected properly en.kioskea.net/forum/affich-18736-error-322-router-not-connected-properly
Protecting PHP file accessHello, I am building a PHP application. As part of that, I stored all of the frequently used variables (such as the MySQL database login information) in a file called "config.php" and then simply put "include 'config.php';" at the beginning... en.kioskea.net/forum/affich-15891-protecting-php-file-access
Download MovampMovamp is an environment of development to be taken. MovAMP was conceived to hold on a key USB or any other support of weak capacity. Connect it up in a computer equipped with Microsoft Windows and you have access to a server web,a database and... en.kioskea.net/telecharger/telecharger-191-movamp
Download WAMP ServerWAMP5 (WAMP means Windows Apache Mysql PHP) is a platform of Web development under Windows. It allows you to develop dynamic Web sites with Apache server, PHP5 script language, and the database of MySQL release 5. It also possesses PHPMyAdmin and... en.kioskea.net/telecharger/telecharger-1318-wamp-server
Download EasyPHPEasyphp is a packaged work environment containing web Apache Server, the MySQL database system management and PHP language support. It is offered with phpMyAdmin, an interface allowing to handle easily the database records. en.kioskea.net/telecharger/telecharger-1332-easyphp
Databases - Introduction A database (abbreviated DB) is an entity in which data can be stored in a structured manner, with as little redundancy as possible. Different programs and different users must be able to use this data. Therefore, the concept of a database is... en.kioskea.net/bdd/bddintro.php3
Sharing an Internet connection in Windows XP If you have a local area network (two or more computers connected in a network) with one computer connected to the Internet (via a modem, using a cable, etc.), it may be useful to make the connection accessible to the other computers on the network... en.kioskea.net/configuration-reseau/partage-connexion-internet.php3
Sharing an Internet connection If you have a LAN (two computers or more connected in a network), of which one is connected to the Internet (via a DSL modem, cable, etc.), it may be worthwhile to make the Internet accessible to the other computers on the LAN by installing software... en.kioskea.net/pratique/partage.php3