[TYPO3-mvc] Accessing external database table
Markus Mahner
lists at mahner.net
Fri Nov 26 14:44:32 CET 2010
Hi,
for a frontend plugin I'm building with Extbase, I try to read-only access a database table located outside the TYPO3 database (though it's located on the same server).
Basically, it seems to work, as when I fetch all records on that table using findAll() and iterate through the result using <f:for>, I get the correct number of records (413); unfortunately, it's 413x the first record :(.
What am I missing?
Here's what I did:
==================================================================================
* ext_tables.php:
t3lib_extMgm::allowTableOnStandardPages('tx_evtman_domain_model_event');
$TCA['tx_evtman_domain_model_event'] = array();
t3lib_extMgm::addStaticFile($_EXTKEY, 'Configuration/TypoScript', 'Event Manager');
* Configuration/TypoScript/setup.txt:
plugin.tx_itagevtman {
persistence {
classes {
Tx_ItagEvtman_Domain_Model_Event {
mapping {
tableName = fw_evtman.event
columns {
date.mapOnProperty = date
name.mapOnProperty = name
}
}
}
}
}
}
* Classes/Domain/Model/Event.php:
class Tx_Evtman_Domain_Model_Event extends Tx_Extbase_DomainObject_AbstractEntity {
protected $date;
protected $name;
/**
* @return string The date of the event
*/
public function getDate() {
return $this->date;
}
/**
* @return string The name of the event
*/
public function getName() {
return $this->name;
}
}
* Classes/Controller/EventController.php:
class Tx_Evtman_Controller_EventController extends Tx_Extbase_MVC_Controller_ActionController {
protected $eventRepository;
public function indexAction() {
$this->eventRepository = t3lib_div::makeInstance('Tx_Evtman_Domain_Repository_EventRepository');
$events = $this->eventRepository->findAll();
$this->view->assign('events', $events);
}
}
* index.html:
<ol>
<f:for each="{events}" as="event">
<li>{event.date} - {event.name}</li>
</f:for>
</ol>
==================================================================================
thanks in advance,
µ.
More information about the TYPO3-project-typo3v4mvc
mailing list