ModulesHandler::getInsertId()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 1
b 0
f 0
1
<?php namespace XoopsModules\Tdmcreate;
2
3
use XoopsModules\Tdmcreate;
4
5
/*
6
 You may not change or alter any portion of this comment or credits
7
 of supporting developers from this source code or any supporting source code
8
 which is considered copyrighted (c) material of the original comment or credit authors.
9
10
 This program is distributed in the hope that it will be useful,
11
 but WITHOUT ANY WARRANTY; without even the implied warranty of
12
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13
 */
14
15
/**
16
 * modules class.
17
 *
18
 * @copyright       XOOPS Project (https://xoops.org)
19
 * @license         GNU GPL 2 (http://www.gnu.org/licenses/old-licenses/gpl-2.0.html)
20
 *
21
 * @since           2.5.7
22
 *
23
 * @author          Txmod Xoops <[email protected]> - <http://www.txmodxoops.org/>
24
 *
25
 * @version         $Id: 1.91 modules.php 13040 2015-04-25 15:12:12Z timgno $
26
 */
27
// include __DIR__ . '/autoload.php';
28
29
/**
30
 *  @Class ModulesHandler
31
 *  @extends \XoopsPersistableObjectHandler
32
 */
33
class ModulesHandler extends \XoopsPersistableObjectHandler
34
{
35
    /**
36
     *  @public function constructor class
37
     *
38
     * @param null|\XoopsDatabase|\XoopsMySQLDatabase $db
39
     */
40
    public function __construct(\XoopsDatabase $db)
41
    {
42
        parent::__construct($db, 'tdmcreate_modules', Modules::class, 'mod_id', 'mod_name');
43
    }
44
45
    /**
46
     * @param bool $isNew
47
     *
48
     * @return \XoopsObject
49
     */
50
    public function create($isNew = true)
51
    {
52
        return parent::create($isNew);
53
    }
54
55
    /**
56
     * retrieve a field.
57
     *
58
     * @param int  $i      field id
59
     * @param null $fields
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $fields is correct as it would always require null to be passed?
Loading history...
60
     *
61
     * @return mixed reference to the <a href='psi_element://Fields'>Fields</a> object
62
     *               object
63
     */
64
    public function get($i = null, $fields = null)
65
    {
66
        return parent::get($i, $fields);
67
    }
68
69
    /**
70
     * get inserted id.
71
     *
72
     * @param null
73
     *
74
     * @return int reference to the {@link Tables} object
75
     */
76
    public function getInsertId()
77
    {
78
        return $this->db->getInsertId();
79
    }
80
81
    /**
82
     * Get Count Modules.
83
     *
84
     * @param int    $start
85
     * @param int    $limit
86
     * @param string $sort
87
     * @param string $order
88
     *
89
     * @return int
90
     */
91
    public function getCountModules($start = 0, $limit = 0, $sort = 'mod_id ASC, mod_name', $order = 'ASC')
92
    {
93
        $crCountModules = new \CriteriaCompo();
94
        $crCountModules = $this->getModulesCriteria($crCountModules, $start, $limit, $sort, $order);
95
96
        return $this->getCount($crCountModules);
97
    }
98
99
    /**
100
     * Get All Modules.
101
     *
102
     * @param int    $start
103
     * @param int    $limit
104
     * @param string $sort
105
     * @param string $order
106
     *
107
     * @return array
108
     */
109
    public function getAllModules($start = 0, $limit = 0, $sort = 'mod_id ASC, mod_name', $order = 'ASC')
110
    {
111
        $crAllModules = new \CriteriaCompo();
112
        $crAllModules = $this->getModulesCriteria($crAllModules, $start, $limit, $sort, $order);
113
114
        return $this->getAll($crAllModules);
115
    }
116
117
    /**
118
     * Get Modules Criteria.
119
     *
120
     * @param $crModules
121
     * @param $start
122
     * @param $limit
123
     * @param $sort
124
     * @param $order
125
     *
126
     * @return mixed
127
     */
128
    private function getModulesCriteria($crModules, $start, $limit, $sort, $order)
129
    {
130
        $crModules->setStart($start);
131
        $crModules->setLimit($limit);
132
        $crModules->setSort($sort);
133
        $crModules->setOrder($order);
134
135
        return $crModules;
136
    }
137
}
138