尊龙凯时人生就是搏

thinkphpÔõô×öÖ©Öë³Ø

Ëæ×Å»¥ÁªÍøµÄÉú³¤£¬ÅÀ³æ£¨Ö©Ö룩ÊÖÒÕÔ½À´Ô½Ö÷Òª ¡£ÎÞÂÛÊÇËÑË÷ÒýÇæÕÕ¾ÉÊý¾ÝÍÚ¾ò£¬¶¼ÐèҪʹÓÃÅÀ³æÊÖÒÕÀ´ËÑË÷¡¢ÍøÂçºÍÌáÈ¡ÍøÂçÊý¾Ý ¡£ÔÚÕâ¸öÀú³ÌÖУ¬Ö©Öë³Ø£¨spiderpool£©µÄÓ¦ÓÃÔ½À´Ô½ÆÕ±é ¡£±¾ÎĽ«ÏÈÈÝÔõÑùʹÓÃthinkphpÀ´¹¹½¨Ò»¸öÖ©Öë³Ø ¡£

Ò»¡¢Ê²Ã´ÊÇÖ©Öë³Ø

Ê×ÏÈ£¬ÈÃÎÒÃÇÀ´ÏàʶһÏÂʲôÊÇÖ©Öë³Ø ¡£Ö©Öë³ØÊÇÒ»¸öÅÀ³æÖÎÀíÆ÷£¬ÓÃÓÚÖÎÀí¶à¸öÅÀ³æµÄÔËÐУ¬½«¶à¸öÅÀ³æ·ÖÅɵ½²î±ðµÄʹÃüÖУ¬Ìá¸ßÅÀ³æµÄЧÂʺÍÎȹÌÐÔ ¡£

Ö©Öë³ØµÄÖ÷Òª¹¦Ð§£º

1¡¢²¢·¢¿ØÖÆ£º¿ØÖÆͬʱÔËÐеÄÅÀ³æÊýÄ¿£¬±ÜÃâЧÀÍÆ÷Òò¹ýÔضøÍ߽⠡£

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

2¡¢ÊðÀí³ØÖÎÀí£ºÊðÀíЧÀÍÆ÷µÄÖÎÀí£¬ÒÔ±£»¤ÅÀ³æ²»ÊÜ·â½û ¡£

3¡¢Ê¹Ãü·ÖÅÉ£º½«¶à¸öÅÀ³æ·ÖÅɵ½²î±ðµÄʹÃüÖУ¬Ìá¸ßÅÀ³æµÄЧÂʺÍÎȹÌÐÔ ¡£

4¡¢Ê¹Ãü¼à¿Ø£º¼à¿Ø¸÷¸öʹÃüµÄÔËÐÐ״̬£¬ÊµÊ±·¢Ã÷ÎÊÌâ²¢´¦Àí ¡£

¶þ¡¢Ö©Öë³ØµÄ¹¹½¨

1¡¢ÇéÐÎ×¼±¸

Ê×ÏÈ£¬ÔÚ×¼±¸×îÏȹ¹½¨Ö©Öë³Ø֮ǰ£¬ÐèҪȷ±£ÒÔÏÂÇéÐÎÒѾ­×¼±¸ºÃ£º

1¡¢PHP5.4»òÒÔÉÏ°æ±¾£»

2¡¢MySQLÊý¾Ý¿â£»

3¡¢Composer°ü¹ÜÀí¹¤¾ß ¡£

2¡¢×°ÖÃThinkPHP

×°ÖÃThinkPHP¿ò¼Ü£¬¿ÉÒÔʹÓÃComposer¾ÙÐÐ×°Öã¬Ö»ÐèҪʹÓÃÒÔÏÂÏÂÁ

composer create-project topthink/think

3¡¢½¨ÉèÊý¾Ý¿â±í

ÔÚMySQLÖУ¬½¨ÉèÒ»¸öÊý¾Ý¿â£¬ÀýÈç¡°spider_pool¡±£¬È»ºó½¨ÉèÒ»¸öÃûΪ¡°sp_pool¡±µÄÊý¾Ý±í£¬ÓÃÓÚ´æ´¢ÅÀ³æµÄÐÅÏ¢ ¡£±íµÄ½á¹¹ÈçÏ£º

CREATE TABLE sp_pool (

id int(11) unsigned NOT NULL AUTO_INCREMENT,

name varchar(255) DEFAULT NULL,

status tinyint(1) DEFAULT ‘0’,

create_time int(11) DEFAULT NULL,

update_time int(11) DEFAULT NULL,

PRIMARY KEY (id)

) ENGINE=InnoDB DEFAULT CHARSET=utf8;

4¡¢±àд¿ØÖÆÆ÷

½ÓÏÂÀ´£¬±àдһ¸ö¿ØÖÆÆ÷£¬ÓÃÓÚ¿ØÖÆÖ©Öë³ØµÄ¹¦Ð§ ¡£¿ÉÒÔ½¨ÉèÒÔÏÂÎļþ£ºapplication/index/controller/SpiderPool.php ¡£

ÔÚ¿ØÖÆÆ÷ÖУ¬ÐèÒª±àдÒÔÏÂÒªÁ죺

1¡¢index

