尊龙凯时人生就是搏

thinkphpÔõô»ñȡij×Ö¶Î

thinkphpÊÇÒ»ÖÖÊ¢ÐеÄphp¿ªÔ´¿ò¼Ü  £¬ÓÃÓÚ¿ìËÙ¿ª·¢webÓ¦ÓóÌÐò ¡£ÔÚ¿ª·¢Àú³ÌÖÐ  £¬¾­³£ÐèÒª´ÓÊý¾Ý¿âÖлñȡij¸ö×ֶεÄÖµ ¡£±¾ÎĽ«ÏÈÈÝÔÚthinkphpÖÐÔõÑù»ñȡij¸ö×ֶεÄÖµ ¡£

Ò»¡¢Ê¹ÓÃÄ£×ÓÒªÁì»ñÈ¡×Ö¶Î

1.µ¥ÌõÊý¾ÝÅÌÎÊ

ÔÚthinkphpÖÐ  £¬Ê¹ÓÃÄ£×ÓÒªÁì»ñÈ¡×Ö¶ÎÊÇ×î³£¼ûµÄÒªÁìÖ®Ò» ¡£ÔÚµ¥ÌõÊý¾ÝÅÌÎʳ¡¾°ÖÐ  £¬¿ÉÒÔʹÓÃfindÒªÁì»ñÈ¡Ö¸¶¨×ֶεÄÖµ ¡£ÀýÈç  £¬ÎÒÃÇÓÐÒ»¸öUserÄ£×Ó  £¬ÏëÒª»ñÈ¡idΪ1µÄÓû§µÄÓû§Ãû  £¬¿ÉÒÔʹÓÃÒÔÏ´úÂ룺

$user = User::find(1);
$username = $user->username;

µÇ¼ºó¸´ÖÆ

ÔÚÕâ¸öÀý×ÓÖÐ  £¬ÎÒÃÇʹÓÃUser::find(1)ÒªÁì»ñÈ¡idΪ1µÄÓû§µÄÐÅÏ¢  £¬²¢½«Ð§¹û¸³¸ø±äÁ¿$user ¡£È»ºóÎÒÃÇ¿ÉÒÔʹÓÃ$user->username»ñÈ¡Óû§Ãû ¡£

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

2.¶àÌõÊý¾ÝÅÌÎÊ

ÈôÊÇÄãÐèÒª´Ó¶àÌõÊý¾ÝÖлñÈ¡Ö¸¶¨×ֶεÄÖµ  £¬¿ÉÒÔʹÓÃselectÒªÁì ¡£ÀýÈç  £¬ÎÒÃÇÒª»ñÈ¡ËùÓÐÓû§µÄ¶¼»á  £¬¿ÉÒÔʹÓÃÒÔÏ´úÂ룺

$users = User::select();
foreach($users as $user){
    $city = $user->city;
    // do something
}

µÇ¼ºó¸´ÖÆ

ÔÚÕâ¸öÀý×ÓÖÐ  £¬ÎÒÃÇʹÓÃUser::select()ÒªÁì»ñÈ¡ËùÓÐÓû§ÐÅÏ¢  £¬²¢½«Ð§¹ûÉúÑÄÔÚ$users±äÁ¿ÖÐ ¡£È»ºóÎÒÃÇʹÓÃforeachÑ­»·±éÀúÿ¸öÓû§  £¬ÓÃ$user->city»ñÈ¡¶¼»áÃû³Æ²¢×öһЩ²Ù×÷ ¡£

¶þ¡¢Ê¹ÓÃÊý¾Ý¿âÅÌÎÊÓï¾ä»ñÈ¡×Ö¶Î

ÁíÒ»ÖÖÒªÁìÊÇʹÓÃÊý¾Ý¿âÅÌÎÊÓï¾ä»ñÈ¡×Ö¶ÎÐÅÏ¢ ¡£ÔÚthinkphpÖÐ  £¬¿ÉÒÔʹÓÃDbÀà²Ù×÷Êý¾Ý¿â ¡£ÒÔÏÂÊÇһЩ³£ÓõÄÒªÁ죺

1.ÅÌÎʵ¥¸ö×Ö¶ÎÖµ

