To create a record, we have two functions i.e ‘createRecord()’ and ‘newAddCommand()’. But we should aware of the difference of these two functions though both are doing same task.
Both the functions need a layout and data array to create a record. So the first difference is the execution process. The ‘createRecord()’ statement requires ‘commit()’ , where as ‘newAddCommand()’ requires ‘execute()’ to complete the request.
Second and main difference is what they return to $result variable. The ‘createRecord()’ statement returns an integer value to know the status of record creation process(whether succeed or failed). But the ‘newAddCommand()’ returns a bunch of information for the new created record along with record id.