2017-12-11 20 views
1

は私が前にInformixデータベースに接続するためにPDOを使用したことがなかった、私は基本的なクエリ実行中にこのエラーがアップpoped:Informix ODBCドライバ...無効な接続文字列属性ですか?

SQLSTATE=01S00, SQLDriverConnect: -11005 [Informix][Informix ODBC Driver]Invalid connection string attribute. 

をそして、これは私のコードです:私はしました

<?php 

class prueba{ 
private static $cn = null; 

public static function conectar(){ 
    if(self::$cn !== null) { 
     return self::$cn; 
    } 
    try{ 
     self::$cn= new PDO("informix:host=localhost; service=30000; 
    database=mrroot; server=mrserver; protocol=onsoctcp; 
    EnableScrollableCursors=1", "mrtony", ""); 
     return self::$cn; 

    } catch (PDOException $ex){ 
     die($ex->getMessage()); 
    } 
    } 


public static function consulta(){ 

    $query = "SELECT * FROM fr_envio"; 

    $cn = prueba::conectar(); 

    $resultado = $cn->prepare($query); 

    $resultado->execute(); 

     echo '<table>'; 
     while ($row = $resultado->fetch(PDO::FETCH_ASSOC)) 
      { 
       echo '<tr>'; 
       echo '<td>'.$row['enviopre'].'</td>'; 
       echo '<td>'.$row['enviofra'].'</td>'; 
       echo '<td>'.$row ['enviopec'].'</td>'; 
       echo '<td>'.$row ['envioval'].'</td>'; 
       echo '</tr>'; 
      } 

     echo '</table>'; 

} 

} 


$prueba = new prueba(); 

$prueba->consulta(); 
?> 

Mysqlで同じコードをテストしただけで、接続文字列を変更するだけで、すべてが完璧に動作します。接続文字列に何かがないように思えます。

私は何ですが、このチュートリアルで言う続く:

https://www.ibm.com/support/knowledgecenter/en/SSGU8G_12.1.0/com.ibm.virtapp.doc/TD_item2.htm

答えて

3

うーん...ちょうど1行に接続文字列をspecifingしてみてください。このよう

[email protected]:/usr3/products/php53# cat test.php 
<?php 

$db = new PDO("informix:host=irk;service=3046;database=stores7; 
server=irk1210;protocol=onsoctcp;EnableScrollableCursors=1;", "informix", "ximrofni"); 

print "Connection Established!\n\n"; 

$stmt = $db->query("select * from systables"); 
$res = $stmt->fetch(PDO::FETCH_BOTH); 
$rows = $res[0]; 
echo "Table contents: $rows.\n"; 


?> 
[email protected]:/usr3/products/php53# php test.php 
PHP Fatal error: Uncaught exception 'PDOException' with message 'SQLSTATE=01S00, SQLDriverConnect: -11005 [Informix][Informix ODBC Driver]Invalid connection string attribute.' in /usr3/products/php5/test.php:4 
Stack trace: 
#0 /usr3/products/php5/test.php(4): PDO->__construct('informix:host=i...', 'informix', 'ximrofni') 
#1 {main} 
    thrown in /usr3/products/php5/test.php on line 4 
[email protected]:/usr3/products/php53# 

:私はfvcking遅だ

[email protected]:/usr3/products/php53# cat test.php 
<?php 

$db = new PDO("informix:host=irk;service=3046;database=stores7; server=irk1210;protocol=onsoctcp;EnableScrollableCursors=1;", "informix", "ximrofni"); 

print "Connection Established!\n\n"; 

$stmt = $db->query("select * from systables"); 
$res = $stmt->fetch(PDO::FETCH_BOTH); 
$rows = $res[0]; 
echo "Table contents: $rows.\n"; 


?> 
[email protected]:/usr3/products/php53# php test.php 
Connection Established! 

Table contents: systables. 
[email protected]:/usr3/products/php53# 
+0

...笑おかげで、途中で、友人は私がubutuにドライバをインストールして設定助けたが、彼は語っていませんでしたそれを行う方法....これを行うためのチュートリアルは知っていますか?私はそれらのいくつかでそれをやろうとしたので、それは私のためにうまくいきませんでした –

+0

CSDKパッケージをインストールし、env変数(PATH/INFORMIXDIR)を設定する以外はあまりありませんそれに。 は、それが(ODBCを含む)異なるInformixのAPIを使用する方法のサンプルの多くといくつかの基本的なトラブルシューティングを持って https://www.redbooks.ibm.com/redbooks/pdfs/sg247884.pdf を見てください。 –

+0

ありがとうございました.... –

関連する問題