MCPcopy
hub / github.com/gogf/gf / Page

Method Page

database/gdb/gdb_model_select.go:677–688  ·  view source on GitHub ↗

Page sets the paging number for the model. The parameter `page` is started from 1 for paging. Note that, it differs that the Limit function starts from 0 for "LIMIT" statement. Note: Negative limit values are treated as zero.

(page, limit int)

Source from the content-addressed store, hash-verified

675// Note that, it differs that the Limit function starts from 0 for "LIMIT" statement.
676// Note: Negative limit values are treated as zero.
677func (m *Model) Page(page, limit int) *Model {
678 model := m.getModel()
679 if page <= 0 {
680 page = 1
681 }
682 if limit < 0 {
683 limit = 0
684 }
685 model.start = (page - 1) * limit
686 model.limit = limit
687 return model
688}
689
690// Having sets the having statement for the model.
691// The parameters of this function usage are as the same as function Where.

Callers 15

Test_Issue4699Function · 0.95
Test_Model_SafeFunction · 0.80
Test_Model_AllAndCountFunction · 0.80
Test_Model_CountFunction · 0.80
Test_Model_ScanAndCountFunction · 0.80
Test_Model_PageFunction · 0.80
Test_Model_HandlerFunction · 0.80
Test_DB_QueryFunction · 0.80
Test_Model_HandlerFunction · 0.80
Test_Model_SafeFunction · 0.80
Test_Model_CountFunction · 0.80
Test_Model_PageFunction · 0.80

Calls 1

getModelMethod · 0.95

Tested by 15

Test_Issue4699Function · 0.76
Test_Model_SafeFunction · 0.64
Test_Model_AllAndCountFunction · 0.64
Test_Model_CountFunction · 0.64
Test_Model_ScanAndCountFunction · 0.64
Test_Model_PageFunction · 0.64
Test_Model_HandlerFunction · 0.64
Test_DB_QueryFunction · 0.64
Test_Model_HandlerFunction · 0.64
Test_Model_SafeFunction · 0.64
Test_Model_CountFunction · 0.64
Test_Model_PageFunction · 0.64