Magicsig class now Managed_DataObject with nicer schemaDef

This commit is contained in:
Mikael Nordfeldth 2013-08-18 15:31:18 +02:00
parent ade2bdc31b
commit 1710a619a8

View File

@ -81,39 +81,21 @@ class Magicsig extends Managed_DataObject
$this->alg = $alg; $this->alg = $alg;
} }
function table() public static function schemaDef()
{ {
return array( return array(
'user_id' => DB_DATAOBJECT_INT, 'fields' => array(
'keypair' => DB_DATAOBJECT_STR + DB_DATAOBJECT_NOTNULL, 'user_id' => array('type' => 'int', 'not null' => true, 'description' => 'user id'),
'alg' => DB_DATAOBJECT_STR 'keypair' => array('type' => 'text', 'description' => 'keypair text representation', 'collate' => 'utf8_general_ci'),
'alg' => array('type' => 'varchar', 'length' => 64, 'description' => 'algorithm'),
),
'primary key' => array('user_id'),
'foreign keys' => array(
'magicsig_user_id_fkey' => array('user', array('user_id' => 'id')),
),
); );
} }
static function schemaDef()
{
return array(new ColumnDef('user_id', 'integer',
null, false, 'PRI'),
new ColumnDef('keypair', 'text',
false, false),
new ColumnDef('alg', 'varchar',
64, false));
}
function keys()
{
return array_keys($this->keyTypes());
}
function keyTypes()
{
return array('user_id' => 'K');
}
function sequenceKey() {
return array(false, false, false);
}
/** /**
* Save this keypair into the database. * Save this keypair into the database.
* *