Description of SQL in EC-CUBE

Asked 2 years ago, Updated 2 years ago, 95 views

In EC-CUBE 3.0.10, we have customized the order number and set it randomly, so we need to check the duplicate order number that already exists.
First, I created the following SQL and created it in QueryBuilder.

·Created SQL

SELECT COUNT(o.order_number) 
FROM dtb_ordero 
WHEREo.order_number = Combined Order Number

·Create with QueryBuilder

$qb=$em->getRepository('Eccube\Entity\Order')
    ->createQueryBuilder('o')
    ->select('COUNT(o.order_number)')
    ->where('o.order_number=:orderId')
    ->setParameter('orderId','$orderId');
$countOrderId = $qb
    ->getQuery()
    ->getSingleResult();

At this time, an error occurred due to insufficient memory, so we decided to change it to the following SQL.

·Recreated SQL

SELECT1
FROM dtb_ordero 
WHEREo.order_number = Combined Order Number
LIMIT1

In this case, how to describe it in QueryBuilder
Please let me know if anyone knows.
It doesn't matter if it's a hint.

Thank you for your cooperation.

Hereafter, add
·Error contents

Apache error logs are as follows:
Do you feel like you don't have enough memory?
[Thu Jun 30 13:51:01.710082 2016] [:error] [pid9568:tid1856] [client::1:61415] PHP Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 552 bytes) in C:\xampp\htdocs\eccube-3.0.10\vendorOS\diverLibline\Dobline\Dobline\Dobline\Dobline\Dobline\Dobline\Dobacalhost/eccube-3.0.10/html/index_dev.php/cart

php ec-cube

2022-09-30 21:17

1 Answers

Out of memory error.
EC-CUBE3 is impossible with memory_limit 256MB, so I think it would be better to increase it with php.ini or ini_set().

Also, if the purpose is to check duplication,

$Order=$em->getRepository('Eccube\Entity\Order')
->findOneBy(array('order_number'=>$orderId));

So, I think it's okay to check if $Order is null.


2022-09-30 21:17

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.