Advertisement
LrdArc

getUniqueCode()

Oct 14th, 2017
334
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.30 KB | None | 0 0
  1. <?php
  2.  
  3. // how to use
  4. // echo $this->getUniqueCode();
  5.  
  6. function getUniqueCode() {
  7.     $start = 1;
  8.     $limit = 100;
  9.     $query = "SELECT unique_code FROM orders ORDER BY id DESC";
  10.     $fetch = $this->db->query( $query )->row();
  11.     $code = $fetch->unique_code;
  12.     return $code < $limit ? $code + 1 : $start;
  13. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement