Object conversion
stdClass Object
(
[id] => 1
[username] => Tester
[password] => c098c977b6c9242f738ed521a63cb7e8
[email] => test@example.com
[created] => 2024-12-07
)
Source
<?php
// create customer object
$customer = new \customer();
// load the customer properties from customer 1
$customer->get_by_id(1);
// assign the customer to the view
$this->view->customer = $customer;
// convert to Object
print_r($customer->toObject());
Source object to activerecord
<?php
// create a stdClass object
$data = new stdClass;
// set the properties
$data->id = null;
$data->username = 'Tester';
$data->password = 'c098c977b6c9242f738ed521a63cb7e8';
$data->email = 'barebone@it-api.nl'
$data->active = '1';
// create customer object
$customer = new \customer();
// set the array as values to the customer object
$customer->set_data($data);
// save the customer
$customer->save();
/**
* PREFER THIS WAY
*/
// create customer object
$customer = new \customer();
// set the properties
$customer->id = null;
$customer->username = 'Tester';
$customer->password = 'c098c977b6c9242f738ed521a63cb7e8';
$customer->email = 'barebone@it-api.nl'
$customer->active = '1';
// save the customer
$customer->save();