Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Archive /

Our old forums are still available as a read-only archive.

Moderators: martimiz, Sean, biapar, Willr, Ingo, simon_w

How to show a database table


Reply


4 Posts   1818 Views

Avatar
TuTToWeB

Community Member, 10 Posts

27 March 2008 at 11:50am

Hello to everyone.
I created those class

class ProductorManager extends Page
{
static $db = array('Percentage'=>'float'
);
static $has_one = array('id_productor'=>'Member'
);

public function Productors()
{
return DataObject::get("ProductorManager ");
}
}

class ProductorManager _Controller extends Page_Controller
{
}

and i've the table setted up, but i cannot retrieve datas from them. i thinks function Productors() is correct, but something don't work.
I want to show Percentage and the complete productor's name fetched by Member's tables

I dont know if i want clear about the explaination.
Thanks to everyone.

VG

Avatar
noizy

Community Member, 25 Posts

27 March 2008 at 1:26pm

you probably want to put that function in the Page_Controller, for starters.

what does your template code look like?

Avatar
TuTToWeB

Community Member, 10 Posts

27 March 2008 at 10:45pm

Template page look like in this way temporarily

<div class="body">
<h1>$Title</h1>
<% include SideBar %>
<div style="clear:left">

<% if Productor %>
<% control Productor %>
$FirstName .<br />
<% end_control %>
<% else %>
<div class="message">No productors found</div>
<% end_if %>
</div>
</div>

First I put Productors() inside the Controller Class, but didn't work.
I want to show each productor's name and i don't know where i've made a mistake.

thank you very much

Avatar
TuTToWeB

Community Member, 10 Posts

28 March 2008 at 3:24am

Edited: 28/03/2008 4:07am

I solved that problem using a DataObject-derivated class.

class Produttori extends DataObject
{
static $db = array('Percentuale'=>'float');
static $has_one = array('Produttore'=>'Member');
}

Thanks you