forked from dojoVader-dev/Diary
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCategoryModel.php
executable file
·48 lines (44 loc) · 934 Bytes
/
CategoryModel.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<?php
namespace Plugin\Diary;
class CategoryModel extends BaseModel {
/**
* Inserts the Category into the Database
*
* @param Array $data
* @return int Record ID or false
*/
public $name="diary_category";
const DRAFT = 0;
const PUBLISHED = 1;
public function save($data) {
return ipDb ()->insert ( "diary_category", $data );
}
/**
* Returns an Array of Status for the Category
*
* @return multitype:string
*/
public function getCategoryStatus() {
return array (
"Draft" => self::DRAFT,
"Published" => self::PUBLISHED
);
}
public function getCategories() {
return ipDb ()->selectAll ( "diary_category", array (
'id',
'name'
) );
}
public function getCategoryOptions() {
$options = $this->getCategories ();
$optionsArray = array ();
foreach ( $options as $opt ) {
$optionsArray [] = array (
$opt ['id'],
$opt ['name']
);
}
return $optionsArray;
}
}