Guest User

Untitled

a guest
Jul 20th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. fn get_by_status_with_skus_trade(conn: &Connection, status: &str, pagination: &mut Pagination, is_pagination: &bool, offset: &Option<i32>, length: &Option<i32>)
  2. -> Result <(Vec<Order>, Vec<ItemOrder>, Vec<Coupon>), Error>
  3. {
  4. let stmt;
  5. let rows;
  6. if *is_pagination {
  7.  
  8. let sql = format!("SELECT * from mytable
  9. ORDER BY b.order_id DESC LIMIT {} OFFSET {}",
  10. length.unwrap(), length.unwrap() * (offset.unwrap() - 1));
  11.  
  12. stmt = try!(conn.prepare(&sql));
  13. rows = try!(stmt.query(&[&status]));
  14.  
  15. let count_stmt = try!(conn.prepare("SELECT COUNT(*) from mytable)"));
  16.  
  17.  
  18. let postgres_row = try!(count_stmt.query(&[&status]));
  19. pagination.set_pagination(postgres_row);
  20. } else {
  21. stmt = try!(conn.prepare("SELECT * from mytable'))
  22. ORDER BY b.order_id DESC"));
  23.  
  24. rows = try!(stmt.query(&[&status]));
  25. }
  26. Ok(get_info_with_skus_trade(&rows, &conn))
  27. }
Add Comment
Please, Sign In to add comment