$filter, ... ). ie: array( 'id' => 1, ... ) * @param array $order Sort order passed to SQL in format of array( $column => 'asc', 'name' => 'desc', ... ). ie: array( 'id' => 'asc', 'name' => 'desc', ... ) * @return $this */ function getAll( $limit = null, $page = null, $where = null, $order = null ) { $query = ' select * from ' . $this->getTable() . ' '; $query .= $this->getWhereSQL( $where ); $query .= $this->getSortSQL( $order ); $this->rs = $this->ExecuteSQL( $query, null, $limit, $page ); return $this; } /** * @param string $id UUID * @param array $where Additional SQL WHERE clause in format of array( $column => $filter, ... ). ie: array( 'id' => 1, ... ) * @param array $order Sort order passed to SQL in format of array( $column => 'asc', 'name' => 'desc', ... ). ie: array( 'id' => 'asc', 'name' => 'desc', ... ) * @return bool|UserSettingListFactory */ function getById( $id, $where = null, $order = null ) { if ( $id == '' ) { return false; } $ph = [ 'id' => TTUUID::castUUID( $id ), ]; $query = ' select * from ' . $this->getTable() . ' where id = ? '; $query .= $this->getWhereSQL( $where ); $query .= $this->getSortSQL( $order ); $this->rs = $this->ExecuteSQL( $query, $ph ); return $this; } /** * @param string $company_id UUID * @param array $where Additional SQL WHERE clause in format of array( $column => $filter, ... ). ie: array( 'id' => 1, ... ) * @param array $order Sort order passed to SQL in format of array( $column => 'asc', 'name' => 'desc', ... ). ie: array( 'id' => 'asc', 'name' => 'desc', ... ) * @return bool|UserSettingListFactory */ function getByCompanyId( $company_id, $where = null, $order = null ) { if ( $company_id == '' ) { return false; } $uf = new UserFactory(); $ph = [ 'company_id' => TTUUID::castUUID( $company_id ), ]; $query = ' select a.* from ' . $this->getTable() . ' as a LEFT JOIN ' . $uf->getTable() . ' as uf ON a.user_id = uf.id where uf.company_id = ? AND ( uf.deleted = 0 )'; $query .= $this->getWhereSQL( $where ); $query .= $this->getSortSQL( $order ); $this->rs = $this->ExecuteSQL( $query, $ph ); return $this; } /** * @param string $user_id UUID * @param $name * @return bool|UserSettingListFactory */ function getByUserIdAndName( $user_id, $name ) { if ( $user_id == '' ) { return false; } if ( $name == '' ) { return false; } $cache_id = $user_id . $name; $this->rs = $this->getCache( $cache_id ); if ( $this->rs === false ) { $ph = [ 'user_id' => TTUUID::castUUID( $user_id ), 'name' => $name, ]; $query = ' select * from ' . $this->getTable() . ' where user_id = ? AND name = ? AND deleted = 0'; $this->rs = $this->ExecuteSQL( $query, $ph ); $this->saveCache( $this->rs, $cache_id ); } return $this; } } ?>