Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls
 

Custom select Query issue

 
Reply
   X-Cart forums > X-Cart 5 > Dev Questions (X-Cart 5)
 
Thread Tools Search this Thread
  #1  
Old 02-15-2017, 04:01 AM
 
Sooraj Sooraj is offline
 

Newbie
  
Join Date: Mar 2016
Posts: 9
 

Default Custom select Query issue

Hi,

I was trying to integrate a third party library related to order.
I need to fetch previous order placed customer prior to current order.

MySQL query is
Code:
SELECT order_id FROM `xc_orders` WHERE orig_profile_id=7 AND is_order=1 AND order_id!=11 ORDER BY order_id DESC LIMIT 1

This is my code.

Code:
$condition = array('orig_profile' => 7, 'is_order'=>1, 'order_id!='=>11); $lastOrderInfo = \XLite\Core\Database::getRepo('XLite\Model\Order')->findOneBy($condition); return $lastOrderInfo->orderNumber;



But I'm getting "Unrecognized field: is_order" error. How to fix this error.
Reply With Quote
  #2  
Old 02-17-2017, 12:48 AM
 
Sooraj Sooraj is offline
 

Newbie
  
Join Date: Mar 2016
Posts: 9
 

Smile Re: Custom select Query issue

This is my new code and worked for me.

Code:
$lastOrderId = 0; $queryBuilder = \XLite\Core\Database::getRepo('XLite\Model\Order') ->createPureQueryBuilder('o'); $lastOrderId = $queryBuilder->select('o.orderNumber') ->andWhere('o.orig_profile = :profile_id') ->andWhere('o.order_id != :order_id') ->andWhere('o.orderNumber IS NOT NULL') ->orderBy('o.order_id', 'DESC') ->setParameter('profile_id', 7) ->setParameter('order_id', 11) ->setMaxResults(1) ->getSingleResult(); return $lastOrderId;
Reply With Quote

The following user thanks Sooraj for this useful post:
qualiteam (02-24-2017)
Reply
   X-Cart forums > X-Cart 5 > Dev Questions (X-Cart 5)



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 09:01 AM.

   

 
X-Cart forums © 2001-2020