Compiling a new pdo PDO_4D

682 views Asked by At

We have 32 client databases, some are big, with millions of records (V.11. Currently, hosted and build on Mac's). I have build a website on Windows 2012 64x Server and included last version of PDO with PHP version that was stated (Xamp 2.5 with PHP/5.3.8 ). Plugin and Apache are 32x.

My web page connects to all 32 clients on 4d sql servers and runs few SQL select quarries. The problems I'm encountering are almost impossible to describe. On some search terms it sometimes works and sometimes not. What I mean, if I search for "jone doe" it does give me results, and if I change one latter it doesn't, SQL connect handler on client stays hanging and web page goes to timeout.

Note that there is no pattern. Some searches are hanging on one client. some on 2 or 3. Different search is same, but different clients. Only one Search for specific number of 13 characters is passing all clients and it's working perfectly. Let me also say I'm targeting specific tables and columns so I'm sure my SQL query is not a problem, I have few search boxes and they are all single search no OR or AND SQL, also I'm selecting about 4-6 columns to display results for that one select query.

Also, it's all on private network at work. So connections are not the problem also. I will add that results can be from 0 - 50 maximum per one connection. Here is stripped down sample of code:

Connections are defined up, this is rest of the code:

function trazi($dbaza) { 
    global $db; global $db2; global $db3; global $db4; global $db5; global $db6; global $db7;  
global $db8; global $db9; global $db10; global $db11;   global $db12; global $db13; global  
$db14; global $db15; global $db16; global $db17; global $db18; global $db19; global $db20;  
global $db21; global $db22; global $db23; global $db24; global $db25; global $db26; global $db27; 
 global $db28; global $db29; global $db30; global $db31; global $db32;  
    global $inime; global $inoib; global $inbb; global $inbbroj; global $insb; 

    $odabrani = $dbaza->prepare('SELECT  STANJE, SUD_BROJ_O, SUD_BROJ_P, SUD_BROJ_JBR , NAZIV_LONG, OIB FROM PREDMETI WHERE SUD_BROJ_O = ? '); 
    $params = array($insb); 
    $odabrani->execute($params); 
    $rezultat = $odabrani->fetchAll(PDO::FETCH_ASSOC); 
unset($dbaza); 
unset($odabrani); 

if ($rezultat) { 


            <th>Ime i prezime</th>  
            <th>OIB</th> 
            <th>Bilježnički broj</th> 
            <th>Sudski parnički broj</th> 
            <th>Sudski ovršni broj</th> 
            <th>Stanje predmeta</th>';

    foreach($rezultat as $row) {
            echo "<tr>
            <td>".$row['NAZIV_LONG']. "</td>".
            "<td>".$row['OIB']."</td>".
            "<td>".$row['SUD_BROJ_JBR']."</td>".
            "<td>".$row['SUD_BROJ_P']."</td>".
            "<td>".$row['SUD_BROJ_O']."</td>".
            "<td>".$row['STANJE']."</td>".
            "</tr>";                
            } 
    echo "</table>"; 
    } else {
        echo "Vaša pretraga nije pronašla niti jedan rezultat.";
        }

}

unset($rezultat);


//ATLANTIC
echo '<br><br><div style="color:#922E19">ATLANTIC</div>';   
trazi($db);
ob_implicit_flush(true);
$buffer = str_repeat(" ", 4096);
echo $buffer;
ob_flush(); usleep(300000);

//CEDEVITA
echo '<br><br><div style="color:#922E19">CEDEVITA</div>';    
trazi($db2); 
ob_implicit_flush(true); 
$buffer = str_repeat(" ", 4096); 
echo $buffer; 
ob_flush(); usleep(300000); 

ETC... 

I really hope that this PDO limitations are the problem because on some queries it selects too much data and breaks.

The problem: I have made changes to 4d PDO source files and changed limitations. But I cannot compile it neither do I know how. I don't have a PC, my server is of no use for this topic and I'm on Mac. Can someone please help me compile a DLL with this changes. I will attach a zip file with changes made.

http://forums.4d.fr/4DBB_Main/x_User/18851165/files/18851204.zip

Edit; or can someone compile me this version with bug fixes; https://github.com/famsf/pecl-pdo-4d

I'm using PHP/5.3.8 32bits.

2

There are 2 answers

4
ikiK On BEST ANSWER

If anybody come across this thread the answer is here. Compiling works like it states and original driver is faulty after all. This versions works. I'm hosting my script on Ubuntu and compiled a new driver and its connecting to 32 databases with no errors.

You will need Ubuntu 12.04 and follow the code below.

# Install dependencies (You may need more)
sudo apt-get install php5-dev
# Clone a working version of the code from the FAMSF repo
git clone https://github.com/famsf/pecl-pdo-4d.git pdo_4d
cd pdo_4d
# Prepare the PHP extension for compiling
phpize
# Workaround acinclude.m4 pointing to incorrect header location.
# See: https://bugs.launchpad.net/ubuntu/+source/php5/+bug/1393640
sudo ln -s /usr/include/php5/ /usr/include/php
# Configure the package to the system
./configure --with-pdo-4d
# Compile!
make
# Copy the extension to PHP's library
sudo make install
# Create php5 module configuration file for PHP 5.4/5.5
sudo sh -c "echo extension=pdo_4d.so > /etc/php5/mods-available/pdo_4d.ini"
# Enable the module for PHP 5.4/5.5
sudo php5enmod pdo_4d
# Enable the module for PHP 5.3
sudo sh -c "echo extension=pdo_4d.so > /etc/php5/conf.d/pdo_4d.ini"
# Restart apache
sudo apache2ctl restart
# Check for PDO_4D in the PHP CLI Information
php -i | grep 4D

You will just need to make your own folder for step below;

sudo sh -c "echo extension=pdo_4d.so > /etc/php5/mods-available/pdo_4d.ini

folder mods-available, and it will all do as its stated, before all this just install PHP and Apache but for that you can find many explanations on the web. It's just a one line command and Linux does the rest.

Also skip # Enable the module for PHP 5.4/5.5, because Ubuntu will have 5.3, and its all you need.

1
ikiK On

Compling PDO_4D for php 7.0. On ubuntu 16.04 32bits, 32 its important because driver was made for 32 systems, or at least i think its important...

First you need corresponding php version of driver and php. I recommend this tested version of driver: http://git.thesecretgamer.de/faldon/pdo_4d.git

IMPORTANT : first upgrade and update your system before you install php and Apache because if you do it later it will install php 7.1 and driver didn't work for me.

//Installing server

sudo apt-get update
sudo apt-get install apache2
sudo apt-get install python-software-properties
sudo apt install php7.0-cli
sudo apt-get install php7.0-dev
sudo apt-get install php7.0-mbstring <--- for some reason you will need this, trust me. 
sudo apt-get install libapache2-mod-php7.0
apt install git

//compilation

# Install dependencies (You may need more)
sudo apt-get install php7.0-dev <--- I did this in steps before so skip it.
# Clone a working version of the code from the FAMSF repo
git clone http://git.thesecretgamer.de/faldon/pdo_4d.git pdo_4d <----- or just unpack your modified driver with your changes where ever you wont.
cd /var/4d/pdo_4d <------- navigate to driver folder
# Prepare the PHP extension for compiling
phpize
# Workaround acinclude.m4 pointing to incorrect header location.
# See: https://bugs.launchpad.net/ubuntu/+source/php5/+bug/1393640 <---- this may be fixed for php 7.0 but i did it anyway.
sudo ln -s /usr/include/php/20151012/ /usr/include/php
# Configure the package to the system
./configure --with-pdo-4d
# Compile!
make
# Copy the extension to PHP's library
sudo make install
# Create php module configuration file for PHP 7.0
sudo sh -c "echo extension=pdo_4d.so > /etc/php/7.0/mods-available/pdo_4d.ini"
# Enable the module for PHP 
sudo phpenmod pdo_4d
sudo sh -c "echo extension=pdo_4d.so > /etc/php/7.0/apache2/conf.d/pdo_4d.ini"
# Restart apache
sudo service apache2 restart
# Check for PDO_4D in the PHP CLI Information
php -i | grep 4D
php -m

Now keep in mind there may be few unnecessary steps, but this works, I did it 4 times. Credits go as mentioned in last post to Brad and this blog post with tutorial for php5. I just modified it for php7.0