. */ namespace SP\Services\UserProfile; use SP\DataModel\ItemSearchData; use SP\DataModel\ProfileBaseData; use SP\Services\Service; use SP\Services\ServiceItemInterface; use SP\Services\ServiceItemTrait; use SP\Storage\DbWrapper; use SP\Storage\QueryData; /** * Class UserProfileService * * @package SP\Services\UserProfile */ class UserProfileService extends Service implements ServiceItemInterface { use ServiceItemTrait; /** * Creates an item * * @return mixed */ public function create() { // TODO: Implement create() method. } /** * Updates an item * * @param $id * @return mixed */ public function update($id) { // TODO: Implement update() method. } /** * Deletes an item * * @param $id * @return mixed */ public function delete($id) { // TODO: Implement delete() method. } /** * Returns the item for given id * * @param int $id * @return mixed */ public function getById($id) { // TODO: Implement getById() method. } /** * Returns all the items * * @return mixed */ public function getAll() { $query = /** @lang SQL */ 'SELECT userprofile_id, userprofile_name FROM usrProfiles ORDER BY userprofile_name'; $Data = new QueryData(); $Data->setMapClassName(ProfileBaseData::class); $Data->setQuery($query); return DbWrapper::getResultsArray($Data); } /** * Returns all the items for given ids * * @param array $ids * @return array */ public function getByIdBatch(array $ids) { // TODO: Implement getByIdBatch() method. } /** * Deletes all the items for given ids * * @param array $ids * @return $this */ public function deleteByIdBatch(array $ids) { // TODO: Implement deleteByIdBatch() method. } /** * Checks whether the item is in use or not * * @param $id int * @return bool */ public function checkInUse($id) { // TODO: Implement checkInUse() method. } /** * Checks whether the item is duplicated on updating * * @return bool */ public function checkDuplicatedOnUpdate() { // TODO: Implement checkDuplicatedOnUpdate() method. } /** * Checks whether the item is duplicated on adding * * @return bool */ public function checkDuplicatedOnAdd() { // TODO: Implement checkDuplicatedOnAdd() method. } /** * Searches for items by a given filter * * @param ItemSearchData $SearchData * @return mixed */ public function search(ItemSearchData $SearchData) { $Data = new QueryData(); $Data->setSelect('userprofile_id, userprofile_name'); $Data->setFrom('usrProfiles'); $Data->setOrder('userprofile_name'); if ($SearchData->getSeachString() !== '') { $Data->setWhere('userprofile_name LIKE ?'); $search = '%' . $SearchData->getSeachString() . '%'; $Data->addParam($search); } $Data->setLimit('?,?'); $Data->addParam($SearchData->getLimitStart()); $Data->addParam($SearchData->getLimitCount()); DbWrapper::setFullRowCount(); $queryRes = DbWrapper::getResultsArray($Data); $queryRes['count'] = $Data->getQueryNumRows(); return $queryRes; } }