-
เรื่องล่าสุด
คลังเก็บ
- กุมภาพันธ์ 2021
- ธันวาคม 2020
- กรกฎาคม 2020
- มิถุนายน 2020
- กุมภาพันธ์ 2020
- มกราคม 2020
- มีนาคม 2015
- มกราคม 2015
- ธันวาคม 2014
- พฤศจิกายน 2014
- ตุลาคม 2014
- กันยายน 2014
- สิงหาคม 2014
- กรกฎาคม 2014
- มิถุนายน 2014
- พฤษภาคม 2014
- เมษายน 2014
- มีนาคม 2014
- กุมภาพันธ์ 2014
- มกราคม 2014
- ธันวาคม 2013
- พฤศจิกายน 2013
- ตุลาคม 2013
- กันยายน 2013
- สิงหาคม 2013
- กรกฎาคม 2013
- มิถุนายน 2013
- พฤษภาคม 2013
- เมษายน 2013
- มีนาคม 2013
- กุมภาพันธ์ 2013
- มกราคม 2013
- ธันวาคม 2012
- พฤศจิกายน 2012
- ตุลาคม 2012
Monthly Archives: มกราคม 2014
javascript eval function for jsonObject
สมมติว่า jsonObject เก็บค่ามาจากตัวแปร php ที่เป็น array ดังนี้ [cc lang=”php”] $data = array( ‘table1′ => array( ‘…’), ‘table2′ => array( ‘…’), … ); [/cc] ถ้าเรามีตัวแปร javascript ที่เก็บว่าเราจะเลือก table อะไรดี โดยได้ค่าที่ dynamic มาจากการที่ผู้ใช้ติดต่อกับฟอร์มทางหน้าเว็บ และเราจะต้อง loop เข้าไปหาข้อมูลใน table นั้นๆด้วยให้ทำดังนี้ [cc lang=”javascript] var tableName … Continue reading
Posted in knowledge
Leave a comment
laravel 4 database eloquent ORM
วิธีใช้งานอย่างง่าย Introduction Basic Usage Mass Assignment Insert, Update, Delete Soft Deleting Timestamps Query Scopes Relationships Querying Relations Eager Loading Inserting Related Models Touching Parent Timestamps Working With Pivot Tables Collections Accessors & Mutators Date Mutators Model Events Model Observers Converting … Continue reading
Posted in laravel4
Leave a comment
Laravel 4 Mass Assignment
การกำหนดชื่อฟิลด์ name ใน form ให้ตรงกับชื่อฟิลด์ในฐานข้อมูล และยิงลงฐานข้อมูลทั้งหมดทุกฟิลด์ ข้อดี : ลดการเขียนโค้ดใน controllers ที่ต้องมา match ฟิลด์เองจากค่าที่ส่งจาก form ช่องโหว่ : ถ้าใส่ input type hidden มาจะเกิดปัญหา วิธีแก้ : laravel แก้ด้วยการให้ใส่ชื่อฟิล์ดที่ยอมให้ใช้ได้ในตัวแปร $fillable ใน Model [cc lang=”php”] class User extends Eloquent implements UserInterface, RemindableInterface { protected $fiilable … Continue reading
Posted in laravel4
Leave a comment
laravel4 route controller
วันนี้ขอมาเสนอวิธีหนึ่งในการ Route แบบมีหลักการวิธีหนึ่งครับ [cc lang=”php”] //for member http://yourdomain.com/member/yourClassController Route::group(array(‘prefix’ => ‘member’),function(){ Route::controller(‘/account’,’AccountController’); Route::controller(‘/project’,’ProjectController’); Route::controller(‘/organizations’,’OrganizationController’); Route::controller(‘/auth’,’AuthController’); }); //for public page http://yourdomain.com/yourClassController Route::controller(‘/docs’,’DocsController’); Route::controller(‘/pricing’,’PricingController’); //**you must set rootClassController at last line Route::controller(‘/’,’MainController’); [/cc] จากตัวอย่างข้างต้น เราจะ ROUTE member group ไว้ที่เดียวกัน จะเป็นหน้าที่ต้อง LOGIN … Continue reading
Posted in laravel4
Leave a comment
laravel 4 unit test
1.install PHPUnit, add the following line to your composer.json file [cc]{ “require”: { “laravel/framework”: “4.1.*”, “phpunit/phpunit”: “3.7.*” } }[/cc] 2.run the composer update command to install the package: [cc]composer update[/cc] 3.Now that you have PHPUnit installed, you can run automated … Continue reading
Posted in laravel4
Leave a comment