Forums / General / How to get instance of Database

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 .

eZ debug

Timing: Jan 18 2025 18:35:24
Script start
Timing: Jan 18 2025 18:35:24
Module start 'content'
Timing: Jan 18 2025 18:35:25
Module end 'content'
Timing: Jan 18 2025 18:35:25
Script end

Main resources:

Total runtime1.0869 sec
Peak memory usage4,096.0000 KB
Database Queries199

Timing points:

CheckpointStart (sec)Duration (sec)Memory at start (KB)Memory used (KB)
Script start 0.00000.0073 587.7031180.8438
Module start 'content' 0.00730.9463 768.5469602.3516
Module end 'content' 0.95360.1331 1,370.8984337.3828
Script end 1.0868  1,708.2813 

Time accumulators:

 Accumulator Duration (sec) Duration (%) Count Average (sec)
Ini load
Load cache0.00390.3628210.0002
Check MTime0.00150.1339210.0001
Mysql Total
Database connection0.00140.129510.0014
Mysqli_queries1.010392.95301990.0051
Looping result0.00210.19151970.0000
Template Total1.048796.520.5244
Template load0.00200.187120.0010
Template processing1.046796.302420.5233
Template load and register function0.00020.019510.0002
states
state_id_array0.00270.245810.0027
state_identifier_array0.00190.173920.0009
Override
Cache load0.00170.1583340.0001
Sytem overhead
Fetch class attribute can translate value0.00130.115240.0003
Fetch class attribute name0.00110.104460.0002
XML
Image XML parsing0.00140.132240.0004
class_abstraction
Instantiating content class attribute0.00000.001060.0000
General
dbfile0.00460.4262350.0001
String conversion0.00000.000630.0000
Note: percentages do not add up to 100% because some accumulators overlap

CSS/JS files loaded with "ezjscPacker" during request:

CacheTypePacklevelSourceFiles
CSS0extension/community/design/community/stylesheets/ext/jquery.autocomplete.css
extension/community_design/design/suncana/stylesheets/scrollbars.css
extension/community_design/design/suncana/stylesheets/tabs.css
extension/community_design/design/suncana/stylesheets/roadmap.css
extension/community_design/design/suncana/stylesheets/content.css
extension/community_design/design/suncana/stylesheets/star-rating.css
extension/community_design/design/suncana/stylesheets/syntax_and_custom_tags.css
extension/community_design/design/suncana/stylesheets/buttons.css
extension/community_design/design/suncana/stylesheets/tweetbox.css
extension/community_design/design/suncana/stylesheets/jquery.fancybox-1.3.4.css
extension/bcsmoothgallery/design/standard/stylesheets/magnific-popup.css
extension/sevenx/design/simple/stylesheets/star_rating.css
extension/sevenx/design/simple/stylesheets/libs/fontawesome/css/all.min.css
extension/sevenx/design/simple/stylesheets/main.v02.css
extension/sevenx/design/simple/stylesheets/main.v02.res.css
JS0extension/ezjscore/design/standard/lib/yui/3.17.2/build/yui/yui-min.js
extension/ezjscore/design/standard/javascript/jquery-3.7.0.min.js
extension/community_design/design/suncana/javascript/jquery.ui.core.min.js
extension/community_design/design/suncana/javascript/jquery.ui.widget.min.js
extension/community_design/design/suncana/javascript/jquery.easing.1.3.js
extension/community_design/design/suncana/javascript/jquery.ui.tabs.js
extension/community_design/design/suncana/javascript/jquery.hoverIntent.min.js
extension/community_design/design/suncana/javascript/jquery.popmenu.js
extension/community_design/design/suncana/javascript/jScrollPane.js
extension/community_design/design/suncana/javascript/jquery.mousewheel.js
extension/community_design/design/suncana/javascript/jquery.cycle.all.js
extension/sevenx/design/simple/javascript/jquery.scrollTo.js
extension/community_design/design/suncana/javascript/jquery.cookie.js
extension/community_design/design/suncana/javascript/ezstarrating_jquery.js
extension/community_design/design/suncana/javascript/jquery.initboxes.js
extension/community_design/design/suncana/javascript/app.js
extension/community_design/design/suncana/javascript/twitterwidget.js
extension/community_design/design/suncana/javascript/community.js
extension/community_design/design/suncana/javascript/roadmap.js
extension/community_design/design/suncana/javascript/ez.js
extension/community_design/design/suncana/javascript/ezshareevents.js
extension/sevenx/design/simple/javascript/main.js

Templates used to render the page:

UsageRequested templateTemplateTemplate loadedEditOverride
1node/view/full.tplfull/forum_topic.tplextension/sevenx/design/simple/override/templates/full/forum_topic.tplEdit templateOverride template
4content/datatype/view/ezxmltext.tpl<No override>extension/community_design/design/suncana/templates/content/datatype/view/ezxmltext.tplEdit templateOverride template
5content/datatype/view/ezxmltags/line.tpl<No override>design/standard/templates/content/datatype/view/ezxmltags/line.tplEdit templateOverride template
7content/datatype/view/ezxmltags/paragraph.tpl<No override>extension/ezwebin/design/ezwebin/templates/content/datatype/view/ezxmltags/paragraph.tplEdit templateOverride template
2content/datatype/view/ezimage.tpl<No override>extension/sevenx/design/simple/templates/content/datatype/view/ezimage.tplEdit templateOverride template
2content/datatype/view/ezxmltags/literal.tpl<No override>extension/community/design/standard/templates/content/datatype/view/ezxmltags/literal.tplEdit templateOverride template
1pagelayout.tpl<No override>extension/sevenx/design/simple/templates/pagelayout.tplEdit templateOverride template
 Number of times templates used: 22
 Number of unique templates used: 7

Time used to render debug report: 0.0001 secs