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

Post::findLatest()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 10
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

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