Posts

Showing posts from October, 2019

Directory ownership change and mode change - Linux

- sudo chown hasib:hasib html/ - sudo chmod +x html/ - sudo chmod -R 777 html/

CURL

*** Initialize a cURL session $ch = curl_init(); *** Set the URL that you want to GET by using the CURLOPT_URL option. curl_setopt($ch, CURLOPT_URL, $url); *** Set CURLOPT_RETURNTRANSFER so that the content is returned as a variable. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); *** Set CURLOPT_FOLLOWLOCATION to true to follow redirects. curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); *** Timeout after 120 seconds curl_setopt($ch, CURLOPT_CONNECTTIMEOUT , 120); *** Start counting time for response from BL API. $time_start     = microtime(true); $requestTime    = Carbon::now()->format('Y-m-d H:i:s'); *** Execute the request. $response   = curl_exec($ch); *** End counting, and calculate time for response from BL API. $time_end       = microtime(true); $responseTime   = Carbon::now()->format('Y-m-d H:i:s'); $execution_time = ($time_end - $time_start)*1000; *** Return a string containing the last error for the current session $err  = curl

MySQL Query - IF CONDITION, DATE FORMAT, ADD DAY IN DATE, SUBTRACT DAY FROM DATE

1. IF CONDITION SELECT IF(condition,true,false) AS row_name; 2. ADD 10 DAYS IN DATE SELECT DATE_ADD("2019-10-01", INTERVAL 10 DAY) 3. SUBTRACT 10 DAYS FROM DATE SELECT DATE_SUB("2019-10-01", INTERVAL 10 DAY); 4. FORMAT DATE DATE_FORMAT(table.date, "%Y-%m-%d 23:59:59") PRACTICAL EXAMPLE IN A SELECT-INSERT QUERY :  INSERT INTO subscription_history( customer_id, sales_log_id, customer_name, plan_id, plan_name, plan_duration, transaction_price, subscription_plan_purchased_date, subscription_activation_date, subscription_end_date, status, created_by, updated_by, deleted_by, deleted_at, created_at, updated_at) SELECT  sales_log.customer_id, sales_log.id AS sales_log_id, customers.name AS customer_name, sales_log.plan_id, subscription_plans.plan_name, subscription_plans.plan_duration, subscription_plans.plan_price AS transaction_price, sales_log.sales_date AS subscription_plan_purchased_date, sales_log.sales_date AS subscription_acti