I have created an extension and i would like to import and remove data on my ImportAction. Although the Import snippet works, the remove does not.
Note that this did not work for me.
Here is what i have so far:
I am using TYPO3 7.6.23
Here is my code that does not work:
$objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager');
$myRepository = $objectManager->get('BW....\MyImporter\Domain\Repository\MyRepository');
$myRepository->removeAll();
Here is the code that imports data successfully (Here i am using USE on the top of my PHP file that is the reason why there is this myImport::class).
$finalTitle = 'This is a Test';
$objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager');
$newMyImport = $objectManager->get(myImport::class);
$newMyImport->setTitle($finalTitle);
$this->myRepository->add($newMyImport);
print_r($newMyImport);
How can i remove all the elements from my database ALONG WITH the IDs? It will not be nice if the ID reaches the 254206782.
Thanks in advance,
A little bit late but i figured a way to do it and it works perfectly.
I had to truncate my table!
This is the code on my Task.php (because i had it on my scheduler).
/*Create connection to Truncate the database*/
$servername = TYPO3_db_host;
$username = TYPO3_db_username;
$password = TYPO3_db_password;
$dbname = TYPO3_db;
// Create connection
$databaseConnect = mysqli_connect($servername, $username, $password, $dbname);
$repositoryRemove = "TRUNCATE TABLE tx_importer_domain_model_import";
$repositoryAttachmentsRemove = "TRUNCATE TABLE tx_importer_domain_model_attachments";
$mysql = mysqli_query($databaseConnect, $repositoryRemove);
$mysql1 = mysqli_query($databaseConnect, $repositoryAttachmentsRemove);
mysqli_close($databaseConnect);
And simply as that, the deletion of my Tables was a success!
Best regards,