PHP connection via ODBC to the intersystems CACHE database

Asked

Viewed 40 times

0

Good morning, everyone. Does anyone have experience of making a connection via odbc with the intersystems caché database in PHP? I have already installed the ODBC driver on my host and connected it right with the database, however I am having difficulty starting the connection.php.

Thanks in advance!

1 answer

0


I was able to connect, make a query and print the data as below.

<!DOCTYPE html>
        <html lang='pt-BR'>
        <head>
            <link href='https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css' rel='stylesheet' integrity='sha384-eOJMYsd53ii+scO/bJGFsiCZc+5NDVN2yr8+0RDqr0Ql0h+rP48ckxlpbzKgwra6' crossorigin='anonymous'>
        </head>
        <body>
<title>Teste</title>
 <head>
 <body>
 <?php
    $usu='DB_USER';
    $senha='DB_PASSWORD';
    $connect = odbc_connect('DSN_NAME',$usu,$senha);
    $sql = "SELECT * FROM banco";
    $result = odbc_exec($connect , $sql);
      ?>
<div class='container container-sm'><br>
<table class='table table-hover table-sm'>
 <tr>
    <th>ID</th>
    <th></th>
    <th>Conta</th>
    <th></th>
    <th>nome</th>
 </tr>

 <?php
  while (odbc_fetch_row($result)) {

    echo 
        '<tr>
            <td>'.odbc_result($result, 1).'<td/> 
            <td>'.odbc_result($result, 2).'<td/> 
            <td>'.odbc_result($result, 3).'<td/>
        </tr>';
  }
 odbc_close($connect);
 ?>
 </table>
</div>
</body>
</html>

´´´

Browser other questions tagged

You are not signed in. Login or sign up in order to post.