ÈôÊÇÄãÖ»ÐèÒªÅÌÎÊij¸ö×ֶεÄÖµ  £¬¿ÉÒÔʹÓÃvalueÒªÁì ¡£ÀýÈç  £¬ÎÒÃÇÒªÅÌÎÊidΪ1µÄÓû§µÄ¶¼»á  £¬¿ÉÒÔʹÓÃÒÔÏ´úÂ룺

$city = Db::name('user')->where('id', 1)->value('city');

µÇ¼ºó¸´ÖÆ

ÔÚÕâ¸öÀý×ÓÖÐ  £¬ÎÒÃÇʹÓÃDb::name(‘user’)ÒªÁì»ñÈ¡user±íµÄ¹¤¾ß  £¬²¢Ê¹ÓÃwhereÒªÁìÖ¸¶¨ÅÌÎÊÌõ¼þ ¡£×îºó  £¬ÎÒÃÇŲÓÃvalueÒªÁì»ñÈ¡city×ֶεÄÖµ ¡£

2.ÅÌÎʶà¸ö×Ö¶ÎÖµ

ÈôÊÇÄãÐèҪͬʱÅÌÎʶà¸ö×ֶεÄÖµ  £¬¿ÉÒÔʹÓÃfieldÒªÁì ¡£ÀýÈç  £¬ÎÒÃÇÒªÅÌÎÊidΪ1µÄÓû§µÄ¶¼»áºÍÓʱà  £¬¿ÉÒÔʹÓÃÒÔÏ´úÂ룺

$user = Db::name('user')->field('city, zip')->where('id', 1)->find();
$city = $user['city'];
$zip = $user['zip'];

µÇ¼ºó¸´ÖÆ

ÔÚÕâ¸öÀý×ÓÖÐ  £¬ÎÒÃÇʹÓÃfield(‘city, zip’)ÒªÁìÖ¸¶¨ÅÌÎʵÄ×ֶΠ £¬Ê¹ÓÃfindÒªÁìÅÌÎʵ¥ÌõÊý¾Ý  £¬²¢½«Ð§¹ûÉúÑÄÔÚ$user±äÁ¿ÖÐ ¡£×îºó  £¬ÎÒÃÇ¿ÉÒÔʹÓÃ$user[‘city’]ºÍ$user[‘zip’]»ñÈ¡¶¼»áºÍÓʱà ¡£

3.ÅÌÎʶàÌõÊý¾ÝÖеÄ×Ö¶Î

ÈôÊÇÄãÐèÒª´Ó¶àÌõÊý¾ÝÖлñÈ¡Ìض¨µÄ×ֶΠ £¬¿ÉÒÔʹÓÃcolumnÒªÁì ¡£ÀýÈç  £¬ÎÒÃÇÒª»ñÈ¡ËùÓÐÓû§µÄÓÊÏä  £¬¿ÉÒÔʹÓÃÒÔÏ´úÂ룺

$emails = Db::name('user')->column('email');

µÇ¼ºó¸´ÖÆ

ÔÚÕâ¸öÀý×ÓÖÐ  £¬ÎÒÃÇʹÓÃcolumn(’email’)ÒªÁì»ñÈ¡user±íÖÐËùÓеÄemail×Ö¶ÎÖµ  £¬²¢½«Ð§¹ûÉúÑÄÔÚ$emails±äÁ¿ÖÐ ¡£

Èý¡¢×ܽá

ÒÔÉÏÊÇÔÚthinkphpÖлñȡij¸ö×ֶεÄÒªÁì ¡£ÔÚÏÖʵ¿ª·¢ÖÐ  £¬Æ¾Ö¤Ïêϸ³¡¾°Ñ¡ÔñºÏÊʵÄÒªÁì¿ÉÒÔÌá¸ß¿ª·¢Ð§ÂÊ ¡£ÎÞÂÛʹÓÃÄ£×ÓÒªÁìÕÕ¾ÉÊý¾Ý¿âÅÌÎÊÓï¾ä  £¬¶¼¿ÉÒÔÇáËÉ»ñÈ¡ÏëÒªµÄ×Ö¶ÎÐÅÏ¢ ¡£

ÒÔÉϾÍÊÇthinkphpÔõô»ñȡij×ֶεÄÏêϸÄÚÈÝ  £¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

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

Ïà¹ØÐÂÎÅ

ÁªÏµ尊龙凯时人生就是搏

18523999891

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

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

QR code
sitemap¡¢ÍøÕ¾µØͼ