How to get instance of Database

Author Message

bipul kuri

Wednesday 20 October 2004 2:06:20 am

I have created a database in Mysql say test
and have created a table Employee with fields Name,Id,Dept.
Now I want to generate a table in the template file to show the user.
All I could make out from the forums and Documentations is to do this
$db =& eZDB::instance();
$rows =& $db->arrayQuery( "SELECT * FROM employee" );
foreach ( $rows as $row )
{
print( $row["name"] );
}
}

but how do i know eZDB is connecting to my "test" database
is this the correct way of getting the instance of database

Björn Dieding@xrow.de

Wednesday 20 October 2004 2:17:01 am

I think you are missing here some basic concepts of eZ. Sorry to say that.

I would handle this like this:

-Create a new persistent object Employee
-Create a new module function that is fetchable (operator fetch) within your template...

hmmm maybe I can give you the advice to buy the book. In the book should be all the code examples you need.

Looking for a new job? http://www.xrow.com/xrow-GmbH/Jobs
Looking for hosting? http://hostingezpublish.com
-----------------------------------------------------------------------------
GMT +01:00 Hannover, Germany
Web: http://www.xrow.com/

Łukasz Serwatka

Wednesday 20 October 2004 8:19:27 am

- in administration panel u can also create class called Employee with Name, Id, Dept attributes
- create folder where u will store your objects
- fatch data with fetch function

{section loop=fetch(content, list, hash(parent_node_id, $node.node_id))}
{$:item.name} | {$:item.id} | {$:item.dept}
{/section}

You can construc table in html with 1 object per row

<table width="100%"  border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td> Name </td>
    <td> Id</td>
    <td> Dept </td>
  </tr>
  {section loop=fetch(content, list, hash(parent_node_id, $node.node_id))}
  <tr>
    <td>{$:item.name}</td>
    <td>{$:item.id}</td>
    <td>{$:item.dept}</td>
  </tr>
  {/section}
</table>

Personal website -> http://serwatka.net
Blog (about eZ Publish) -> http://serwatka.net/blog

bipul kuri

Wednesday 20 October 2004 10:12:56 pm

Thnak you all for the advice ,
Is there any way to show an excel sheet embedded in the page or template not the file link because I have a Excel sheet which is updated by third party .

Powered by eZ Publish™ CMS Open Source Web Content Management. Copyright © 1999-2014 eZ Systems AS (except where otherwise noted). All rights reserved.

eZ debug

Timing: Jan 31 2025 06:05:44
Script start
Timing: Jan 31 2025 06:05:44
Module start 'layout'
Timing: Jan 31 2025 06:05:44
Module start 'content'
Timing: Jan 31 2025 06:05:44
Module end 'content'
Timing: Jan 31 2025 06:05:44
Script end

Main resources:

Total runtime0.0182 sec
Peak memory usage2,048.0000 KB
Database Queries3

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0064 588.1250151.2109
Module start 'layout' 0.00640.0034 739.335936.6484
Module start 'content' 0.00980.0068 775.984494.2344
Module end 'content' 0.01660.0015 870.218833.9922
Script end 0.0181  904.2109 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.002614.3990140.0002
Check MTime0.00116.2140140.0001
Mysql Total
Database connection0.00105.497010.0010
Mysqli_queries0.003117.062230.0010
Looping result0.00000.143110.0000
Template Total0.00116.110.0011
Template load0.00094.835110.0009
Template processing0.00021.217310.0002
Override
Cache load0.00063.217310.0006
General
dbfile0.00179.133280.0002
String conversion0.00000.055240.0000
Note: percentages do not add up to 100% because some accumulators overlap

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1print_pagelayout.tpl<No override>extension/community/design/community/templates/print_pagelayout.tplEdit templateOverride template
 Number of times templates used: 1
 Number of unique templates used: 1

Time used to render debug report: 0.0001 secs