public static function initialize(Jelly_Meta $meta) { // Set database to connect to $meta->db(Unittest_Jelly_Testcase::$database_connection); // Define fields $meta->fields(array('id' => Jelly::field('primary'), 'name' => Jelly::field('string'), 'test_posts' => Jelly::field('manytomany'), 'parent' => Jelly::field('belongsto', array('foreign' => 'test_category', 'column' => 'parent_id')))); }
public static function initialize(Jelly_Meta $meta) { // Set database to connect to $meta->db(Unittest_Jelly_Testcase::$database_connection); // Define fields $meta->fields(array('id' => Jelly::field('primary'), 'name' => Jelly::field('string'), 'password' => Jelly::field('password'), 'email' => Jelly::field('email'), 'test_posts' => Jelly::field('hasmany'), 'test_post' => Jelly::field('hasone'), 'permission' => Jelly::field('belongsto', array('foreign' => 'test_role', 'column' => 'test_role_id')), '_id' => 'id')); }
public static function initialize(Jelly_Meta $meta) { // Set database to connect to $meta->db(Unittest_Jelly_Testcase::$database_connection); // Define fields $meta->fields(array('id' => Jelly::field('primary'), 'name' => Jelly::field('string'))); }
public static function initialize(Jelly_Meta $meta) { // Set database to connect to $meta->db(Unittest_Jelly_Testcase::$database_connection); // All fields are aliased to different columns $meta->fields(array('id' => Jelly::field('primary', array('column' => 'id-alias')), 'name' => Jelly::field('string', array('column' => 'name-alias')), 'description' => Jelly::field('string', array('column' => 'description-alias')), '_id' => 'id', '_name' => 'name', '_description' => 'description', '_bar' => 'foo')); }
/** * Casts the returned value to a given type. * * @param mixed $value * @return mixed */ public function set($value) { if (isset($this->cast)) { // Cast the value using the field type defined in 'cast' $value = Jelly::field($this->cast)->set($value); } return $value; }
public static function initialize(Jelly_Meta $meta) { // Set database to connect to $meta->db(Unittest_Jelly_Testcase::$database_connection); // Posts always load_with an author $meta->load_with(array('test_author')); // Set fields $meta->fields(array('id' => Jelly::field('primary'), 'name' => Jelly::field('string'), 'slug' => Jelly::field('slug', array('unique' => TRUE)), 'status' => Jelly::field('enum', array('choices' => array('draft', 'published', 'review'))), 'created' => Jelly::field('timestamp', array('auto_now_create' => TRUE)), 'updated' => Jelly::field('timestamp', array('auto_now_update' => TRUE)), 'test_author' => Jelly::field('belongsto'), 'test_categories' => Jelly::field('manytomany'), 'approved_by' => Jelly::field('belongsto', array('foreign' => 'test_author.id', 'column' => 'approved_by')), '_id' => 'id', '_slug' => 'slug')); }
/** * Initializating model meta information * * @param Jelly_Meta $meta */ public static function initialize(Jelly_Meta $meta) { $meta->table('users')->fields(array('id' => Jelly::field('Primary'), 'email' => Jelly::field('Email'), 'name' => Jelly::field('String'), 'password' => Jelly::field('Password'))); }
/** * @param Jelly_Meta $meta */ public static function initialize(Jelly_Meta $meta) { $meta->fields(array('id' => new Field_Primary(), 'username' => Jelly::field('string', array('unique' => TRUE, 'rules' => array(array('not_empty'), array('min_length', array(':value', 4)), array('max_length', array(':value', 4))))), 'password' => Jelly::field('password', array('hash_with' => array('Model_A1_User_Jelly', 'hash_password'), 'rules' => array(array('not_empty'), array('min_length', array(':value', 6)), array('max_length', array(':value', 50))))), 'password_confirm' => Jelly::field('password', array('in_db' => FALSE, 'rules' => array(array('not_empty'), array('min_length', array(':value', 6)), array('max_length', array(':value', 50)), array('matches', array(':validation', 'password', ':field'))))))); }