-2

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.

halfer
  • 19,824
  • 17
  • 99
  • 186
ikiK
  • 6,328
  • 4
  • 20
  • 40
  • Holy moly, *how many* global variables?? Have you not heard of arrays? – Niet the Dark Absol Jan 09 '17 at 11:33
  • you call this story *short*? – Your Common Sense Jan 09 '17 at 11:33
  • So you are asking us to do your job for you, instead of helping you figure out what the actual cause of the problem is, so you yourself can do your job? – Ludricio Jan 09 '17 at 11:34
  • I stared with few, I'm changing it every day to make it work. I will do cosmetics after, its work in progress. – ikiK Jan 09 '17 at 11:39
  • I can not compile new dll plug in. I don't even know how much time or work that takes. Also be free to point out if you see anything wrong with code, thats why i posted it. Only thing I could think of at this point its those pdo limitations and the pdo with bug fixes that i can not find anywhere to download. I have changed this code in so many ways in last month that theres no point of listing them all. – ikiK Jan 09 '17 at 11:42
  • Why being so hard on me. I have stated I'm new to all this and im stuck. You could have just say no thats big work to compile new plug in. How should I know that? I tried to do it myself. ON windows server with codeblocks, it didn't work. And apparently cross compiling on mac doesn't work. – ikiK Jan 09 '17 at 11:45
  • @ Your Common Sense It started short. But i don't know how to describe my problem shorter, nether I have words for it, I'm completely self learned on everything about this. Btw your tutorial is very useful. I have read it few time in last month... – ikiK Jan 09 '17 at 12:29
  • I would not advise that you run any compiled binary if you have obtained it from someone on the internet. It is _much_ safer to find out how to compile it, and then compile it yourself. If you need Windows to do so then run a dev copy of Windows (available from Microsoft for free) on VirtualBox (available from Oracle for free). – halfer Jan 09 '17 at 12:33
  • 1
    @halfer I didn't know that. Thanks you for your advise, like I did mention, i don't have one minute in schooling in any programing language or anything computer related, I'm new to this. And I'm using 6 languages for this webpage. I will do it myself then somehow. Thank you. – ikiK Jan 09 '17 at 12:37
  • You are still welcome to get advice, just don't install or run any binaries that people send you, nor solicit them. This will protect you from malicious code. Also, it is best not to explicitly ask any "do it for me" questions here - readers want to cut beginners a break, but we get a _lot_ of lazy people here, and it is critical not to sound like them, even a little bit! – halfer Jan 09 '17 at 16:09
  • Would you reword your question a bit? I wonder if the `problems I'm encountering are almost impossible to describe` needs to be expanded on. It is possible that you do not need to recompile PHP, but it is unlikely anyone can understand the problems you're having. – halfer Jan 09 '17 at 16:09
  • Ok I can understand that. Problems are hard to explain, it all works while it doesn't not... I put to much work in this to give up now. But I find here same problem http://forums.4d.fr/Post/EN/5206105/1/18891690#18891690 , and i just posted my problem there. Thats why i wont to try my version and that plc. I installed parallels desktop, win xp and visual studio 6. And now I'm stuck again. I cant find any tutorial how to compile it... – ikiK Jan 09 '17 at 17:15
  • @halfer looks like this original version has memory leaks and some limitations... bugs are fixed but there is not dll to download just source files. – ikiK Jan 09 '17 at 17:44
  • Would you have any luck upgrading from PHP 5.3? This is well out of support anyway, so you must do so as a matter of some importance. In doing so, you may get the bugfixes you need for the PDO module. – halfer Jan 09 '17 at 18:44
  • @halfer this php server (virtual machine with windows server 2012 with xamp) runs just for this, the module 4d-pdo was made for 5.3 php and there is no newer version (I seen people compile there own for newer version, also there si source files for new php 7. on github, but guess what, compiling again, don't know how to...). So I installed corresponding version of php. That idea did cross my mind, but I don't think that will fix anything. But I will try it today. But I'm running out of ideas, so feel free to throw some more, thank you for your time. – ikiK Jan 10 '17 at 08:09
  • @halfer I installed php7, apache wont loud that same driver. Im guessing it needs to be for that version 7. Source files; https://groups.google.com/forum/#!topic/pdo_4d/Vyukkt_EuZY – ikiK Jan 10 '17 at 12:53
  • Yes, it will need compiling for every different 5.x and 7.y as far as I know. As I say, I don't know for certain you need to recompile, since there may be settings you can try to fix your problem. I don't know what they are, of course. However if you want to try compiling against a later PHP, then set up a Windows VM and the compile toolset, and ask a question if you get stuck. It sounds like you might have found some resources to give it a go yourself first. – halfer Jan 10 '17 at 13:01
  • 1
    @halfer just to inform you that i have managed to make it work with this instructions. http://eosrei.net/articles/2013/06/compiling-pdo4d-extension-recent-versions-php5 . Now its all working on ubuntu, and compiling is explained great and does not produce any errors. And I host the script on it. It looks I was right after all that original driver is faulty. I really did all I could with original. – ikiK Jan 18 '17 at 17:34
  • Great @ikiK. It would be really splendid if you could write a full answer below to help someone else who might want to do the same thing. Comments are not searchable here, but answers are. Do note though that while links are welcome at the end of answers, we generally do not accept link-only answers - we want help and guidance in the actual answers. – halfer Jan 18 '17 at 17:36
  • @halfer I just did that while you where typing answer to me, i hope I explained it in right way. If not I can edit it. – ikiK Jan 18 '17 at 17:38
  • In my opinion it is rather brief. If the link is removed it doesn't really explain anything at all. Could you replicate the console commands (either from that article or from your console history) in that answer? We're trying to ensure that if a link dies (which happens quite often) any posts that use them are still useful. That's why I prefer links at the end - they are almost an afterthought, rather than the main thing. – halfer Jan 18 '17 at 17:39
  • 1
    @halfer yes I can. – ikiK Jan 18 '17 at 17:40

2 Answers2

2

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.

halfer
  • 19,824
  • 17
  • 99
  • 186
ikiK
  • 6,328
  • 4
  • 20
  • 40
  • 1
    @halfer no thank you for having patience for me from start. I was stuck and like I said, I never done anything like this in my life. So I'm limited in explaining myself and knowledge. 0 schooling on anything IT related. You helped me also in understanding how this site works. So thank you one more time. Cheers. – ikiK Jan 18 '17 at 18:12
  • No problem. I would suggest you next try to compile against a later version of PHP - as I outlined some days ago, you should not really be running PHP 5.3, as it is out of regular _and_ security support. If the above process is easy, try 5.4, 5.5, 5.6, 7.0 etc in turn (they may get progressively harder to compile or not work at all) but even a single bump is better than none at all. – halfer Jan 18 '17 at 18:56
  • @halfer I remember you said that and i know what about you are talking about, but, all this is running on local work network and we have certificates for security so I'm little sceptic that anything could happen. But that is something too think about for sure. At this point I'm just happy that this is working as we needed it. And of corse i will develop this as time goes by. Thank you for advice. – ikiK Jan 18 '17 at 19:07
  • 1
    @halfer also i have already find a github with driver predefined for php 7. So I will definitely have go at it at some point. – ikiK Jan 18 '17 at 19:17
1

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

ikiK
  • 6,328
  • 4
  • 20
  • 40