當前位置: 首頁>>代碼示例>>PHP>>正文


PHP User::id方法代碼示例

本文整理匯總了PHP中App\Model\User::id方法的典型用法代碼示例。如果您正苦於以下問題:PHP User::id方法的具體用法?PHP User::id怎麽用?PHP User::id使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在App\Model\User的用法示例。


在下文中一共展示了User::id方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: removeProductFromUserWishLists

 public function removeProductFromUserWishLists(User $user, $productId)
 {
     if (!$user->loaded()) {
         return;
     }
     $this->pixie->db->query('delete')->table($this->pixie->orm->get('wishListItem')->table, 'wli')->join(array('tbl_products', 'p'), array('wli.product_id', 'p.productID'))->join(array('tbl_wish_list', 'wl'), array('wl.id', 'wli.wish_list_id'))->where('wl.user_id', '=', $user->id())->where('p.productID', '=', $productId)->execute();
 }
開發者ID:guitarooman14,項目名稱:hackazon,代碼行數:7,代碼來源:Wishlist.php

示例2: isInUserWishList

 public function isInUserWishList(User $user = null)
 {
     if ($user === null || !$user->loaded() || !$this->loaded()) {
         return false;
     }
     $num = $this->pixie->db->query('count')->table('tbl_products', 'p')->join(array('tbl_wish_list_item', 'wli'), array('wli.product_id', 'p.productID'))->join(array('tbl_wish_list', 'wl'), array('wl.id', 'wli.wish_list_id'))->where('wl.user_id', '=', $user->id())->where('p.productID', '=', $this->id())->execute();
     return $num > 0;
 }
開發者ID:guitarooman14,項目名稱:hackazon,代碼行數:8,代碼來源:Product.php

示例3: execute

 public function execute()
 {
     if ($this->processed) {
         return;
     }
     $this->pixie->session->get();
     if ($this->pixie->getParameter('parameters.use_external_dir')) {
         if ($this->removeOld) {
             if ($this->modifyUser) {
                 $this->user->photo = '';
             }
         }
         if ($this->picture->isLoaded()) {
             $uploadDir = $this->pixie->getParameter('parameters.user_pictures_external_dir');
             $uploadPath = $uploadDir . "/sess_" . session_id() . "_uploadto";
             if (!file_exists($uploadPath) || !is_dir($uploadPath)) {
                 mkdir($uploadPath, 0777, true);
             }
             $photoName = $this->generatePhotoName($this->picture);
             if ($this->pixie->getParameter('parameters.use_perl_upload')) {
                 $scriptName = $this->pixie->isWindows() ? 'uploadwin.pl' : 'uploadux.pl';
                 $headers = $this->picture->upload('http' . ($_SERVER['HTTPS'] == 'on' ? 's' : '') . '://' . $_SERVER['HTTP_HOST'] . '/upload/' . $scriptName, $photoName);
                 if ($headers['X-Created-Filename']) {
                     /** @var File $newFile */
                     $newFile = $this->pixie->orm->get('file');
                     $newFile->path = $headers['X-Created-Filename'];
                     $newFile->user_id = $this->user->id();
                     $newFile->save();
                     $this->result = $newFile->id();
                     if ($this->modifyUser) {
                         $this->user->photo = $newFile->id();
                     }
                 }
             } else {
                 $uniqueUploadPath = $uploadPath . '/' . substr(sha1(time() . $this->picture->getName()), 0, 2);
                 if (!file_exists($uniqueUploadPath) || !is_dir($uniqueUploadPath)) {
                     mkdir($uniqueUploadPath, 0777, true);
                 }
                 $newPhotoPath = $uniqueUploadPath . '/' . $photoName;
                 $this->picture->move($newPhotoPath);
                 /** @var File $newFile */
                 $newFile = $this->pixie->orm->get('file');
                 $newFile->path = $newPhotoPath;
                 $newFile->user_id = $this->user->id();
                 $newFile->save();
                 $this->result = $newFile->id();
                 if ($this->modifyUser) {
                     $this->user->photo = $newFile->id();
                 }
             }
         }
     } else {
         $relativePath = $this->pixie->getParameter('parameters.user_pictures_path');
         $pathDelimiter = preg_match('|^[/\\\\]|', $relativePath) ? '' : DIRECTORY_SEPARATOR;
         $photoPath = preg_replace('#/+$#i', '', $this->pixie->root_dir) . $pathDelimiter . $relativePath;
         if ($this->removeOld && $this->user->photo && file_exists($photoPath . $this->user->photo)) {
             unlink($photoPath . $this->user->photo);
             if ($this->modifyUser) {
                 $this->user->photo = '';
             }
         }
         if ($this->picture->isLoaded()) {
             if ($this->user->photo && file_exists($photoPath . $this->user->photo)) {
                 unlink($photoPath . $this->user->photo);
             }
             $photoName = $this->generatePhotoName($this->picture);
             $uniquePhotoDirName = substr(sha1(time() . $this->picture->getName()), 0, 2);
             $uniquePhotoDir = $photoPath . $uniquePhotoDirName;
             if (!file_exists($uniquePhotoDir) || !is_dir($uniquePhotoDir)) {
                 mkdir($uniquePhotoDir, 0777, true);
             }
             $this->picture->move($uniquePhotoDir . '/' . $photoName);
             $uniquePhotoName = $uniquePhotoDirName . '/' . $photoName;
             $this->result = $uniquePhotoName;
             if ($this->modifyUser) {
                 $this->user->photo = $uniquePhotoName;
             }
         }
     }
     $this->processed = true;
 }
開發者ID:scottleedavis,項目名稱:hackazon,代碼行數:81,代碼來源:UserPictureUploader.php


注:本文中的App\Model\User::id方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。