Skip to main content

Ben Tre trip

The driving force behind this trip is my curiosity about this western area, its people, culture, landscape.

Comments

Popular posts from this blog

PHP json_encode return empty array [] instead of empty object {}

Problem: Get below array for example.  $status = array ( "message" => "error" , "club_id" => $_club_id , "status" => "1" , "membership_info" => array (), ); This array will be encoded in json format echo json_encode($status); This function return json: {"message":"error","club_id":275,"status":"1","membership_info": [] } Notice the empty array [], it is not consistent, it should be an empty object {} {"message":"error","club_id":275,"status":"1","membership_info": {} } The cause: This problem is caused by the called function array(), which yields an empty array [] Solution: There are 2 solutions for this issue: Solution 1: Call new stdClass instead of array(), stdClass generates an empty object {} Solution 2: The above solution is complex in case there are plenty of arr...

Fix cross domain in ajax request

Follow this sample ajax request $.ajax({    "type": 'POST',    "url": url,     "crossDomain": true,    "data": params,    "dataType": 'json',    "async": false,    "success": function(data){ done_fn(data, is_test);    },    "error": function (jqXHR) { var data = $.parseJSON(jqXHR.responseText); $("#results").text(data.message);    } }); The keys are crossDomain: true and async: false Hope to help many people.

Sub-program (procedure and function) in SQL

What is sub-program in SQL? Sub-program is a programming unit which is created in a database to perform some tasks on data. Basic usages of sub-program? Create CREATE PROCEDURE or CREATE FUNCTION Delete DROP PROCEDURE or DROP FUNCTION Two kinds of sub-program: PROCEDURE: perform an action but NOT return a value, but we can get output value by OUT variables. and FUNCTION: compute and return a value Create procedure: CREATE [ OR REPLACE ] PROCEDURE procedure_name [( parameter_name [ IN | OUT | IN OUT ] type [, ...])] { IS | AS } BEGIN < procedure_body > END procedure_name ; Create function: CREATE [ OR REPLACE ] FUNCTION function_name [( parameter_name [ IN | OUT | IN OUT ] type [, ...])] RETURN return_datatype { IS | AS } BEGIN < function_body > END [ function_name ]; What is cursor? A cursor holds the rows (one or more) returned by a SQL statement. Triggers are stored programs, which are automatically executed or fired wh...