First of all, i create a Extension with the "Extension Builder". I would like to extend the "tt_address" Extension.
What steps i do?
I create a Entity
Adress
and map this to existing tablett_address
. In my EntityAddress
i create setter and getter for retrieving Addressinformations like 'city, zip and street'.After this step i create a Repository
AddressRepository
which extends\TYPO3\CMS\Extbase\Persistence\Repository
.The extensionbuilder create a typoscript File
ext_typoscript_setup.txt
with this content:config.tx_extbase{ persistence{ classes{
Mab\Oaaddress\Domain\Model\Address { mapping { tableName = tt_address recordType = Tx_Oaaddress_Address } } } }}
I set the
storagePid
in myconstants.txt
In the last step i would like to retrieve all Addresses from Database and show this in a list view.
class AddressController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionController {
/**
* Events repository
*
* @var \Mab\Oaaddress\Domain\Repository\AddressRepository
* @inject
*/
protected $addressRepository;
/**
* action list
*
* @return void
*/
public function listAction() {
// Exists adress repository?
//var_dump($this->addressRepository);
$addresses = $this->addressRepository->findAll();
//var_dump(count($addresses));
$this->view->assign('addresses', $addresses);
}
The table tt_address
contains more than ten results. But the controller show $addresses
count always 0
. I clear every Cache (empty Typo3Temp folder, empty Cache through Install Tool, emptyh Backend Cache) but nothing have a effect. Why my Controller return nothing? Can someone give me a tip?
Update
After i analyse the query log, i find that this query is executed:
SELECT tt_address.* FROM tt_address WHERE 1=1 AND (tt_address.tx_extbase_type='Tx_Oaaddress_Address') AND tt_address.pid IN (148) AND tt_address.deleted=0 AND tt_address.hidden=0
How can i remove this part
tt_address.tx_extbase_type='Tx_Oaaddress_Address' from the where part of the query?
general.log
. In your Terminal, find out where the logfile is (e.g. /var/log/mysql5/general.log) and then dotail -n 3000 /var/log/mysql5/general.log | grep tt_address
This could help you to find the sql query that was called and you may see what is going wrong. - Jay Dinse