public function store($data, $method = 'INSERT', $where = '') { $this->_clearErrors(); $method = strtoupper($method); if ($this->_escape) { $data = dbGmp::escape($data); } $query = ''; switch ($method) { case 'INSERT': $query = 'INSERT INTO '; if (isset($data[$this->_id]) && empty($data[$this->_id])) { unset($data[$this->_id]); } break; case 'UPDATE': $query = 'UPDATE '; break; } $fields = $this->_getQueryString($data, ',', true); if (empty($fields)) { $this->_addError(__('Nothig to update', GMP_LANG_CODE)); return false; } $query .= $this->_table . ' SET ' . $fields; if (!empty($this->_errors)) { return false; } if ($method == 'UPDATE' && !empty($where)) { $query .= ' WHERE ' . $this->_getQueryString($where, 'AND'); } if (dbGmp::query($query)) { if ($method == 'INSERT') { return dbGmp::lastID(); } else { return true; } } else { $this->_addError(GMP_TEST_MODE ? dbGmp::getError() : __('Database error. Please contact your developer.', GMP_LANG_CODE)); } return false; }
public function getListForTable() { $res = new responseGmp(); $res->ignoreShellData(); $count = $this->getModel()->getCount(); $listReqData = array('limitFrom' => reqGmp::getVar('iDisplayStart'), 'limitTo' => reqGmp::getVar('iDisplayLength')); $displayColumns = $this->getView()->getDisplayColumns(); $displayColumnsKeys = array_keys($displayColumns); $iSortCol = reqGmp::getVar('iSortCol_0'); if (!is_null($iSortCol) && is_numeric($iSortCol)) { $listReqData['orderBy'] = $displayColumns[$displayColumnsKeys[$iSortCol]]['db']; $iSortDir = reqGmp::getVar('sSortDir_0'); if (!is_null($iSortDir)) { $listReqData['orderBy'] .= ' ' . strtoupper($iSortDir); } } $search = reqGmp::getVar('sSearch'); if (!is_null($search) && !empty($search)) { $dbSearch = dbGmp::escape($search); $listReqData['additionalCondition'] = 'title LIKE "%' . $dbSearch . '%" OR description LIKE "%' . $dbSearch . '%"'; } $list = $this->getModel()->getAllMarkers($listReqData, true); $res->addData('aaData', $this->_convertDataForDatatable($list)); $res->addData('iTotalRecords', $count); $res->addData('iTotalDisplayRecords', $count); $res->addData('sEcho', reqGmp::getVar('sEcho')); $res->addMessage(__('Done')); return $res->ajaxExec(); }