Bookmark class now has schemaDef (for Managed_DataObject)
This commit is contained in:
parent
2a4dc77a63
commit
ade2bdc31b
|
@ -53,72 +53,36 @@ class Bookmark extends Managed_DataObject
|
||||||
public $uri; // varchar(255)
|
public $uri; // varchar(255)
|
||||||
public $created; // datetime
|
public $created; // datetime
|
||||||
|
|
||||||
/**
|
public static function schemaDef()
|
||||||
* Get an instance by compound key
|
|
||||||
*
|
|
||||||
* This is a utility method to get a single instance with a given set of
|
|
||||||
* key-value pairs. Usually used for the primary key for a compound key; thus
|
|
||||||
* the name.
|
|
||||||
*
|
|
||||||
* @param array $kv array of key-value mappings
|
|
||||||
*
|
|
||||||
* @return Bookmark object found, or null for no hits
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
function pkeyGet($kv)
|
|
||||||
{
|
{
|
||||||
return Memcached_DataObject::pkeyGet('Bookmark', $kv);
|
return array(
|
||||||
}
|
'fields' => array(
|
||||||
|
'id' => array('type' => 'char',
|
||||||
/**
|
'length' => 36,
|
||||||
* return table definition for DB_DataObject
|
'not null' => true),
|
||||||
*
|
'profile_id' => array('type' => 'int', 'not null' => true),
|
||||||
* DB_DataObject needs to know something about the table to manipulate
|
'uri' => array('type' => 'varchar',
|
||||||
* instances. This method provides all the DB_DataObject needs to know.
|
'length' => 255,
|
||||||
*
|
'not null' => true),
|
||||||
* @return array array of column definitions
|
'url' => array('type' => 'varchar',
|
||||||
*/
|
'length' => 255,
|
||||||
function table()
|
'not null' => true),
|
||||||
{
|
'title' => array('type' => 'varchar', 'length' => 255),
|
||||||
return array('id' => DB_DATAOBJECT_STR + DB_DATAOBJECT_NOTNULL,
|
'description' => array('type' => 'text'),
|
||||||
'profile_id' => DB_DATAOBJECT_INT + DB_DATAOBJECT_NOTNULL,
|
'created' => array('type' => 'datetime', 'not null' => true),
|
||||||
'url' => DB_DATAOBJECT_STR,
|
),
|
||||||
'title' => DB_DATAOBJECT_STR,
|
'primary key' => array('id'),
|
||||||
'description' => DB_DATAOBJECT_STR,
|
'unique keys' => array(
|
||||||
'uri' => DB_DATAOBJECT_STR,
|
'bookmark_uri_key' => array('uri'),
|
||||||
'created' => DB_DATAOBJECT_STR + DB_DATAOBJECT_DATE +
|
),
|
||||||
DB_DATAOBJECT_TIME + DB_DATAOBJECT_NOTNULL);
|
'foreign keys' => array(
|
||||||
}
|
'bookmark_profile_id_fkey' => array('profile', array('profile_id' => 'id'))
|
||||||
|
),
|
||||||
/**
|
'indexes' => array('bookmark_created_idx' => array('created'),
|
||||||
* return key definitions for DB_DataObject
|
'bookmark_url_idx' => array('url'),
|
||||||
*
|
'bookmark_profile_id_idx' => array('profile_id'),
|
||||||
* @return array list of key field names
|
),
|
||||||
*/
|
);
|
||||||
function keys()
|
|
||||||
{
|
|
||||||
return array_keys($this->keyTypes());
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* return key definitions for Memcached_DataObject
|
|
||||||
*
|
|
||||||
* @return array associative array of key definitions
|
|
||||||
*/
|
|
||||||
function keyTypes()
|
|
||||||
{
|
|
||||||
return array('id' => 'K',
|
|
||||||
'uri' => 'U');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Magic formula for non-autoincrementing integer primary keys
|
|
||||||
*
|
|
||||||
* @return array magic three-false array that stops auto-incrementing.
|
|
||||||
*/
|
|
||||||
function sequenceKey()
|
|
||||||
{
|
|
||||||
return array(false, false, false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue
Block a user