本文整理汇总了PHP中Jam::association方法的典型用法代码示例。如果您正苦于以下问题:PHP Jam::association方法的具体用法?PHP Jam::association怎么用?PHP Jam::association使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Jam
的用法示例。
在下文中一共展示了Jam::association方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: initialize
public static function initialize(Jam_Meta $meta)
{
$meta->table('vocabularies')->name_key('name');
$meta->behaviors(array('paranoid' => Jam::behavior('paranoid', array())));
$meta->associations(array('terms' => Jam::association('hasmany', array('inverse_of' => 'vocabulary'))));
$meta->fields(array('id' => Jam::field('primary'), 'name' => Jam::field('string'), 'is_hidden' => Jam::field('boolean', array()), 'created_at' => Jam::field('timestamp', array('auto_now_create' => TRUE, 'format' => 'Y-m-d H:i:s')), 'updated_at' => Jam::field('timestamp', array('auto_now_update' => TRUE, 'format' => 'Y-m-d H:i:s', 'label' => "Last edited"))));
}
示例2: initialize
public static function initialize(Jam_Meta $meta)
{
$meta->db(Kohana::TESTING);
parent::initialize($meta);
$meta->behaviors(['username' => Jam::behavior('username')]);
$meta->associations(array('user_tokens' => Jam::association('hasmany', array('foreign_model' => 'test_user_token', 'foreign_key' => 'test_user_id')), 'roles' => Jam::association('manytomany', array('foreign_model' => 'test_role', 'join_table' => 'test_roles_users', 'foreign_key' => 'test_role_id', 'association_foreign_key' => 'test_user_id'))));
}
示例3: initialize
public static function initialize(Jam_Meta $meta)
{
// Set database to connect to
$meta->db(Kohana::TESTING);
$meta->associations(array('test_owner' => Jam::association('belongsto', array('foreign_model' => 'test_author', 'foreign_key' => 'test_owner_id')), 'test_featured_category' => Jam::association('hasone', array('foreign_model' => 'test_category')), 'test_posts' => Jam::association('hasmany', array('inverse_of' => 'test_blog', 'count_cache' => TRUE, 'dependent' => Jam_Association::DELETE)), 'test_categories' => Jam::association('hasmany', array('required' => TRUE, 'inverse_of' => 'test_blog')), 'test_tags' => Jam::association('manytomany', array())));
// Define fields
$meta->fields(array('id' => Jam::field('primary'), 'name' => Jam::field('string'), 'url' => Jam::field('weblink'), 'test_posts_count' => Jam::field('integer')));
}
示例4: initialize
public static function initialize(Jam_Meta $meta)
{
$meta->table('terms')->name_key('name');
$meta->behaviors(array('nested' => Jam::behavior('Nested'), 'sluggable' => Jam::behavior('Sluggable', array('uses_primary_key' => FALSE, 'auto_save' => FALSE, 'unique' => TRUE))));
$meta->associations(array('vocabulary' => Jam::association('belongsto', array('inverse_of' => 'terms'))));
$meta->fields(array('id' => Jam::field('primary'), 'name' => Jam::field('string'), 'is_hidden' => Jam::field('boolean', array()), 'created_at' => Jam::field('timestamp', array('auto_now_create' => TRUE, 'format' => 'Y-m-d H:i:s')), 'updated_at' => Jam::field('timestamp', array('auto_now_update' => TRUE, 'format' => 'Y-m-d H:i:s'))));
$meta->validator('name', array('present' => TRUE));
}
示例5: initialize
public static function initialize(Jam_Meta $meta)
{
// Set database to connect to
$meta->db(Kohana::TESTING);
$meta->associations(array('test_image' => Jam::association('belongsto', array('dependent' => Jam_Association::DELETE))));
// Set fields
$meta->fields(array('id' => Jam::field('primary'), 'name' => Jam::field('string')));
}
示例6: initialize
public static function initialize(Jam_Meta $meta)
{
// Set database to connect to
$meta->db(Kohana::TESTING);
$meta->associations(array('test_post' => Jam::association('hasone', array('inverse_of' => 'test_author')), 'test_posts' => Jam::association('hasmany'), 'test_blogs_owned' => Jam::association('hasmany', array('foreign_model' => 'test_blog', 'foreign_key' => 'test_owner_id')), 'test_categories' => Jam::association('hasmany'), 'test_position' => Jam::association('belongsto'), 'permission' => Jam::association('belongsto', array('foreign_model' => 'test_position', 'foreign_key' => 'test_position_id'))));
// Define fields
$meta->fields(array('id' => Jam::field('primary'), 'name' => Jam::field('string'), 'password' => Jam::field('password'), 'email' => Jam::field('string')));
}
示例7: initialize
public static function initialize(Jam_Meta $meta)
{
// Set database to connect to
$meta->db(Kohana::TESTING);
$meta->associations(array('test_holder' => Jam::association('belongsto', array('polymorphic' => TRUE)), 'test_copyright' => Jam::association('hasone', array('dependent' => Jam_Association::ERASE)), 'test_copyrights' => Jam::association('hasmany', array('dependent' => Jam_Association::ERASE))));
// Set fields
$meta->fields(array('id' => Jam::field('primary'), 'file' => Jam::field('upload', array('delete_file' => TRUE))));
}
示例8: initialize
public static function initialize(Jam_Meta $meta)
{
// Set database to connect to
$meta->db(Kohana::TESTING);
$meta->behaviors(array('nested' => Jam::behavior('nested')));
$meta->associations(array('test_blog' => Jam::association('belongsto', array('inverse_of' => 'test_categories')), 'test_posts' => Jam::association('manytomany'), 'test_author' => Jam::association('belongsto')));
// Define fields
$meta->fields(array('id' => Jam::field('primary'), 'name' => Jam::field('string'), 'is_featured' => Jam::field('boolean')));
}
示例9: initialize
public static function initialize(Jam_Meta $meta)
{
// Set database to connect to
$meta->db(Kohana::TESTING);
$meta->associations(array('test_post' => Jam::association('belongsto', array('conditions' => array('where' => array('test_post._approved_by', 'IS', NULL)), 'counter_cache' => TRUE, 'touch' => 'updated')), 'test_blogs' => Jam::association('manytomany', array('join_table' => 'test_blogs_test_tags'))));
$meta->behaviors(array('sluggable' => Jam::behavior('sluggable', array('uses_primary_key' => FALSE, 'unique' => TRUE, 'slug' => 'Model_Test_Tag::_slug'))));
// Set fields
$meta->fields(array('id' => Jam::field('primary'), 'name' => Jam::field('string')));
}
示例10: initialize
public function initialize(Jam_Meta $meta, $name)
{
parent::initialize($meta, $name);
if (!$this->_branches_table) {
$this->_branches_table = ($meta->table() ?: Inflector::plural($meta->model())) . '_branches';
}
$meta->associations(array('parent' => Jam::association('closuretable_parent', array('foreign_model' => $this->_model, 'branches_table' => $this->_branches_table, 'ansestor_key' => $this->_ansestor_key, 'descendant_key' => $this->_descendant_key, 'depth_key' => $this->_depth_key, 'inverse_of' => 'children')), 'children' => Jam::association('closuretable_children', array('foreign_model' => $this->_model, 'branches_table' => $this->_branches_table, 'ansestor_key' => $this->_ansestor_key, 'descendant_key' => $this->_descendant_key, 'depth_key' => $this->_depth_key, 'inverse_of' => 'parent', 'children_dependent' => $this->_children_dependent))));
$meta->events()->bind('model.after_save', array($this, 'model_before_after_save'), Jam_Event::ATTRIBUTE_PRIORITY + 1);
}
示例11: initialize
public static function initialize(Jam_Meta $meta)
{
// Set database to connect to
$meta->db(Kohana::TESTING);
$meta->associations(array('test_author' => Jam::association('belongsto')));
// Set fields
$meta->fields(array('id' => Jam::field('primary'), 'name' => Jam::field('string'), 'url' => Jam::field('string'), 'email' => Jam::field('string'), 'description' => Jam::field('string'), 'amount' => Jam::field('integer')));
$meta->validator('name', array('present' => TRUE))->validator('name', 'email', 'url', array('count' => array('minimum' => 2)))->validator('email', array('format' => array('filter' => FILTER_VALIDATE_EMAIL)))->validator('url', array('format' => array('filter' => FILTER_VALIDATE_URL)))->validator('amount', array('numeric' => array('greater_than' => 10, 'less_than' => 100)))->validator('description', array('length' => array('between' => array(10, 1000))))->validator('name', array('format' => array('filter' => FILTER_VALIDATE_IP), 'if' => 'name_is_ip'))->validator('name', array('length' => array('minimum' => 2)));
$meta->with_options(array('unless' => 'name_is_normal()'))->validator('name', array('format' => array('filter' => FILTER_VALIDATE_EMAIL)));
}
示例12: initialize
public static function initialize(Jam_Meta $meta)
{
// Set database to connect to
$meta->db(Kohana::TESTING);
$meta->name_key('file');
$meta->behaviors(array('paranoid' => Jam::behavior('paranoid', array('field' => 'deleted')), 'sortable' => Jam::behavior('sortable', array('field' => 'position', 'scope' => 'group')), 'sluggable' => Jam::behavior('sluggable', array('auto_save' => TRUE)), 'tokenable' => Jam::behavior('tokenable', array('uppercase' => TRUE))));
$meta->associations(array('test_holder' => Jam::association('belongsto', array('polymorphic' => 'test_holder_type'))));
// Set fields
$meta->fields(array('id' => Jam::field('primary'), 'file' => Jam::field('string'), 'group' => Jam::field('string')));
$meta->validator('file', array('length' => array('minimum' => 4)));
}
示例13: initialize
public static function initialize(Jam_Meta $meta)
{
// Set database to connect to
$meta->db(Kohana::TESTING);
// Posts always load_with an author
//$meta->load_with(array('test_author'));
$meta->name_key('name');
$meta->associations(array('test_blog' => Jam::association('belongsto', array('inverse_of' => 'test_posts')), 'test_author' => Jam::association('belongsto', array()), 'test_tags' => Jam::association('hasmany', array('inverse_of' => 'test_post')), 'approved_by' => Jam::association('belongsto', array('foreign_model' => 'test_author', 'foreign_key' => '_approved_by')), 'test_images' => Jam::association('hasmany', array('as' => 'test_holder', 'dependent' => Jam_Association::DELETE)), 'test_cover_image' => Jam::association('hasone', array('as' => 'test_holder', 'foreign_model' => 'test_image', 'dependent' => Jam_Association::DELETE)), 'test_categories' => Jam::association('manytomany')));
// Set fields
$meta->fields(array('id' => Jam::field('primary'), 'name' => Jam::field('string'), 'slug' => Jam::field('slug', array('unique' => TRUE)), 'status' => Jam::field('string', array()), 'created' => Jam::field('timestamp', array('auto_now_create' => TRUE)), 'updated' => Jam::field('timestamp', array('auto_now_update' => TRUE))));
// Set some custom validators
$meta->validator('name', array('present' => TRUE, 'if' => 'slug'));
}
示例14: initialize
/**
* @codeCoverageIgnore
*/
public static function initialize(Jam_Meta $meta)
{
parent::initialize($meta);
$meta->table('shipping_items')->associations(array('shipping_external_data' => Jam::association('belongsto', array('inverse_of' => 'shipping_items'))));
}
示例15: initialize
/**
* @codeCoverageIgnore
*/
public static function initialize(Jam_Meta $meta)
{
$meta->behaviors(array('paranoid' => Jam::behavior('paranoid')))->associations(array('groups' => Jam::association('hasmany', array('foreign_model' => 'shipping_group', 'foreign_key' => 'shipping_id', 'inverse_of' => 'shipping', 'delete_on_remove' => Jam_Association::DELETE)), 'methods' => Jam::association('manytomany', array('foreign_model' => 'shipping_method', 'association_foreign_key' => 'method_id', 'join_table' => 'shipping_groups', 'readonly' => TRUE, 'join_table_paranoid' => TRUE)), 'locations' => Jam::association('manytomany', array('join_table' => 'shipping_groups', 'join_table_paranoid' => TRUE, 'readonly' => TRUE)), 'ships_from' => Jam::association('belongsto', array('foreign_model' => 'location')), 'brand' => Jam::association('belongsto', array('inverse_of' => 'shippings'))))->fields(array('id' => Jam::field('primary'), 'model' => Jam::field('polymorphic'), 'name' => Jam::field('string'), 'currency' => Jam::field('string')))->validator('name', 'currency', array('present' => TRUE))->validator('currency', array('currency' => TRUE));
}