×ðÁú¿­Ê±¹ÙÍøµÇ¼

thinkphpÌáÐÑÒªÁì²ÎÊý¹ýʧid

thinkphpÌáÐÑÒªÁì²ÎÊý¹ýʧid

ThinkPHPÊÇÒ»¿îÓÅÒìµÄ¿ªÔ´PHP¿ò¼Ü £¬ËüµÄÉè¼ÆÀíÄîÊÇ¿ìËÙ¡¢¼òÆÓ¡¢ÎÞа¡£ËüÌṩÁ˸»ºñµÄ¿ª·¢¹¤¾ßºÍ¹¦Ð§ £¬Ê¹µÃÎÒÃÇ¿ª·¢WebÓ¦ÓóÌÐòʱԽ·¢¸ßЧ £¬²¢ÇÒÄܹ»¿ìËÙµØʵÏÖÎÒÃÇËùÐèµÄ¹¦Ð§¡£

ÔÚʹÓÃThinkPHP¾ÙÐпª·¢Ê± £¬¿ÉÄÜ»áÓöµ½ÒªÁì²ÎÊý¹ýʧidµÄÎÊÌâ¡£ÕâÒ»ÎÊÌâºÜ³£¼û £¬¿ÉÊÇËüµÄ½â¾öÒªÁì²¢²»ÖØ´ó¡£ÏÂÃæÎÒÃÇÀ´¿´Ò»ÏÂÏêϸµÄ½â¾öÒªÁì¡£

Ê×ÏÈ £¬ÎÒÃÇÐèÒªÏàʶ¹ØÓÚ¡°ÒªÁì²ÎÊý¹ýʧid¡±µÄһЩ»ù±¾ÖªÊ¶¡£µ±ÎÒÃÇÔÚʹÓÿØÖÆÆ÷ÖеÄij¸öÒªÁìʱ £¬ÈôÊÇת´ïÁ˹ýʧ»òÕß²»±£´æµÄ²ÎÊýid £¬¾Í»áµ¼Ö¸ÃÒªÁìÎÞ·¨Õý³£Ö´ÐС£Òò´Ë £¬ÎÒÃÇÐèÒª¶Ôת´ïµÄ²ÎÊý¾ÙÐÐ׼ȷµÄÑéÖ¤ £¬ÒÔÈ·±£×ª´ïµÄ²ÎÊýidÊÇ׼ȷµÄ¡£

Æä´Î £¬ÎÒÃÇÐèÒª¶ÔThinkPHP¿ò¼ÜÖеIJÎÊýת´ïÒªÁì¾ÙÐÐÉîÈëÏàʶ¡£ÔÚThinkPHP¿ò¼ÜÖÐ £¬¿ÉÒÔʹÓÃget¡¢post¡¢paramµÈÒªÁìÀ´»ñȡת´ïµÄ²ÎÊýÖµ¡£ÆäÖÐ £¬getÒªÁì¿ÉÒÔ»ñÈ¡URLÖеIJÎÊýÖµ £¬postÒªÁì¿ÉÒÔ»ñÈ¡±íµ¥ÖеIJÎÊýÖµ £¬paramÒªÁì¿ÉÒÔͬʱ»ñÈ¡URLºÍ±íµ¥ÖеIJÎÊýÖµ¡£ÔÚ»ñÈ¡²ÎÊýÖµºó £¬ÎÒÃÇÐèÒª¶Ôת´ïµÄ²ÎÊý¾ÙÐÐÑéÖ¤¡£

Á¬Ã¦Ñ§Ï°¡°PHPÃâ·ÑѧϰÌõ¼Ç£¨ÉîÈ룩¡±£»

ÀýÈç £¬ÎÒÃÇÔÚ¿ØÖÆÆ÷Öнç˵ÁËÒ»¸öshowÒªÁì £¬ÓÃÓÚƾ֤ת´ïµÄ²ÎÊýidÀ´Õ¹Êլû§ÐÅÏ¢¡£¸ÃÒªÁì´úÂëÈçÏ£º

public function show($id){

$user = UserModel::get($id);
$this->assign('user', $user);
return $this->fetch();

µÇ¼ºó¸´ÖÆ

}

