Nếu chúng ta lưu trữ dữ liệu tạm thời trong các tham số của người sử dụng, chúng tôi chạy các nguy cơ tiết kiệm dữ liệu tình cờ ghi lại cơ sở dữ liệu của người vấn đề thiết kế phổ biến là phần mở rộng của người sử dụng vượt ra ngoài các thuộc tính được xác định trước của họ. | Chapter 8 We use the getUserStateFromRequest method to get the limit and limitstart variables. We use the user state variable to determine the limit. This variable is used throughout Joomla to determine the length of lists. For example if we were to view the Article Manager and select a limit if 5 items per page when we move to a different list it will also be limited to 5 items. If a value is set in the request value limit part of the listFooter we use that value. Alternatively we use the previous value and if that is not set we use the default value defined in the application configuration. The limitstart variable is retrieved from the user state value option plus .limitstart. option is the component name for example com_content. If we build a component that has multiple lists we should add an extra level to this normally named after the entity. If a value is set in the request value limitstart part of the listFooter we use that value. Alternatively we use the previous value and if that is not set we use the default value 0 which will lead us to the first page. At this stage you might be wondering why we handle this in the constructor and not the getPagination method. As well as using these values for the JPagination object we also need to use them when getting data from the database. Assuming we are using a method called getData to retrieve the itemized data our method might look like this Get itemized data @access public @return array function getData if empty this- _data query this- _buildQuery limitstart this- getState limitstart limit this- getState limit this- _data this- _getList query limitstart limit return this- _data 227 Rendering Output This method uses the private _buildQuery method that we discussed earlier. We get the object state variables limit and limitstart and pass them to the _getList method. The _getList method is used to get an array of objects from the database based on a query and optionally limit and limitstart. The .