By: servo
Date: 2003-11-06
Time: 08:24
|
Connect with John Lim's ADOdb
Hi skrol29,
I'm quite new to tbs but find it very interesting.
Could you give me a complete example on how to call data from db using John Lim's ADOdb function.
I have tried, but come to no success…
Here is my code:
PHP
<?
include_once("tbs_class.php");
include_once("../adodb/adodb.inc.php");
include_once("cnx_ADOdb.php"); // file that contain John Lim's ADOdb function
$conn = NewADOConnection('access');
$conn->Connect('db_name');
$tbs = new clsTinyButStrong;
$tbs->LoadTemplate("list_employee.htm");
$query = "Select * from Employees, Department where Employees.DepartmentNo=Department.DepartmentNo";
$rs = tbsdb_adodb_open($conn,$query);
$tbs->MergeBlock("blk1","adodb",$rs);
$tbs->Show();
?>
|
HTML
<table border="1" cellpadding="2" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%" id="AutoNumber1">
<tr>
<td width="25%" bgcolor="#DDDDDD"><b><font size="1" face="Verdana">Employee No.</font></b></td>
<td width="25%" bgcolor="#DDDDDD"><b><font size="1" face="Verdana">Employee Name</font></b></td>
<td width="25%" bgcolor="#DDDDDD"><b><font size="1" face="Verdana">Designation</font></b></td>
<td width="25%" bgcolor="#DDDDDD"><b><font size="1" face="Verdana">Department</font></b></td>
</tr>
<tr>
<td width="25%"><font size="1" face="Verdana">[blk1.EmployeeNO;block=row]</font></td>
<td width="25%"><font size="1" face="Verdana">[blk1.FirstName]</font></td>
<td width="25%"><font size="1" face="Verdana">[blk1.Positions]</font></td>
<td width="25%"><font size="1" face="Verdana">[blk1.DepartmentDescription]</font></td>
</tr>
<tr>
<td width="25%" bgcolor="#CCCCFF"><font size="1" face="Verdana">[blk1.EmployeeNO;block=row]</font></td>
<td width="25%" bgcolor="#CCCCFF"><font size="1" face="Verdana">[blk1.FirstName]</font></td>
<td width="25%" bgcolor="#CCCCFF"><font size="1" face="Verdana">[blk1.Positions]</font></td>
<td width="25%" bgcolor="#CCCCFF"><font size="1" face="Verdana">[blk1.DepartmentDescription]</font></td>
</tr>
</table>
|
Thx.
|
By: Skrol29
Date: 2003-11-06
Time: 10:20
|
Re: Connect with John Lim's ADOdb
Hi servo,
The code should be more like this :
<?
include_once("tbs_class.php");
include_once("../adodb/adodb.inc.php");
include_once("cnx_ADOdb.php"); // file that contain John Lim's ADOdb function
$conn = NewADOConnection('access');
$conn->Connect('db_name');
$tbs = new clsTinyButStrong;
$tbs->LoadTemplate("list_employee.htm");
$query = "Select * from Employees, Department where Employees.DepartmentNo=Department.DepartmentNo";
$tbs->MergeBlock("blk1",$conn,$query);
$tbs->Show();
?>
|
The tbsdb_adodb_open() function is called by TBS itself.
By the way :
I've been told by a user that TBS can not recognize the ADOdb object with some configurations.
If it happens to you, could you simply give me the value returned by PHP for the expression :
get_resource_type($conn)
|
By: Skrol29
Date: 2003-11-06
Time: 23:30
|
Re: Connect with John Lim's ADOdb
My first aswer is not quite correct.
You HTML part is ok.
But here is what you should use for the PHP code
(of course you should also add the cusom functions descibed in the Support page)
<?
include_once("tbs_class.php");
include_once("../adodb/adodb.inc.php");
include_once("cnx_ADOdb.php"); // file that contain John Lim's ADOdb function
$conn = NewADOConnection('access');
$conn->Connect('db_name');
$tbs = new clsTinyButStrong;
$tbs->LoadTemplate("list_employee.htm");
$query = "Select * from Employees, Department where Employees.DepartmentNo=Department.DepartmentNo";
$tbs->MergeBlock("blk1","adodb",$query);
$tbs->Show();
?>
|
|
By: servo
Date: 2003-11-07
Time: 05:12
|
Re: Connect with John Lim's ADOdb
I have tried your code.
But the weird things is the result page only show the [block.code].
While the amount of table column generated is the same compare to data inside the db.
What's wrong anyway ?
|
By: Skrol29
Date: 2003-11-09
Time: 02:10
|
Re: Connect with John Lim's ADOdb
Can you send me the Html result you have, so I can better understand.
|
By: servo
Date: 2003-11-13
Time: 04:50
|
Re: Connect with John Lim's ADOdb
I have figured out myself, I should add one more line after the
$conn->Connect('db_name');
The code should be this way :
$conn = NewADOConnection('access');
$conn->Connect('db_name');
$conn->SetFetchMode(ADODB_FETCH_ASSOC);
|
Then, everything is ok.
Thx anyway Skrol29.
|
By: Skrol29
Date: 2003-11-13
Time: 08:35
|
Re: Connect with John Lim's ADOdb
Thanks servo,
I've change the custom functions at the support page..
|
By: thuc
Date: 2005-11-12
Time: 05:00
|
Re: Connect with John Lim's ADOdb
Hello Mr Skroll29. would you tell me contain of "adodb.inc.php"?
thank you.
|
By: Skrol29
Date: 2005-11-13
Time: 23:15
|
Re: Connect with John Lim's ADOdb
Hello,
In the example above, "adodb.inc.php" is, in fact, the main file provided by the ADOdb library. And "cnx_ADOdb.php" is a custom the file wich makes the connexion.
|
|
Posting in progress.
Please wait...
|