ÔÚ»á¼û¸Ã¿ØÖÆÆ÷ʱ £¬ÎÒÃÇÐèҪת´ï׼ȷµÄ²ÎÊýid²Å»ªÕý³£Õ¹Êլû§ÐÅÏ¢ £¬²»È»¾Í»á·ºÆð¡°ÒªÁì²ÎÊý¹ýʧid¡±µÄ¹ýʧÌáÐÑ¡£Òò´Ë £¬ÎÒÃÇÐèÒªÌí¼Ó²ÎÊýÑéÖ¤´úÂë £¬ÒÔÈ·±£×ª´ïµÄ²ÎÊýidÊÇ׼ȷµÄ¡£

ÀýÈç £¬ÎÒÃÇ¿ÉÒÔʹÓÃÏÂÃæµÄ´úÂë¶Ôת´ïµÄ²ÎÊýid¾ÙÐÐÑéÖ¤£º

public function show($id){

if(!is_numeric($id) || $id <= 0){
    $this->error('²ÎÊý¹ýʧ£¡');
}
$user = UserModel::get($id);
$this->assign('user', $user);
return $this->fetch();

µÇ¼ºó¸´ÖÆ

}

ÔڸôúÂëÖÐ £¬ÎÒÃÇÊ×ÏÈʹÓÃis_numericº¯ÊýÅжÏת´ïµÄ²ÎÊýidÊÇ·ñΪÊý×Ö £¬ÈôÊDz»ÎªÊý×ÖÔòÌáÐÑ¡°²ÎÊý¹ýʧ¡±¡£½Ó×Å £¬ÎÒÃÇÅжÏת´ïµÄ²ÎÊýidÊÇ·ñСÓÚ¼´ÊÇ0 £¬ÈôÊÇСÓÚ¼´ÊÇ0ÔòͬÑùÌáÐÑ¡°²ÎÊý¹ýʧ¡±¡£×îºó £¬ÈôÊÇת´ïµÄ²ÎÊýid׼ȷ £¬¾Í»áÕý³£Õ¹Êլû§ÐÅÏ¢¡£

³ýÁËת´ï²ÎÊý¹ýʧÍâ £¬ÉÐÓпÉÄ᷺ܻÆðȱʧ²ÎÊýµÄÇéÐΡ£ÀýÈç £¬ÔÚʹÓ÷ÖÒ³¹¦Ð§Ê± £¬ÈôÊÇûÓÐת´ï׼ȷµÄÒ³Âë²ÎÊý £¬Ôò»á·ºÆð¡°ÒªÁìȱÉÙÒ³Âë²ÎÊý¡±µÄ¹ýʧÌáÐÑ¡£ÔÚÕâÖÖÇéÐÎÏ £¬ÎÒÃÇͬÑùÐèÒª¶Ôת´ïµÄ²ÎÊý¾ÙÐÐ׼ȷµÄÑéÖ¤ £¬ÒÔÈ·±£²ÎÊýµÄÍêÕûÐÔ¡£

ÀýÈç £¬ÎÒÃÇÔÚ¿ØÖÆÆ÷Öнç˵ÁËÒ»¸öÁбíÒ³ÒªÁìlist £¬ÓÃÓÚÕ¹Êլû§Áбí¡£ÔÚ¸ÃÒªÁìÖÐ £¬ÎÒÃÇÐèҪת´ïÒ»¸öÄ¿½ñÒ³Âë²ÎÊý$page £¬ÒÔ±ã·ÖÒ³Õ¹Êլû§Áбí¡£ÏÂÃæÊǸÃÒªÁìµÄ´úÂ룺

public function list($page){

$userModel = new UserModel();
$userList = $userModel->paginate(10, false, ['page' => $page]);
$this->assign('userList', $userList);
return $this->fetch();

µÇ¼ºó¸´ÖÆ

}

ÔÚ»á¼û¸Ã¿ØÖÆÆ÷ʱ £¬ÎÒÃÇÐèҪת´ïÄ¿½ñÒ³Âë²ÎÊý$page²Å»ªÕý³£Õ¹Êլû§Áбí¡£ÈôÊÇûÓÐת´ïÄ¿½ñÒ³Âë²ÎÊý$page £¬Ôò»á·ºÆð¡°ÒªÁìȱÉÙÒ³Âë²ÎÊý¡±µÄ¹ýʧÌáÐÑ¡£Òò´Ë £¬ÎÒÃÇÐèÒª¶Ôת´ïµÄ²ÎÊý¾ÙÐÐÑéÖ¤ £¬ÒÔÈ·±£²ÎÊýµÄÍêÕûÐÔ¡£

