picoSQL and PHP

Corso Italia, 178 - 56125 Pisa
phone/fax +39 050 46380
e-mail picosoft@picosoft.it

Starting from release 1.5beta, you can access picoSQL from PHP pages. The installation is rather simple, anyway we hope that picoSQL will be supported in the standard PHP release. At this moment, you need to perform some modification on 2 files in the distribution and to compile as usual. picoSQL use the the "Unified ODBC functions", (see here) but, with the following instructions, you do not need to install any ODBC support.
The following instructions are tested on PHP 4.3.1 Linux version, but we presume that should be valid also for other releases, with few changes.
First of all, you must set php-4.3.1/ext/odbc as current directory and edit the file config.m4 . This file cantains several blocks of text, one for each supported database. Each block starta with an if command at column 1 and ends with a fi command at column 1 too. In this file, you need to add a block of text for picoSQL before the last one, which start with the line

if test -n "$ODBC_TYPE"; then
. The block to add is the following one:
dnl --------------------------- start picoSQL configuration
if test -z "$ODBC_TYPE"; then
AC_MSG_CHECKING(for picoSQL support)
[  --with-picoSQL[=DIR]   Include picoSQL support.  DIR is the
                          picoSQL base install directory, defaults to
  if test "$withval" = "yes"; then
  if test "$withval" != "no"; then
    PHP_ADD_LIBRARY_WITH_PATH(picocpp, $withval/lib)
    PHP_ADD_LIBRARY_WITH_PATH(picoiiop, $withval/lib)
    PHP_ADD_LIBRARY_WITH_PATH(picosqlnet, $withval/lib)
    PHP_ADD_INCLUDE($withval/inc, 1)
    ODBC_LIBS=-lpicosqlnet -lpicoiiop -lpicocpp
dnl --------------------------- end picoSQL configuration
The other file to modify is in the same directory and its name is php_odbc_includes.h. Also in this file there are blocks of text, one for each database supported. Each block starts with a #elif defined command (of course the first starts with a #if defined command) and ends at the next #elif defined (excluding the last 2 blocks that and with a #else and with a #endif). We put the block to add before the line
#else /* MS ODBC */
and it is the following one:
/* ---------------------- start picoSQL */
#elif defined(HAVE_PICOSQL) /* PICOSQL */
#define ODBC_TYPE "picoSQL"
#include <odbcsql.h>
/* ---------------------- end picoSQL */
Now, you need set the root directory of PHP as current directory (cd ../..) and run the command ./buildconf (eventually using the --force option). At the end of the run, picoSQL is configured and, in fact, it appears in the list of the supported database, as you can see running the command ./configure --help. You can now to configure the compilation as usual, remembering to add the option --with-picoSQL=/directory/of/picoSQL; For example:
./configure --with-picoSQL=/usr/local/picoSQL
At this point, if you use GNU-C until rel 2.96, you can launch the compilation as usual and you get a picoSQL enabled PHP. If you use a more recent GNU-C release (we try with GNU-C rel 3.2.2), there is another problem to solve, due to the fact that a big part of picoSQL is written using C++. C++ programs need a particular linkage phase to bind virtual methods, constructors and other. Using GNU-C until 2.96, this phase was executed also using the gcc program as linker program, while in the 3.2.2 this phase is executed only using the g++ program as linker program. So you need to modify the Makefile to do the g++ execute the linking phase. This command is contained in two variables whose name is BUILD_CLI and BUILD_CGI. So you need to modify the following two (long) lines:
   BUILD_CLI = $(LIBTOOL) --mode=link $(CC) ...
   BUILD_CGI = $(LIBTOOL) --mode=link $(CC) ...
with the following ones:
   BUILD_CLI = $(LIBTOOL) --mode=link g++ ...
   BUILD_CGI = $(LIBTOOL) --mode=link g++ ...

SourceForge.net Logo
Last update: 2003-08-25