I would like to know if there are any benefits of one of the following 2 methods which insert an object into a database
The first function calls the Model method statically, creating a new instance of the Insert function on the call.
foreach ($model_data as $data) {
$row = \Models\ModelData::createRow($data, $u->dname, $w_reason, $comment);
$insert = \Models\ModelData::Insert($row);
$insert_obj = new \stdClass();
$insert_obj->d_name = $data->{'Data Name'};
$insert_obj->status = $insert;
$insert_array[] = $insert_obj;
}
This version of the function calls the Model method non-statically.
foreach ($model_data as $data) {
$row = \Models\ModelData::createRow($data, $u->dname, $w_reason, $comment);
$insert_result = $row->Insert();
$insert_obj = new \stdClass();
$insert_obj->d_name = $data->{'Data Name'};
$insert_obj->status = $insert_result;
$insert_array[] = $insert_obj;
}
With the Model method being called non-statically, there is no need for an argument to be passed in.
public function Insert(): bool
But with the Model being created via a static method, it requires the argument.
public static function Insert(MyObject $object): bool
Is there a major benefit to one of these over the other?