0

i'm working on my first TYPO3-Project (TYPO3 6.1). I developed a CSV-import which works well, but now i want to backup the table before the import new Data. Thus, i want to copy the Table with the Data.

My question, how can i do this in the right way? I mentioned to write a Method in the Repository-Class (Which Extends the extbase/perstistance/repository).

Is this good? How can access a DB-Object there to call a custom SQL-Query?

Thanks for your help!

biesior
  • 55,576
  • 10
  • 125
  • 182
Hayo
  • 240
  • 1
  • 2
  • 12

1 Answers1

1

You can use a raw query like

$query = $this->createQuery();
$query->getQuerySettings()->setReturnRawQueryResult(TRUE);
$query->statement(
    'SELECT order_id,product_name,qty
    FROM orders
    INTO OUTFILE '/tmp/orders.csv'
    FIELDS TERMINATED BY ','
    ENCLOSED BY '"'
    LINES TERMINATED BY '\n''
);
return $query->execute();
freshp
  • 525
  • 5
  • 20
  • The raw Query is fine, it didn't work because i didn't set the setReturnRawQueryResult(TRUE); But after that it worked great! Thanks – Hayo Jul 26 '13 at 07:10