-
Notifications
You must be signed in to change notification settings - Fork 0
/
Article.php
38 lines (34 loc) · 1.08 KB
/
Article.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
<?php
class Application_Model_M_Article extends Application_Model_M_B_Article{
public static function fetchByType($type = 1){
if(!is_numeric($type)){
return array();
}
$select = self::select();
$select
->where('type = ?',$type)
->where('status = 1')
->order('sort asc')
;
$data = self::fetchAll($select);
return $data;
}
public static function updateImage($id,$img){
$sql = "UPDATE yy_article SET img = '{$img}' WHERE id = {$id}";
$config = self::getDb()->getConfig();
$pdo = new PDO("mysql:host={$config['host']};dbname={$config['dbname']}", $config['username'], $config['password']);
return $pdo->exec($sql);
}
public static function getImage($id){
$sql = "SELECT img FROM yy_article WHERE id={$id}";
$res = self::getDb()->query($sql)->fetchAll();
$img = "";
if(count($res)>0){
$img = $res['0']['img'];
}
return $img;
}
public static function getImageUrl($id){
return '/more/artimage?id='.$id;
}
}