- looking at the issue #012470, I found out that current ezpo code casts
object properties to the declared php type before serializing them into
the db, instead of doing that when extracting them out of the db. Am I
the only one thinking this is done backwards? After all they will be
cast anyway by the bind done in PDO a few lines of code later... Otoh it
would be nice to have the fetched data cast to say, php bool, even if
the underlying db does not support it natively
- reading the online tutorial, I find this code a bit clumsy:
$def->properties['name'] = new ezcPersistentObjectProperty
<http://ezcomponents.org/docs/api/trunk/PersistentObject/ezcPersistentObjectProperty.html>;
$def->properties['name']->columnName = 'full_name';
$def->properties['name']->propertyName = 'name';
$def->properties['name']->propertyType =
ezcPersistentObjectProperty::PHP_TYPE_STRING
<http://ezcomponents.org/docs/api/trunk/PersistentObject/ezcPersistentObjectProperty.html#PHP_TYPE_STRING>;
why is it needed to use 'name' both as key of the properties array of
the definition object and at the same time specify it in the property
itself?
imho the code should be automagic enough to either infer key names from
property->propertyName; which might be doable with small changes to
ezcPersistentObjectProperties:
public function append( $value )
{
//throw new Exception( 'Operation append is not supported by
this object.' );
// instead: get the propertyName out of $value, and if it is !==
'', use it as array key
// if otoh $value->popertyName === '', throw an exception
}
public function offsetSet( $offset, $value )
{
if ( ( $value instanceof ezcPersistentObjectProperty ) === false )
{
throw new ezcBaseValueException( 'value', $value,
'ezcPersistentObjectProperty' );
}
if ( !is_string( $offset ) || strlen( $offset ) < 1 )
{
throw new ezcBaseValueException( 'offset', $offset, 'string,
length > 0' );
}
// here: check if $offset corresponds to $value->propertyName
// if $value->propertyName === '', set it to $offset
// else if $value->propertyName !== $offset, raise an exception
parent::offsetSet( $offset, $value );
}
shall I add a feat. request to wit about this?
--
Components mailing list
[email protected]
http://lists.ez.no/mailman/listinfo/components