ÀýÈç £¬ÎÒÃÇ¿ÉÒÔʹÓÃÏÂÃæµÄ´úÂë¶Ôת´ïµÄ²ÎÊý$page¾ÙÐÐÑéÖ¤£º

public function list($page){

if(empty($page) || !is_numeric($page) || $page <= 0){
    $this->error('²ÎÊý¹ýʧ£¡');
}
$userModel = new UserModel();
$userList = $userModel->paginate(10, false, ['page' => $page]);
$this->assign('userList', $userList);
return $this->fetch();

µÇ¼ºó¸´ÖÆ

}

ÔڸôúÂëÖÐ £¬ÎÒÃÇÊ×ÏÈʹÓÃemptyº¯ÊýÅжÏת´ïµÄ²ÎÊý$pageÊÇ·ñΪ¿Õ £¬ÈôÊÇΪ¿ÕÔòÌáÐÑ¡°²ÎÊý¹ýʧ¡±¡£½Ó×Å £¬ÎÒÃÇʹÓÃis_numericº¯ÊýÅжÏת´ïµÄ²ÎÊý$pageÊÇ·ñΪÊý×Ö £¬ÈôÊDz»ÎªÊý×ÖÔòͬÑùÌáÐÑ¡°²ÎÊý¹ýʧ¡±¡£×îºó £¬ÈôÊÇת´ïµÄ²ÎÊý$page׼ȷ £¬¾Í»áÕý³£Õ¹Êլû§Áбí¡£

×ÛÉÏËùÊö £¬¹ØÓÚ¡°ÒªÁì²ÎÊý¹ýʧid¡±µÄÎÊÌâ £¬ÎÒÃÇÐèÒª¶Ôת´ïµÄ²ÎÊý¾ÙÐÐ׼ȷµÄÑéÖ¤ £¬ÒÔÈ·±£²ÎÊýµÄ׼ȷÐÔ¡¢ÍêÕûÐÔ¡£µ±·ºÆðÀàËƵÄÎÊÌâʱ £¬ÎÒÃÇ¿ÉÒÔ½ÓÄÉÉÏÊöÑéÖ¤ÒªÁì¾ÙÐд¦Àí £¬ÒÔÈ·±£Ó¦ÓóÌÐòµÄÕý³£ÔËÐС£

ÒÔÉϾÍÊÇthinkphpÌáÐÑÒªÁì²ÎÊý¹ýʧidµÄÏêϸÄÚÈÝ £¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

ÃâÔð˵Ã÷£ºÒÔÉÏչʾÄÚÈÝȪԴÓÚÏàÖúýÌå¡¢ÆóÒµ»ú¹¹¡¢ÍøÓÑÌṩ»òÍøÂçÍøÂçÕûÀí £¬°æȨÕùÒéÓë±¾Õ¾ÎÞ¹Ø £¬ÎÄÕÂÉæ¼°¿´·¨Óë¿´·¨²»´ú±í×ðÁú¿­Ê±¹ÙÍøµÇ¼ÂËÓÍ»úÍø¹Ù·½Ì¬¶È £¬Çë¶ÁÕß½ö×ö²Î¿¼¡£±¾ÎĽӴýתÔØ £¬×ªÔØÇë˵Ã÷À´ÓÉ¡£ÈôÄúÒÔΪ±¾ÎÄÇÖÕ¼ÁËÄúµÄ°æȨÐÅÏ¢ £¬»òÄú·¢Ã÷¸ÃÄÚÈÝÓÐÈκÎÉæ¼°ÓÐÎ¥¹«µÂ¡¢Ã°·¸Ö´·¨µÈÎ¥·¨ÐÅÏ¢ £¬ÇëÄúÁ¬Ã¦ÁªÏµ×ðÁú¿­Ê±¹ÙÍøµÇ¼ʵʱÐÞÕý»òɾ³ý¡£

Ïà¹ØÐÂÎÅ

ÁªÏµ×ðÁú¿­Ê±¹ÙÍøµÇ¼

18523999891

¿É΢ÐÅÔÚÏß×Éѯ

ÊÂÇéʱ¼ä£ºÖÜÒ»ÖÁÖÜÎå £¬9:30-18:30 £¬½ÚãåÈÕÐÝÏ¢

QR code
ÍøÕ¾µØͼ