Categories > TinyButStrong general >

ADODB Connection

The forum is closed. Please use Stack Overflow for submitting new questions. Use tags: tinybutstrong , opentbs
By: Rodrigo
Date: 2003-04-07
Time: 02:32

ADODB Connection

Hi, I'm trying TBS with an ADODB conection to a PostgreSQL database.

The problem is when I try to merge a block with a result set, i get this message:

TinyButStrong Error (Open resource): Unsupported resource for object class: 'adorecordset_postgres7'.

Here's the code:

contact.list.php
<?php
include_once("app.inc.php");
$cn = NewADOConnection('postgres7');
$cn->Connect("localhost", "Rodrigo", "", "ngs");
$rs = $cn->Execute("select * from rep_contact_list");
$tbs = new clsTinyButStrong;
$tbs->LoadTemplate("contact.list.html");
$tbs->MergeField("FIELD_CNAME","Nombre");
$tbs->MergeField("FIELD_CTYPE","Tipo");
$tbs->MergeField("FIELD_DEPT","Departamento");
$tbs->MergeField("FIELD_WEMAIL","E-Mail (Trabajo)");
$tbs->MergeBlock("contact", $rs);
$tbs->Show();
?>

contact.list.html
...
<table width="100%" border="0" cellpadding="0" cellspacing="0" class="List">
  <tr>
    <th>[FIELD_CNAME]</th>
    <th>[FIELD_CTYPE]</th>
    <th>[FIELD_DEPT]</th>
    <th>[FIELD_WEMAIL]</th>
  </tr>
  <tr class="ListOdd">
    <td>[contact.con_cname;block=row]</td>
    <td>[contact.con_cname]</td>
    <td>[contact.dept_name]</td>
    <td>[contact.con_wemail]</td>
  </tr>
  <tr class="ListEven">
    <td>[contact.con_cname;block=row]</td>
    <td>[contact.con_cname]</td>
    <td>[contact.dept_name]</td>
    <td>[contact.con_wemail]</td>
  </tr>
  <tr>
    <td colspan="4" class="ListNotFound">No se encontraron registros.[contact;block=row;nodata]</td>
...

app.inc.php
<?php
include_once("tbs_class.php");
include_once("adodb/adodb.inc.php");
include_once('adodb/tohtml.inc.php');
$ADODB_CACHE_DIR = 'C:/web/tmp';
?>

Any pointers?
By: Skrol29
Date: 2003-04-07
Time: 10:14

Re: ADODB Connection

Hi Rodrigo,

The ADO library you are using is not the proper ADODB connection described in the PHP documentation but a specific external library named ADOdb edited by php.weblogs.com. It's name is a bit confusing.

I've had a look in this library and it seems you can refer to a the proper ADODB object related to teire objects:
Try
$cn->_connectionID
to refer to the proper ADODB connection ressource id.
$rs->_queryID
to refer to the proper ADODB recordset ressource id.

I didn' test this. If it doesn't work, please tell me and I gonna ask to the php.weblogs.com web site.
I'm intersed about database connection methods used on the net so I care about the answer.
By: Skrol29
Date: 2003-04-07
Time: 17:32

Re: ADODB Connection -> the issue

Hi again Rodrigo,

It seems that ADOdb from WebLogs uses the PostreSQL PHP library.
TinyButStrong doesn't supports PostgeSQL neither ADOdb from WebLogs in native yet.

Nevertheless, you can use TBS with any database by using PHP array.
Simply write a function that returns the result of a SQL statement in a PHP array and use this array for merging.
Here is the code for ADOdb from WebLogs:

function m_Sql_Result($cn,$sql) {
  $result = array() ;
  $rs = $cn->Execute($sql) ;
  while (!$rs->EOF) {
    $result[] = $rs->fields ;
    $rs->MoveNext();
  } ;
  $rs->Close();
  return $result ;
}

Then you can code :
$result = m_Sql_Result($cn,"select * from rep_contact_list") ;
$tbs->MergeBlock("contact", $result);
By: Rodrigo
Date: 2003-04-08
Time: 01:08

Re: ADODB Connection -> the issue

Thanks, I tried it and it worked. I'll let you know how it all ends :)