0

I am using X-Cart for my project, I need help in how to perform delete query in X-cart. Currently, I am using the below code but it showing me an error.

Can anyone help me in this??

$products = \XLite\Core\Database::getRepo('\XLite\Module\XCExample\FormDemo\Model\NewScroll')->createQueryBuilder('p');
        $products->delete('xc_news_scroll p');
        $products->getResult();

1 Answers1

0

If you want to remove some object, then you should go:

\XLite\Core\Database::getRepo('\XLite\Module\XCExample\FormDemo\Model\NewScroll')->delete($newScrollObjectToRemove);

If you want to remove some column from the database schema, you need to edit the model class of the entities stored in the table and remove this property there. After that, you will need to re-deploy the store.

Best,

Tony

Tony
  • 149
  • 5
  • I need to remove records, not columns from the database table. does it make sense? – Alfaraz Shaikh Mar 09 '20 at 07:41
  • Then ```\XLite\Core\Database::getRepo('\XLite\Module\XCExample\FormDemo\Model\NewScroll')->delete($scrollObjectToRemove)``` should work out for you. – Tony Mar 10 '20 at 08:03
  • `$products = \XLite\Core\Database::getRepo('\XLite\Module\XCExample\FormDemo\Model\NewScroll')->findAll(); $entityss->delete($products);` I am using like this but not working – Alfaraz Shaikh Mar 12 '20 at 04:09
  • You should pass a single object to delete() or remove() method, not an array. – Tony Mar 12 '20 at 08:19