89 lines
2.2 KiB
PHP
89 lines
2.2 KiB
PHP
<?php
|
|
/*
|
|
TPsoft.org 2000-2025
|
|
file for controlers/*.php
|
|
|
|
Milestones:
|
|
2025-09-30 22:49 Created
|
|
*/
|
|
|
|
namespace TPsoft\BugreportBackend\Models;
|
|
|
|
class Attachments extends \TPsoft\DBmodel\DBmodel {
|
|
|
|
public $tables = array(
|
|
'attachments' => array(
|
|
'name' => 'attachments',
|
|
'primary_key_name' => 'attachment_id',
|
|
'allow_attributes' => array(
|
|
'report_id' => 'INTEGER',
|
|
'attachment_type' => 'VARCHAR(255)',
|
|
'attachment_content' => 'TEXT',
|
|
'created_dt' => 'DATETIME',
|
|
'updated_dt' => 'DATETIME'
|
|
)
|
|
),
|
|
);
|
|
|
|
public function exist($primary_key = null) {
|
|
return $this->existRecord('attachments', $primary_key);
|
|
}
|
|
|
|
public function attachment($primary_key = null, $data = array()) {
|
|
if (is_null($primary_key)
|
|
&& !isset($data['created_dt']))
|
|
{
|
|
$data['created_dt'] = date('Y-m-d H:i:s');
|
|
}
|
|
return $this->record('attachments', $primary_key, $data);
|
|
}
|
|
|
|
public function attachmentBy($colname, $colvalue) {
|
|
return $this->recordBy('attachments', $colname, $colvalue);
|
|
}
|
|
|
|
public function attachmentSave($data = array()) {
|
|
return $this->attachment($this->exist($data) ? $data : null, $data);
|
|
}
|
|
|
|
public function attachmentEmpty() {
|
|
return $this->recordEmpty('attachments');
|
|
}
|
|
|
|
public function attachmentAttributes() {
|
|
return $this->typesAttributes('attachments');
|
|
}
|
|
|
|
public function attachmentCount() {
|
|
return $this->count('attachments');
|
|
}
|
|
|
|
public function getList($search = array(), $reverse = false, $concat_or = false) {
|
|
return $this->search('attachments')
|
|
->where($search, $concat_or)
|
|
->order(array('attachment_id' => $reverse ? 'DESC' : 'ASC'))
|
|
->toArray();
|
|
}
|
|
|
|
public function getListOrganize($cola_name, $search = array(), $reverse = false, $concat_or = false) {
|
|
$all = $this->getList($search, $reverse, $concat_or);
|
|
$ret = array();
|
|
if (is_array($all)) foreach ($all as $key => $row) {
|
|
$ret[$row[$cola_name]] = $row;
|
|
}
|
|
return $ret;
|
|
}
|
|
|
|
public function getListByID($search = array(), $reverse = false, $concat_or = false) {
|
|
return $this->getListOrganize('attachment_id', $search, $reverse, $concat_or);
|
|
}
|
|
|
|
public function attachmentCombo($col_key, $col_value, $add_empty = false) {
|
|
return $this->search('attachments')
|
|
->toCombo($col_key, $col_value, $add_empty);
|
|
}
|
|
|
|
}
|
|
|
|
?>
|