File tree Expand file tree Collapse file tree 1 file changed +23
-1
lines changed Expand file tree Collapse file tree 1 file changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -112,7 +112,29 @@ public static function getAll($parent_type, $parent_id) {
112
112
}
113
113
114
114
public function getContent () {
115
- return "NOT YET IMPLEMENTED " ; // TODO: Retrieve file from database
115
+ if (!isset (Common::$ database )) {
116
+ Common::$ database = DatabaseDriver::getDatabaseObject ();
117
+ }
118
+ try {
119
+ $ stmt = Common::$ database ->prepare ("
120
+ SELECT `content`
121
+ FROM `attachments`
122
+ WHERE `id` = :id
123
+ LIMIT 1;
124
+ " );
125
+ $ stmt ->bindParam (":id " , $ this ->id , PDO ::PARAM_INT );
126
+ if (!$ stmt ->execute ()) {
127
+ throw new QueryException ("Cannot get attachment content " );
128
+ } else if ($ stmt ->rowCount () == 0 ) {
129
+ throw new AttachmentNotFoundException ($ this ->id );
130
+ }
131
+ $ row = $ stmt ->fetch (PDO ::FETCH_OBJ );
132
+ $ stmt ->closeCursor ();
133
+ return $ row ->content ;
134
+ } catch (PDOException $ e ) {
135
+ throw new QueryException ("Cannot get attachment content " , $ e );
136
+ }
137
+ return false ;
116
138
}
117
139
118
140
public function getContentSize ($ format = false ) {
You can’t perform that action at this time.
0 commit comments