我想通過Graph API上傳Facebook頁面的封面圖片,但是一旦更新後它就會出現在時間軸上。生成唯一訂單號
我使用下面的字符串來檢查我的訂單號是唯一的
$unique_order_number = strtoupper(substr(md5(microtime()), 0, 8))
現在我想只要確保這個數字是沒有采取任何其他訂單,想用一個循環,同時還是同時循環檢查分配。
public function __unique_order_no() {
$order_no_exisits = $this->Order->find('first', array('order_no' => $unique_order_number));
while (!empty($order_no_exisits)) {
$unique_order_number = strtoupper(substr(md5(microtime()), 0, 8));
$order_no_exisits = $this->Order->find('first', array('order_no' => $unique_order_number));
debug($order_no_exisits);
}
debug($order_no_exisits);
}
我該如何使用While循環來運行它,直到我得到一個唯一的數字?