Passed
Push — master ( 806287...909ea5 )
by Lydia
02:52
created

Comment::findAllCommentsWhere()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
cc 2
eloc 8
nc 2
nop 2
dl 0
loc 10
ccs 0
cts 9
cp 0
crap 6
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Lyco\Comment;
4
5
use Anax\DatabaseActiveRecord\ActiveRecordModel;
6
7
8
/**
9
 * A database driven model using the Active Record design pattern.
10
 */
11
class Comment extends ActiveRecordModel
12
{
13
    /**
14
     * @var string $tableName name of the database table.
15
     */
16
    protected $tableName = "Comment";
17
    protected $tableIdColumn = "commentId";
18
19
20
21
    /**
22
     * Columns in the table.
23
     *
24
     * @var integer $id primary key auto incremented.
25
     */
26
    public $commentId;
27
    public $postId;
28
    public $replyId;
29
    public $id;
30
    public $text;
31
32
    public function findAllCommentsWhere($where, $value)
33
    {
34
        $this->checkDb();
35
        $params = is_array($value) ? $value : [$value];
36
        return $this->db->connect()
37
                        ->select()
38
                        ->from($this->tableName)
39
                        ->where($where . " = ?")
40
                        ->execute($params)
41
                        ->fetchAllClass(get_class($this));
42
    }
43
}
44