Skip to content

Commit

Permalink
added some models
Browse files Browse the repository at this point in the history
  • Loading branch information
ushi committed Apr 9, 2012
1 parent 23722b7 commit 5682c43
Show file tree
Hide file tree
Showing 3 changed files with 193 additions and 0 deletions.
78 changes: 78 additions & 0 deletions blogwurst/classes/model/article.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
<?php
/**
* Part of Blogwurst
*
* @packacge Blogwurst
* @version 1.0
* @license MIT
*/
/**
* Article model
*
* Handles the article data.
*/
class Model_Article extends Orm\Model
{

/**
* Table name
*
* @var string The db table
*/
protected static $_table_name = 'articles';

/**
* Proeprties
*
* @var array The db table cols
*/
protected static $_properties = array(
'id' => array('data_type' => 'int'),
'user_id' => array('data_type' => 'int'),
'title' => array(
'data_type' => 'varchar',
'validation' => array('required'),
),
'slug' => array('data_type' => 'varchar'),
'body' => array('data_type' => 'text'),
'created_at' => array('data_type' => 'time_unix'),
'updated_at' => array('data_type' => 'time_unix'),
);

/**
* Belongs to
*
* @var array Belongs to relations
*/
protected static $_belongs_to = array('user');

/**
* Many many
*
* @var array Many many relations
*/
protected static $_many_many = array('tags');

/**
* Observers
*
* @var array Needed observers
*/
protected static $_observers = array(
'Orm\\Observer_Validation' => array(
'events' => array('before_save'),
),
'Orm\\Observer_Typing' => array(
'events' => array('before_save', 'after_save', 'after_load'),
),
'Orm\\Observer_Slug' => array(
'events' => array('before_insert'),
),
'Orm\\Observer_CreatedAt' => array(
'events' => array('before_insert'),
),
'Orm\\Observer_UpdatedAt' => array(
'events' => array('before_save'),
),
);
}
55 changes: 55 additions & 0 deletions blogwurst/classes/model/tag.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?php
/**
* Part of Blogwurst
*
* @packacge Blogwurst
* @version 1.0
* @license MIT
*/
/**
* Tag model
*
* Handles the tag data.
*/
class Model_Tag extends Orm\Model
{

/**
* Table name
*
* @var string The db table
*/
protected static $_table_name = 'tags';

/**
* Proeprties
*
* @var array The db table cols
*/
protected static $_properties = array(
'id' => array('data_type' => 'int'),
'tag' => array('data_type' => 'varchar'),
'slug' => array('data_type' => 'varchar'),
);

/**
* Many many
*
* @var array Many many relations
*/
protected static $_many_many = array('articles');

/**
* Observers
*
* @var array Needed observers
*/
protected static $_observers = array(
'Orm\\Observer_Typing' => array(
'events' => array('before_save', 'after_save', 'after_load'),
),
'Orm\\Observer_Slug' => array(
'events' => array('before_insert'),
),
);
}
60 changes: 60 additions & 0 deletions blogwurst/classes/model/user.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@

<?php
/**
* Part of Blogwurst
*
* @packacge Blogwurst
* @version 1.0
* @license MIT
*/
/**
* User model
*
* Handles the user data.
*/
class Model_User extends Orm\Model
{

/**
* Table name
*
* @var string The db table
*/
protected static $_table_name = 'users';

/**
* Proeprties
*
* @var array The db table cols
*/
protected static $_properties = array(
'id' => array('data_type' => 'int'),
'username' => array('data_type' => 'varchar'),
'password' => array('data_type' => 'varchar'),
'group' => array('data_type' => 'int'),
'email' => array('data_type' => 'varchar'),
'last_login' => array('data_type' => 'varchar'),
'login_hash' => array('data_type' => 'varchar'),
'profile_fields' => array('data_type' => 'serialize'),
'reset_hash' => array('data_type' => 'varchar'),
'created_at' => array('data_type' => 'time_unix'),
);

/**
* Has many
*
* @var array Has many relations
*/
protected static $_has_many = array('articles');

/**
* Observers
*
* @var array Needed observers
*/
protected static $_observers = array(
'Orm\\Observer_Typing' => array(
'events' => array('before_save', 'after_save', 'after_load'),
),
);
}

0 comments on commit 5682c43

Please sign in to comment.