| 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 มาก |
Autos Motor
| Univision: Autos |
| Autos nuevos y usados, fotos, videos y precios incluyendo el Kelley Blue Book de todos los Modelos 2008 como: BMW, Mercedes Benz, Jaguar, Ford, Chevrolet, Mazda, Volkswagen, Nissan, Toyota y muchas marcas mas. |
![]() |
|



