Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Flatterizor post on Andreabaccega.com
<?php
require_once('./classes/flatterizor.class.php');
$mat = new stdClass();
$mat->name = 'Mat';
$mat->permissions = array( );
$mat->permissions['can_write'] = false;
$mat->permissions['can_read'] = true;
$flatterizor = new ObjectFlatterizor(true);
$matGoodLooking = $flatterizor->flatterize($mat);
var_dump($matGoodLooking);
O:8:"stdClass":2:{s:4:"name";s:3:"Mat";s:11:"permissions";a:2:s:9:"can_write";b:0;s:8:"can_read";b:1;}}
<?php
$bob = new stdClass();
$bob->name = 'Bob';
$bob->permissions = array( );
$bob->permissions['can_write'] = true;
$bob->permissions['can_read'] = true;
$mat = new stdClass();
$mat->name = 'Mat';
$mat->permissions = array( );
$mat->permissions['can_write'] = false;
$mat->permissions['can_read'] = true;
SELECT userID from userinfos
WHERE name='/permissions/[can_write]'
AND val='true'
CREATE TABLE IF NOT EXISTS `userinfos` (
`userID` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(256) NOT NULL,
`val` varchar(256) NOT NULL,
PRIMARY KEY (`userID`,`name`),
KEY `name` (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=1 ;
object(stdClass)#4 (2) {
["objectDefinitions"]=>
array(1) {
["/"]=>
string(8) "stdClass"
}
["values"]=>
array(3) {
[0]=>
array(2) {
["path"]=>
string(5) "/name"
["val"]=>
string(3) "Mat"
}
[1]=>
array(2) {
["path"]=>
string(24) "/permissions/[can_write]"
["val"]=>
bool(false)
}
[2]=>
array(2) {
["path"]=>
string(23) "/permissions/[can_read]"
["val"]=>
bool(true)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment