JSON conversion
{
"id": 1,
"username": "Tester",
"password": "c098c977b6c9242f738ed521a63cb7e8",
"email": "test@example.com",
"created": "2024-12-07"
}
Database\Barebone_me\Activerecords\customer Object
(
[tablename:Barebone\Activerecord:private] => customer
[primary_key:Barebone\Activerecord:private] => id
[pdo:Barebone\Activerecord:private] => Barebone\Database\Connectors\PDO Object
(
)
[debug:protected] =>
[joins:protected] => Array
(
)
[selected_columns:protected] => Array
(
)
[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 JSON
print_r($customer->toJSON());
$json = '{"id":1,"username":"Testertjes","password":"c098c977b6c9242f738ed521a63cb7e8","email":"barebone@it-api.nl","active":1,"created":"2017-03-05 12:41:59","updated":"2017-03-05 12:43:27","comment":"","realeditor":""}';
$customer->set_data($json);
print_r($customer);