2016-08-09 3 views
0

私はDB2データベースを192.168.0.xxx:xxに、私のアプリケーション(PHPスクリプト)を192.168.0.xxx(Cent OS 6.2)に持っています。 PHPのスクリプトを通していくつかのdb2クエリを実行する必要があります。コア-4.0-IA32:コア-4.0-noarch:グラフィック-4.0-IA32:グラフィックphp - db2接続in centos6.2

  • PHP 5.3.3
  • CentOSのは 6.2(最終)
  • LSBバージョンをリリース-4.0-noarch:印刷-4.0-IA32:印刷-4.0-noarch
  • DATABASE IBM DB2 10.1 X64

私はDB2サーバーへの接続を作成する必要があると思います。これで私を助けてください。

答えて

0

EDIT
db2を動作させるには、libstdC++依存関係をインストールする必要があります。

- :

また
yum install libstdc++.so.6 

は、IBM DB2

resource db2_connect (string $database , string $username , string $password [, array $options ]) 

例への新しい接続を作成するには、インストールディレクトリ

chmod 777 /<installation dir> 

の権限を設定することを忘れないでくださいください。

<?php 
$conn = db2_connect($database, $user, $password); 

// Create the test table 
$create = 'CREATE TABLE animals (id INTEGER, breed VARCHAR(32), 
    name CHAR(16), weight DECIMAL(7,2))'; 
$result = db2_exec($conn, $create); 
if ($result) { 
    print "Successfully created the table.\n"; 
} 

// Populate the test table 
$animals = array(
    array(0, 'cat', 'Pook', 3.2), 
    array(1, 'dog', 'Peaches', 12.3), 
    array(2, 'horse', 'Smarty', 350.0), 
    array(3, 'gold fish', 'Bubbles', 0.1), 
    array(4, 'budgerigar', 'Gizmo', 0.2), 
    array(5, 'goat', 'Rickety Ride', 9.7), 
    array(6, 'llama', 'Sweater', 150) 
); 

foreach ($animals as $animal) { 
    $rc = db2_exec($conn, "INSERT INTO animals (id, breed, name, weight) 
     VALUES ({$animal[0]}, '{$animal[1]}', '{$animal[2]}', {$animal[3]})"); 
    if ($rc) { 
     print "Insert... "; 
    } 
} 
?> 

このスクリプトは出力します

Successfully created the table. 
Insert... Insert... Insert... Insert... Insert... Insert... Insert... 

documentation

+0

こんにちはトニーを参照してください迅速な返信いただきありがとうございますが、私は、スクリプトを持っており、XAMPP(Windowsプラットフォーム)を介して正常に動作します。今私はCentOS 6.2で同じものを実装する必要があり、追加の設定がCentOSで行う必要があるかどうかを知りたいと思います –