public static function save(\Rebond\Core\ModelInterface $model) { $db = new Util\Data(); if ($model->getId() === 0) { $query = 'INSERT INTO core_user (`username`, `email`, `password`, `firstname`, `lastname`, avatar_id, `is_admin`, `is_dev`, `status`, `created_date`, `modified_date`) VALUES (?,?,?,?,?,?,?,?,?,?,?)'; $params = [$model->getUsername(), $model->getEmail(), $model->getPassword(), $model->getFirstname(), $model->getLastname(), $model->getAvatarId(), $model->getIsAdmin(), $model->getIsDev(), $model->getStatus(), $model->getCreatedDate('sqlDatetime'), Util\Format::date(time(), 'sqlDatetime')]; $id = $db->execute($query, $params); $model->setId($id); return $id; } else { $query = 'UPDATE core_user SET '; $params = []; if ($model->getUsername() !== null) { $query .= '`username` = ?, '; $params[] = $model->getUsername(); } if ($model->getEmail() !== null) { $query .= '`email` = ?, '; $params[] = $model->getEmail(); } if ($model->getPassword() !== null) { $query .= '`password` = ?, '; $params[] = $model->getPassword(); } if ($model->getFirstname() !== null) { $query .= '`firstname` = ?, '; $params[] = $model->getFirstname(); } if ($model->getLastname() !== null) { $query .= '`lastname` = ?, '; $params[] = $model->getLastname(); } if ($model->getAvatarId() !== null) { $query .= 'avatar_id = ?, '; $params[] = $model->getAvatarId(); } if ($model->getIsAdmin() !== null) { $query .= '`is_admin` = ?, '; $params[] = $model->getIsAdmin(); } if ($model->getIsDev() !== null) { $query .= '`is_dev` = ?, '; $params[] = $model->getIsDev(); } if ($model->getStatus() !== null) { $query .= '`status` = ?, '; $params[] = $model->getStatus(); } $query .= '`modified_date` = ?, '; $params[] = Util\Format::date(time(), 'sqlDatetime'); $query = rtrim(trim($query), ','); $query .= ' WHERE id = ?'; $params[] = $model->getId(); return $db->execute($query, $params); } }
public static function save(\Rebond\Core\ModelInterface $model) { $db = new Util\Data(); if ($model->getId() === 0) { $query = 'INSERT INTO cms_gadget (page_id, component_id, `col`, filter_id, `custom_filter`, `display_order`, `status`, `created_date`, `modified_date`) VALUES (?,?,?,?,?,?,?,?,?)'; $params = [$model->getPageId(), $model->getComponentId(), $model->getCol(), $model->getFilterId(), $model->getCustomFilter(), $model->getDisplayOrder(), $model->getStatus(), $model->getCreatedDate('sqlDatetime'), Util\Format::date(time(), 'sqlDatetime')]; $id = $db->execute($query, $params); $model->setId($id); return $id; } else { $query = 'UPDATE cms_gadget SET '; $params = []; if ($model->getPageId() !== null) { $query .= 'page_id = ?, '; $params[] = $model->getPageId(); } if ($model->getComponentId() !== null) { $query .= 'component_id = ?, '; $params[] = $model->getComponentId(); } if ($model->getCol() !== null) { $query .= '`col` = ?, '; $params[] = $model->getCol(); } if ($model->getFilterId() !== null) { $query .= 'filter_id = ?, '; $params[] = $model->getFilterId(); } if ($model->getCustomFilter() !== null) { $query .= '`custom_filter` = ?, '; $params[] = $model->getCustomFilter(); } if ($model->getDisplayOrder() !== null) { $query .= '`display_order` = ?, '; $params[] = $model->getDisplayOrder(); } if ($model->getStatus() !== null) { $query .= '`status` = ?, '; $params[] = $model->getStatus(); } $query .= '`modified_date` = ?, '; $params[] = Util\Format::date(time(), 'sqlDatetime'); $query = rtrim(trim($query), ','); $query .= ' WHERE id = ?'; $params[] = $model->getId(); return $db->execute($query, $params); } }
public static function save(\Rebond\Core\ModelInterface $model) { $db = new Util\Data(); if ($model->getId() === 0) { $query = 'INSERT INTO core_log (`code`, user_id, `ip`, `request_uri`, `referer`, `message`, `trace`, `file`, `line`, `status`, `created_date`, `modified_date`) VALUES (?,?,?,?,?,?,?,?,?,?,?,?)'; $params = [$model->getCode(), $model->getUserId(), $model->getIp(), $model->getRequestUri(), $model->getReferer(), $model->getMessage(), $model->getTrace(), $model->getFile(), $model->getLine(), $model->getStatus(), $model->getCreatedDate('sqlDatetime'), Util\Format::date(time(), 'sqlDatetime')]; $id = $db->execute($query, $params); $model->setId($id); return $id; } else { $query = 'UPDATE core_log SET '; $params = []; if ($model->getCode() !== null) { $query .= '`code` = ?, '; $params[] = $model->getCode(); } if ($model->getUserId() !== null) { $query .= 'user_id = ?, '; $params[] = $model->getUserId(); } if ($model->getIp() !== null) { $query .= '`ip` = ?, '; $params[] = $model->getIp(); } if ($model->getRequestUri() !== null) { $query .= '`request_uri` = ?, '; $params[] = $model->getRequestUri(); } if ($model->getReferer() !== null) { $query .= '`referer` = ?, '; $params[] = $model->getReferer(); } if ($model->getMessage() !== null) { $query .= '`message` = ?, '; $params[] = $model->getMessage(); } if ($model->getTrace() !== null) { $query .= '`trace` = ?, '; $params[] = $model->getTrace(); } if ($model->getFile() !== null) { $query .= '`file` = ?, '; $params[] = $model->getFile(); } if ($model->getLine() !== null) { $query .= '`line` = ?, '; $params[] = $model->getLine(); } if ($model->getStatus() !== null) { $query .= '`status` = ?, '; $params[] = $model->getStatus(); } $query .= '`modified_date` = ?, '; $params[] = Util\Format::date(time(), 'sqlDatetime'); $query = rtrim(trim($query), ','); $query .= ' WHERE id = ?'; $params[] = $model->getId(); return $db->execute($query, $params); } }
public static function save(\Rebond\Core\ModelInterface $model) { $db = new Util\Data(); if ($model->getId() === 0) { $query = 'INSERT INTO cms_module (`title`, `summary`, `workflow`, `has_filter`, `has_content`, `status`, `created_date`, `modified_date`) VALUES (?,?,?,?,?,?,?,?)'; $params = [$model->getTitle(), $model->getSummary(), $model->getWorkflow(), $model->getHasFilter(), $model->getHasContent(), $model->getStatus(), $model->getCreatedDate('sqlDatetime'), Util\Format::date(time(), 'sqlDatetime')]; $id = $db->execute($query, $params); $model->setId($id); return $id; } else { $query = 'UPDATE cms_module SET '; $params = []; if ($model->getTitle() !== null) { $query .= '`title` = ?, '; $params[] = $model->getTitle(); } if ($model->getSummary() !== null) { $query .= '`summary` = ?, '; $params[] = $model->getSummary(); } if ($model->getWorkflow() !== null) { $query .= '`workflow` = ?, '; $params[] = $model->getWorkflow(); } if ($model->getHasFilter() !== null) { $query .= '`has_filter` = ?, '; $params[] = $model->getHasFilter(); } if ($model->getHasContent() !== null) { $query .= '`has_content` = ?, '; $params[] = $model->getHasContent(); } if ($model->getStatus() !== null) { $query .= '`status` = ?, '; $params[] = $model->getStatus(); } $query .= '`modified_date` = ?, '; $params[] = Util\Format::date(time(), 'sqlDatetime'); $query = rtrim(trim($query), ','); $query .= ' WHERE id = ?'; $params[] = $model->getId(); return $db->execute($query, $params); } }
public static function save(\Rebond\Core\ModelInterface $model) { $db = new Util\Data(); if ($model->getId() === 0) { $query = 'INSERT INTO core_media (folder_id, `title`, `tags`, `upload`, `original_filename`, `path`, `extension`, `mime_type`, `file_size`, `width`, `height`, `alt`, `is_selectable`, `status`, `created_date`, `modified_date`) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)'; $params = [$model->getFolderId(), $model->getTitle(), $model->getTags(), $model->getUpload(), $model->getOriginalFilename(), $model->getPath(), $model->getExtension(), $model->getMimeType(), $model->getFileSize(), $model->getWidth(), $model->getHeight(), $model->getAlt(), $model->getIsSelectable(), $model->getStatus(), $model->getCreatedDate('sqlDatetime'), Util\Format::date(time(), 'sqlDatetime')]; $id = $db->execute($query, $params); $model->setId($id); return $id; } else { $query = 'UPDATE core_media SET '; $params = []; if ($model->getFolderId() !== null) { $query .= 'folder_id = ?, '; $params[] = $model->getFolderId(); } if ($model->getTitle() !== null) { $query .= '`title` = ?, '; $params[] = $model->getTitle(); } if ($model->getTags() !== null) { $query .= '`tags` = ?, '; $params[] = $model->getTags(); } if ($model->getUpload() !== null) { $query .= '`upload` = ?, '; $params[] = $model->getUpload(); } if ($model->getOriginalFilename() !== null) { $query .= '`original_filename` = ?, '; $params[] = $model->getOriginalFilename(); } if ($model->getPath() !== null) { $query .= '`path` = ?, '; $params[] = $model->getPath(); } if ($model->getExtension() !== null) { $query .= '`extension` = ?, '; $params[] = $model->getExtension(); } if ($model->getMimeType() !== null) { $query .= '`mime_type` = ?, '; $params[] = $model->getMimeType(); } if ($model->getFileSize() !== null) { $query .= '`file_size` = ?, '; $params[] = $model->getFileSize(); } if ($model->getWidth() !== null) { $query .= '`width` = ?, '; $params[] = $model->getWidth(); } if ($model->getHeight() !== null) { $query .= '`height` = ?, '; $params[] = $model->getHeight(); } if ($model->getAlt() !== null) { $query .= '`alt` = ?, '; $params[] = $model->getAlt(); } if ($model->getIsSelectable() !== null) { $query .= '`is_selectable` = ?, '; $params[] = $model->getIsSelectable(); } if ($model->getStatus() !== null) { $query .= '`status` = ?, '; $params[] = $model->getStatus(); } $query .= '`modified_date` = ?, '; $params[] = Util\Format::date(time(), 'sqlDatetime'); $query = rtrim(trim($query), ','); $query .= ' WHERE id = ?'; $params[] = $model->getId(); return $db->execute($query, $params); } }
public static function save(\Rebond\Core\ModelInterface $model) { $db = new Util\Data(); if ($model->getId() === 0) { $query = 'INSERT INTO cms_content (module_id, `app_id`, `content_group`, filter_id, author_id, publisher_id, `title`, `url_friendly_title`, `use_expiration`, `go_live_date`, `expiry_date`, `published_date`, `version`, `created_date`, `modified_date`) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)'; $params = [$model->getModuleId(), $model->getAppId(), $model->getContentGroup(), $model->getFilterId(), $model->getAuthorId(), $model->getPublisherId(), $model->getTitle(), $model->getUrlFriendlyTitle(), $model->getUseExpiration(), $model->getGoLiveDate('sqlDatetime'), $model->getExpiryDate('sqlDatetime'), $model->getPublishedDate('sqlDatetime'), $model->getVersion(), $model->getCreatedDate('sqlDatetime'), Util\Format::date(time(), 'sqlDatetime')]; $id = $db->execute($query, $params); $model->setId($id); return $id; } else { $query = 'UPDATE cms_content SET '; $params = []; if ($model->getModuleId() !== null) { $query .= 'module_id = ?, '; $params[] = $model->getModuleId(); } if ($model->getAppId() !== null) { $query .= '`app_id` = ?, '; $params[] = $model->getAppId(); } if ($model->getContentGroup() !== null) { $query .= '`content_group` = ?, '; $params[] = $model->getContentGroup(); } if ($model->getFilterId() !== null) { $query .= 'filter_id = ?, '; $params[] = $model->getFilterId(); } if ($model->getAuthorId() !== null) { $query .= 'author_id = ?, '; $params[] = $model->getAuthorId(); } if ($model->getPublisherId() !== null) { $query .= 'publisher_id = ?, '; $params[] = $model->getPublisherId(); } if ($model->getTitle() !== null) { $query .= '`title` = ?, '; $params[] = $model->getTitle(); } if ($model->getUrlFriendlyTitle() !== null) { $query .= '`url_friendly_title` = ?, '; $params[] = $model->getUrlFriendlyTitle(); } if ($model->getUseExpiration() !== null) { $query .= '`use_expiration` = ?, '; $params[] = $model->getUseExpiration(); } if ($model->getGoLiveDate() !== null) { $query .= '`go_live_date` = ?, '; $params[] = $model->getGoLiveDate('sqlDatetime'); } if ($model->getExpiryDate() !== null) { $query .= '`expiry_date` = ?, '; $params[] = $model->getExpiryDate('sqlDatetime'); } if ($model->getPublishedDate() !== null) { $query .= '`published_date` = ?, '; $params[] = $model->getPublishedDate('sqlDatetime'); } if ($model->getVersion() !== null) { $query .= '`version` = ?, '; $params[] = $model->getVersion(); } $query .= '`modified_date` = ?, '; $params[] = Util\Format::date(time(), 'sqlDatetime'); $query = rtrim(trim($query), ','); $query .= ' WHERE id = ?'; $params[] = $model->getId(); return $db->execute($query, $params); } }
public static function save(\Rebond\Core\ModelInterface $model) { $db = new Util\Data(); if ($model->getId() === 0) { $query = 'INSERT INTO cms_page (parent_id, template_id, layout_id, `title`, `css`, `js`, `in_nav_header`, `in_nav_side`, `in_sitemap`, `in_breadcrumb`, `in_nav_footer`, `friendly_url_path`, `friendly_url`, `redirect`, `class`, `permission`, `display_order`, `status`, `created_date`, `modified_date`) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)'; $params = [$model->getParentId(), $model->getTemplateId(), $model->getLayoutId(), $model->getTitle(), $model->getCss(), $model->getJs(), $model->getInNavHeader(), $model->getInNavSide(), $model->getInSitemap(), $model->getInBreadcrumb(), $model->getInNavFooter(), $model->getFriendlyUrlPath(), $model->getFriendlyUrl(), $model->getRedirect(), $model->getClass(), $model->getPermission(), $model->getDisplayOrder(), $model->getStatus(), $model->getCreatedDate('sqlDatetime'), Util\Format::date(time(), 'sqlDatetime')]; $id = $db->execute($query, $params); $model->setId($id); return $id; } else { $query = 'UPDATE cms_page SET '; $params = []; if ($model->getParentId() !== null) { $query .= 'parent_id = ?, '; $params[] = $model->getParentId(); } if ($model->getTemplateId() !== null) { $query .= 'template_id = ?, '; $params[] = $model->getTemplateId(); } if ($model->getLayoutId() !== null) { $query .= 'layout_id = ?, '; $params[] = $model->getLayoutId(); } if ($model->getTitle() !== null) { $query .= '`title` = ?, '; $params[] = $model->getTitle(); } if ($model->getCss() !== null) { $query .= '`css` = ?, '; $params[] = $model->getCss(); } if ($model->getJs() !== null) { $query .= '`js` = ?, '; $params[] = $model->getJs(); } if ($model->getInNavHeader() !== null) { $query .= '`in_nav_header` = ?, '; $params[] = $model->getInNavHeader(); } if ($model->getInNavSide() !== null) { $query .= '`in_nav_side` = ?, '; $params[] = $model->getInNavSide(); } if ($model->getInSitemap() !== null) { $query .= '`in_sitemap` = ?, '; $params[] = $model->getInSitemap(); } if ($model->getInBreadcrumb() !== null) { $query .= '`in_breadcrumb` = ?, '; $params[] = $model->getInBreadcrumb(); } if ($model->getInNavFooter() !== null) { $query .= '`in_nav_footer` = ?, '; $params[] = $model->getInNavFooter(); } if ($model->getFriendlyUrlPath() !== null) { $query .= '`friendly_url_path` = ?, '; $params[] = $model->getFriendlyUrlPath(); } if ($model->getFriendlyUrl() !== null) { $query .= '`friendly_url` = ?, '; $params[] = $model->getFriendlyUrl(); } if ($model->getRedirect() !== null) { $query .= '`redirect` = ?, '; $params[] = $model->getRedirect(); } if ($model->getClass() !== null) { $query .= '`class` = ?, '; $params[] = $model->getClass(); } if ($model->getPermission() !== null) { $query .= '`permission` = ?, '; $params[] = $model->getPermission(); } if ($model->getDisplayOrder() !== null) { $query .= '`display_order` = ?, '; $params[] = $model->getDisplayOrder(); } if ($model->getStatus() !== null) { $query .= '`status` = ?, '; $params[] = $model->getStatus(); } $query .= '`modified_date` = ?, '; $params[] = Util\Format::date(time(), 'sqlDatetime'); $query = rtrim(trim($query), ','); $query .= ' WHERE id = ?'; $params[] = $model->getId(); return $db->execute($query, $params); } }
public static function save(\Rebond\Core\ModelInterface $model) { $db = new Util\Data(); if ($model->getId() === 0) { $query = 'INSERT INTO core_site (`title`, `google_analytics`, `keywords`, `description`, `css`, `js`, `sign_in_url`, `environment`, `sql_log`, `timezone`, `is_cms`, `cache_time`, `use_device_template`, `skin`, `send_mail_on_error`, `mail_list_on_error`, `status`, `created_date`, `modified_date`) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)'; $params = [$model->getTitle(), $model->getGoogleAnalytics(), $model->getKeywords(), $model->getDescription(), $model->getCss(), $model->getJs(), $model->getSignInUrl(), $model->getEnvironment(), $model->getSqlLog(), $model->getTimezone(), $model->getIsCms(), $model->getCacheTime(), $model->getUseDeviceTemplate(), $model->getSkin(), $model->getSendMailOnError(), $model->getMailListOnError(), $model->getStatus(), $model->getCreatedDate('sqlDatetime'), Util\Format::date(time(), 'sqlDatetime')]; $id = $db->execute($query, $params); $model->setId($id); return $id; } else { $query = 'UPDATE core_site SET '; $params = []; if ($model->getTitle() !== null) { $query .= '`title` = ?, '; $params[] = $model->getTitle(); } if ($model->getGoogleAnalytics() !== null) { $query .= '`google_analytics` = ?, '; $params[] = $model->getGoogleAnalytics(); } if ($model->getKeywords() !== null) { $query .= '`keywords` = ?, '; $params[] = $model->getKeywords(); } if ($model->getDescription() !== null) { $query .= '`description` = ?, '; $params[] = $model->getDescription(); } if ($model->getCss() !== null) { $query .= '`css` = ?, '; $params[] = $model->getCss(); } if ($model->getJs() !== null) { $query .= '`js` = ?, '; $params[] = $model->getJs(); } if ($model->getSignInUrl() !== null) { $query .= '`sign_in_url` = ?, '; $params[] = $model->getSignInUrl(); } if ($model->getEnvironment() !== null) { $query .= '`environment` = ?, '; $params[] = $model->getEnvironment(); } if ($model->getSqlLog() !== null) { $query .= '`sql_log` = ?, '; $params[] = $model->getSqlLog(); } if ($model->getTimezone() !== null) { $query .= '`timezone` = ?, '; $params[] = $model->getTimezone(); } if ($model->getIsCms() !== null) { $query .= '`is_cms` = ?, '; $params[] = $model->getIsCms(); } if ($model->getCacheTime() !== null) { $query .= '`cache_time` = ?, '; $params[] = $model->getCacheTime(); } if ($model->getUseDeviceTemplate() !== null) { $query .= '`use_device_template` = ?, '; $params[] = $model->getUseDeviceTemplate(); } if ($model->getSkin() !== null) { $query .= '`skin` = ?, '; $params[] = $model->getSkin(); } if ($model->getSendMailOnError() !== null) { $query .= '`send_mail_on_error` = ?, '; $params[] = $model->getSendMailOnError(); } if ($model->getMailListOnError() !== null) { $query .= '`mail_list_on_error` = ?, '; $params[] = $model->getMailListOnError(); } if ($model->getStatus() !== null) { $query .= '`status` = ?, '; $params[] = $model->getStatus(); } $query .= '`modified_date` = ?, '; $params[] = Util\Format::date(time(), 'sqlDatetime'); $query = rtrim(trim($query), ','); $query .= ' WHERE id = ?'; $params[] = $model->getId(); return $db->execute($query, $params); } }
public static function save(\Rebond\Core\ModelInterface $model) { $db = new Util\Data(); if ($model->getId() === 0) { $query = 'INSERT INTO core_feedback (user_id, `title`, `type`, `description`, `status`, `created_date`, `modified_date`) VALUES (?,?,?,?,?,?,?)'; $params = [$model->getUserId(), $model->getTitle(), $model->getType(), $model->getDescription(), $model->getStatus(), $model->getCreatedDate('sqlDatetime'), Util\Format::date(time(), 'sqlDatetime')]; $id = $db->execute($query, $params); $model->setId($id); return $id; } else { $query = 'UPDATE core_feedback SET '; $params = []; if ($model->getUserId() !== null) { $query .= 'user_id = ?, '; $params[] = $model->getUserId(); } if ($model->getTitle() !== null) { $query .= '`title` = ?, '; $params[] = $model->getTitle(); } if ($model->getType() !== null) { $query .= '`type` = ?, '; $params[] = $model->getType(); } if ($model->getDescription() !== null) { $query .= '`description` = ?, '; $params[] = $model->getDescription(); } if ($model->getStatus() !== null) { $query .= '`status` = ?, '; $params[] = $model->getStatus(); } $query .= '`modified_date` = ?, '; $params[] = Util\Format::date(time(), 'sqlDatetime'); $query = rtrim(trim($query), ','); $query .= ' WHERE id = ?'; $params[] = $model->getId(); return $db->execute($query, $params); } }
public static function save(\Rebond\Core\ModelInterface $model) { $db = new Util\Data(); if ($model->getId() === 0) { $query = 'INSERT INTO core_user_security (user_id, `sign_in`, `secure`, `type`, `created_date`) VALUES (?,?,?,?,?)'; $params = [$model->getUserId(), $model->getSignIn(), $model->getSecure(), $model->getType(), $model->getCreatedDate('sqlDatetime')]; $id = $db->execute($query, $params); $model->setId($id); return $id; } else { $query = 'UPDATE core_user_security SET '; $params = []; if ($model->getUserId() !== null) { $query .= 'user_id = ?, '; $params[] = $model->getUserId(); } if ($model->getSignIn() !== null) { $query .= '`sign_in` = ?, '; $params[] = $model->getSignIn(); } if ($model->getSecure() !== null) { $query .= '`secure` = ?, '; $params[] = $model->getSecure(); } if ($model->getType() !== null) { $query .= '`type` = ?, '; $params[] = $model->getType(); } $query = rtrim(trim($query), ','); $query .= ' WHERE id = ?'; $params[] = $model->getId(); return $db->execute($query, $params); } }
public static function save(\Rebond\Core\ModelInterface $model) { $db = new Util\Data(); if ($model->getId() === 0) { $query = 'INSERT INTO cms_module_media (module_id, `field`, `status`, `created_date`, `modified_date`) VALUES (?,?,?,?,?)'; $params = [$model->getModuleId(), $model->getField(), $model->getStatus(), $model->getCreatedDate('sqlDatetime'), Util\Format::date(time(), 'sqlDatetime')]; $id = $db->execute($query, $params); $model->setId($id); return $id; } else { $query = 'UPDATE cms_module_media SET '; $params = []; if ($model->getModuleId() !== null) { $query .= 'module_id = ?, '; $params[] = $model->getModuleId(); } if ($model->getField() !== null) { $query .= '`field` = ?, '; $params[] = $model->getField(); } if ($model->getStatus() !== null) { $query .= '`status` = ?, '; $params[] = $model->getStatus(); } $query .= '`modified_date` = ?, '; $params[] = Util\Format::date(time(), 'sqlDatetime'); $query = rtrim(trim($query), ','); $query .= ' WHERE id = ?'; $params[] = $model->getId(); return $db->execute($query, $params); } }
public static function save(\Rebond\Core\ModelInterface $model) { $db = new Util\Data(); if ($model->getId() === 0) { $query = 'INSERT INTO cms_user_settings (user_id, `media_view`, `media_paging`, `content_paging`, `paging`) VALUES (?,?,?,?,?)'; $params = [$model->getUserId(), $model->getMediaView(), $model->getMediaPaging(), $model->getContentPaging(), $model->getPaging()]; $id = $db->execute($query, $params); $model->setId($id); return $id; } else { $query = 'UPDATE cms_user_settings SET '; $params = []; if ($model->getUserId() !== null) { $query .= 'user_id = ?, '; $params[] = $model->getUserId(); } if ($model->getMediaView() !== null) { $query .= '`media_view` = ?, '; $params[] = $model->getMediaView(); } if ($model->getMediaPaging() !== null) { $query .= '`media_paging` = ?, '; $params[] = $model->getMediaPaging(); } if ($model->getContentPaging() !== null) { $query .= '`content_paging` = ?, '; $params[] = $model->getContentPaging(); } if ($model->getPaging() !== null) { $query .= '`paging` = ?, '; $params[] = $model->getPaging(); } $query = rtrim(trim($query), ','); $query .= ' WHERE id = ?'; $params[] = $model->getId(); return $db->execute($query, $params); } }