| Model หน้าจำนวนแถว ข้อมูลทั้งหมด |
|
|
|
| Tuesday, 20 January 2009 13:01 | |
|
ตอนที่เราสร้าง class? Model ของ แต่ละ Compent จะ extends JModel ซึ่งใน JModel จะมีการติดต่อกับฐานข้อมูลไว้อยู่แล้วเราสามารถใช้งาน method เกี่ยวกับฐานข้อมูลได้ เช่น ต้องการนับจำนวนข้อมูลทั้งหมด ??? function getTotal() ??? { ??? ??? if(empty($this->_total)) { ??? ??? ??? $query = "SELECT COUNT(*) as m_total FROM member " . $where; ??? ??? ??? $o_sum = $this->_getList($query); ??? ??? ??? $this->_total = $o_sum[0]->m_total; ??? ??? } ??? ??? return $this->_total; ??? } เท่านี้เราก็ได้ จำนวนแถวทั้งหมดเพื่อ เอามาแสดง ใน view หรือ จะเอาไปแบ่งหน้า ต่อใน method อื่นๆ ของ Modelนี้ได้ ข้อสังเกตุ ไม่ควรใช้ $query = "SELECT * FROM tb " แล้ว $this->_getListCount($query); สำหรับ ข้อมูลเยอะๆ นะครับ จำทำให้ ทำงานช้าและ เปลือง ram มาก |
Latest News
- A-1 Skyraider
- Top 50 Fastest Aircraft
- Federal Aviation Administration (FAA)
- The United States' air traffic control system is the safest in the world.
- ANTONOV 225 เครื่องบินที่ใหญ่ที่สุดในโลก
- Add Javascript to JHTML genericlist booleanlist
- Show messages notices error form Componet
- JAS 39 Gripen
- JPATH_COMPONENT Site Administrator component
- radiolist From Database
- 304 Industrial Park 2 Co., Ltd.
- A&P Siam Neo Group PCL.
- 3M Thailand Ltd.
- A. Bill. Art. Industrial Co.,Ltd.
- A-Tech Metal Works Co.,Ltd.
Latestnews
Autos Motor
| Autos |
| Autos |
![]() |
|



