ผมหาทางติดตั้ง Smarty 3.1.7 เพื่อให้ใช้งานได้กับ CodeIgniter 2.1.0 ได้ โดยมีขั้นดังนี้
ดาวน์โหลดและติดตั้ง CodeIgniter ตามปกติ การติดตั้ง Smarty จะดำเนินการโดยใช้ Ci-Smarty ที่พัฒนาขึ้นโดยคุณ Dwayne Charrington ให้ดาวน์โหลดและติดตั้งลงใน CodeIgniter ในข้อ 1. แล้วให้ทำการทดสอบว่าสามารถใช้งาน Smarty ได้จริง เนื่องจากในขณะที่เขียนบทความนี้ Smarty ที่ิติดตั้งใน Ci-Smarty เป็นเวอร์ชัน 3.1.1 เราจึงต้องมีการแก้ไขปรับแก้ไฟล์ โดยโครงสร้างไฟล์ของ Ci-Smarty มีดังภาพข้างล่างนี้
เราต้องปรับแก้ 3 [...]
Object-relational mapping (ORM, O/RM, and O/R mapping) in computer software is a programming technique for converting data between incompatible type systems in relational databases and object-oriented programming languages.
From: http://en.wikipedia.org/wiki/Object-relational_mapping
หากมีเวลาก็ทดลองใช้งาน ORM ต่างๆ ได้
DataMapper OverZealous Edition (DMZ) Doctrine (CodeIgniter and Doctrin Tutorial) RapidDataMapper
ผมใช้ CodeIginter แล้วเจอ error เกี่ยวกับ session library แบบนี้
A PHP Error was encountered Severity: 4096 Message: Object of class stdClass could not be converted to string Filename: libraries/Session.php Line Number: 715
ลองค้นดูในเน็ตแล้วพบว่าเป็นบั๊กของ session เกี่ยวกับ object storage วิธีการแก้ที่
http://codeigniter.com/forums/viewthread/95690/P0/
โดยให้แก้ไฟล์ system/libraries/Session.php ที่บรรทัด 683 และ 714 จาก
$data[$key] = str_replace(‘\’, ‘{{slash}}’, $val);
ให้่เป็น
if(!is_object($val)) $data[$key] = str_replace(‘{{slash}}’, ’\', $val);
Codeiginer มี pagination class เพื่อช่วยในการจัดแบ่งข้อมูลที่จะนำแสดงบนเว็บ โดยผู้ใช้สามารถกำหนดได้ว่าในแต่ละหน้านั้น จะให้แสดงจำนวนข้อมูลจำนวนเท่าใด โดยจะมีการทำลิ้งก์ให้เลือกหน้าถัดไปหรือย้อนหลังให้อัตโนมัติ เช่น
ตัวอย่างการใช้งาน
$this->load->library(‘pagination’); $config['base_url'] = ‘http://example.com/index.php/test/page/’; $config['total_rows'] = ’200′; $config['per_page'] = ’20′; $this->pagination->initialize($config); echo $this->pagination->create_links();
องค์ประกอบเบื้องต้น
ตัวแปร $config จากตัวอย่างข้างต้น ใช้ในการกำหนดองค์ประกอบที่ต้องการ โดยสามารถสร้างไฟล์สำหรับเก็บตัวแปร $config ชื่อ pagination.php แยกไว้ต่างหาก [...]
Tags
.htaccess Apache blogspot CentOS codeigniter CSS domain name driver Drupal Flickr Hotmail HTML internet law linux mailing list mailman MICT mod_rewrite monitor MSL MySQL name server Network open source PHP Postfix Security Smarty sony Spammail SPF theme TLS traffic log Universiade UTF-8 UTF8 vbulletin Wordpress การเมือง จตุคาม รูปภาพ สถิติ เรารักในหลวง