¸ÃÒªÁìÓÃÓÚÏÔʾÅÀ³æ³ØµÄÁбí ¡£ÅÌÎÊÊý¾Ý¿âÖÐËùÓÐÅÀ³æµÄÐÅÏ¢£¬²¢ÏÔʾÔÚÒ³ÃæÉÏ ¡£

public function index()

{

$list = Db::name('sp_pool')->select();
return json($list);

µÇ¼ºó¸´ÖÆ

}

2¡¢add

¸ÃÒªÁìÓÃÓÚÌí¼ÓеÄÅÀ³æµ½³ØÖÐ ¡£ÔÚÌí¼ÓʹÃüʱ£¬ÐèÒªÖ¸¶¨Ê¹ÃüÃû³ÆºÍÍøÖ·µÈÐÅÏ¢ ¡£

public function add()

{

$request = Request::instance();
$sp_name = $request->post('name');
$sp_status = $request->post('status');
$sp_create_time = time();
$sp_update_time = time();
$data = [
    'name' => $sp_name,
    'status' => $sp_status,
    'create_time' => $sp_create_time,
    'update_time' => $sp_update_time,
];
$result = Db::name('sp_pool')->insert($data);
if ($result) {
    return json(['msg' => 'success']);
} else {
    return json(['msg' => 'failure']);
}

µÇ¼ºó¸´ÖÆ

}

3¡¢update

¸ÃÒªÁìÓÃÓÚ¸üÐÂÅÀ³æµÄÐÅÏ¢£¬ºÃ±ÈʹÃüÃû³Æ»òÕßʹÃü״̬µÈ ¡£

public function update()

{

$request = Request::instance();
$sp_id = $request->post('id');
$sp_name = $request->post('name');
$sp_status = $request->post('status');
$sp_update_time = time();
$data = [
    'name' => $sp_name,
    'status' => $sp_status,
    'update_time' => $sp_update_time,
];
$result = Db::name('sp_pool')->where('id', $sp_id)->update($data);
if ($result) {
    return json(['msg' => 'success']);
} else {
    return json(['msg' => 'failure']);
}

µÇ¼ºó¸´ÖÆ

}

4¡¢delete

¸ÃÒªÁìÓÃÓÚ´Ó³ØÖÐɾ³ýÖ¸¶¨µÄÅÀ³æ ¡£

public function delete()

{

$request = Request::instance();
$sp_id = $request->post('id');
$result = Db::table('sp_pool')->delete($sp_id);
if ($result) {
    return json(['msg' => 'success']);
} else {
    return json(['msg' => 'failure']);
}

µÇ¼ºó¸´ÖÆ

}

5¡¢Æô¶¯Ö©Öë³Ø

Ö©Öë³ØµÄÆô¶¯Àú³Ì¿ÉÒÔ·ÅÔÚϵͳµÄ׼ʱʹÃüÖУ¬ÔÚÿ´ÎʹÃüÖ´ÐеÄʱ¼ä£¬Æô¶¯Ö©Öë³Ø ¡£±àдÒÔϾ籾³ÌÐò£¬ÓÃÓÚÆô¶¯Ö©Öë³Ø£º

namespace appindexcontroller;

use thinkController;

class Task extends Controller

{

public function spiderpool()
{
    $list = Db::name('sp_pool')->where('status', 0)->limit(1)->select();
    if (count($list) > 0) {
        $sp_name = $list[0]['name'];
        $sp_update_time = time();
        Db::name('sp_pool')->where('name', $sp_name)->update(['status' => 1, 'update_time' => $sp_update_time]);
        //Æô¶¯ÅÀ³æʹÃü

        Db::name('sp_pool')->where('name', $sp_name)->update(['status' => 0, 'update_time' => $sp_update_time]);
    }
}

µÇ¼ºó¸´ÖÆ

}

Èý¡¢×ܽá

Ö©Öë³ØÊÇÖÎÀíÅÀ³æʹÃüµÄÐëÒª¹¤¾ß£¬¿ÉÒÔÌá¸ßÅÀ³æµÄЧÂʺÍÎȹÌÐÔ ¡£±¾ÎÄÏÈÈÝÁËÔõÑùʹÓÃThinkPHP¹¹½¨Ò»¸ö¼òÆÓµÄÖ©Öë³Ø£¬Í¨¹ýÕâ¸öÀý×Ó£¬ÎÒÃÇ¿ÉÒÔÏàʶµ½ThinkPHP¿ò¼ÜÔÚ¹¹½¨WebÓ¦ÓóÌÐòÖеÄÓÅÁ¼ÌØÕ÷ ¡£ËäÈ»±¾ÎÄÖ»ÊÇÒ»¸ö¼òÆÓµÄÀý×Ó£¬¿ÉÊÇ¿ÉÒÔΪºÍ¸÷È˸ÐÊܵ½ThinkPHPµÄÓ÷¨ºÍÍ·ÄÔÌṩһЩ×ÊÖú ¡£

ÒÔÉϾÍÊÇthinkphpÔõô×öÖ©Öë³ØµÄÏêϸÄÚÈÝ£¬¸ü¶àÇë¹Ø×¢±¾ÍøÄÚÆäËüÏà¹ØÎÄÕ£¡

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

Ïà¹ØÐÂÎÅ

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

18523999891

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

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

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