Methods summary
public
|
#
__construct( string $field )
create new Recordset.
Parameters
Overrides
|
public
array|static
|
#
all( array|string $fields = null )
query ข้อมูลทุกรายการ
SELECT ....
query ข้อมูลทุกรายการ
SELECT ....
Parameters
- $fields
- (options) null หมายถึง SELECT ตามที่กำหนดโดย field
Returns
array|static
|
public
static
|
#
cacheOn( boolean $auto_save = true )
เปิดการใช้งานแคช
จะมีการตรวจสอบจากแคชก่อนการสอบถามข้อมูล.
เปิดการใช้งานแคช
จะมีการตรวจสอบจากแคชก่อนการสอบถามข้อมูล.
Parameters
- $auto_save
- (options) true (default) บันทึกผลลัพท์อัตโนมัติ, false ต้องบันทึกแคชเอง
Returns
static
|
public
integer
|
#
count( )
สอบถามจำนวน record ใช้สำหรับการแบ่งหน้า.
สอบถามจำนวน record ใช้สำหรับการแบ่งหน้า.
Returns
integer
|
public static
static
|
#
create( string $filed )
create new Recordset.
Parameters
Returns
static
|
public
string
|
#
createQuery( $start, $count )
build query string.
Returns
string
|
public
mixed
|
#
current( )
Returns
mixed
Implementation of
|
public
array|object
|
#
customQuery( string $sql, boolean $toArray = true, array $values = array() )
ฟังก์ชั่นประมวลผลคำสั่ง SQL สำหรับสอบถามข้อมูล คืนค่าผลลัพท์เป็นแอเรย์ของข้อมูลที่ตรงตามเงื่อนไข
คืนค่าผลการทำงานเป็น record ของข้อมูลทั้งหมดที่ตรงตามเงื่อนไข
ฟังก์ชั่นประมวลผลคำสั่ง SQL สำหรับสอบถามข้อมูล คืนค่าผลลัพท์เป็นแอเรย์ของข้อมูลที่ตรงตามเงื่อนไข
คืนค่าผลการทำงานเป็น record ของข้อมูลทั้งหมดที่ตรงตามเงื่อนไข
Parameters
- $sql
- query string
- $toArray
- (option) default true คืนค่าเป็น Array, false คืนค่าผลลัทเป็น Object
- $values
- ถ้าระบุตัวแปรนี้จะเป็นการบังคับใช้คำสั่ง prepare แทน query
Returns
array|object
|
public
boolean
|
#
delete( mixed $condition = array(), boolean $all = false, string $oprator = 'AND' )
ลบ record กำหนดโดย $condition
คืนค่า true ถ้าสำเร็จ.
ลบ record กำหนดโดย $condition
คืนค่า true ถ้าสำเร็จ.
Parameters
- $condition
- int (primaryKey), string (SQL QUERY), array
- $all
- false (default) ลบรายการเดียว, true ลบทุกรายการที่ตรงตามเงื่อนไข
- $oprator
- สำหรับเชื่อมแต่ละ $condition เข้าด้วยกัน AND (default), OR
Returns
boolean
|
public
boolean
|
#
emptyTable( )
ฟังก์ชั่นลบข้อมูลทั้งหมดในตาราง
คืนค่า true ถ้าสำเร็จ.
ฟังก์ชั่นลบข้อมูลทั้งหมดในตาราง
คืนค่า true ถ้าสำเร็จ.
Returns
boolean
|
public
array|static
|
#
execute( array|string $fields = null )
query ข้อมูลที่มีการแบ่งหน้า
SELECT ....
query ข้อมูลที่มีการแบ่งหน้า
SELECT ....
Parameters
- $fields
- (options) null หมายถึง SELECT ตามที่กำหนดโดย field
Returns
array|static
|
public
boolean
|
#
fieldExists( string $field )
ฟังก์ชั่นตรวจสอบว่ามีฟิลด์ หรือไม่
คืนค่า true หากมีฟิลด์นี้อยู่ ไม่พบคืนค่า false.
ฟังก์ชั่นตรวจสอบว่ามีฟิลด์ หรือไม่
คืนค่า true หากมีฟิลด์นี้อยู่ ไม่พบคืนค่า false.
Parameters
Returns
boolean
|
public
Kotchasan\Orm\Field
|
#
find( integer $id )
สอบถามข้อมูลที่ $primaryKey คืนค่าข้อมูลรายการเดียว.
สอบถามข้อมูลที่ $primaryKey คืนค่าข้อมูลรายการเดียว.
Parameters
Returns
|
public
boolean|array|Kotchasan\Orm\Field
|
#
first( array|string $fields = null )
Query ข้อมูลรายการเดียว
ไม่พบคืนค่า false พบคืนค่า record ของข้อมูลรายการเดียว
SELECT .... LIMIT 1.
Query ข้อมูลรายการเดียว
ไม่พบคืนค่า false พบคืนค่า record ของข้อมูลรายการเดียว
SELECT .... LIMIT 1.
Parameters
- $fields
- (options) null หมายถึง SELECT ตามที่กำหนดโดย field
Returns
|
public
Kotchasan\Orm\Field
|
#
getField( )
คืนค่าอ๊อปเจ็ค Field ของ Recordset.
คืนค่าอ๊อปเจ็ค Field ของ Recordset.
Returns
|
public
array
|
#
getFields( )
รายชื่อฟิลด์ทั้งหมดของ Model.
รายชื่อฟิลด์ทั้งหมดของ Model.
Returns
array
|
public
array
|
#
getValues( )
คืนค่า value สำหรับการ execute.
คืนค่า value สำหรับการ execute.
Returns
array
|
public
string
|
#
group( array $params, string $oprator = 'AND' )
ฟังก์ชั่นสำหรับจัดกลุ่มคำสั่ง และ เชื่อมแต่ละกลุ่มด้วย $oprator
คืนค่า query ภายใต้ ().
ฟังก์ชั่นสำหรับจัดกลุ่มคำสั่ง และ เชื่อมแต่ละกลุ่มด้วย $oprator
คืนค่า query ภายใต้ ().
Parameters
- $params
- คำสั่ง รูปแบบ array('field1', 'condition', 'field2')
- $oprator
- AND หรือ OR
Returns
string
|
public
integer|boolean
|
#
insert( Kotchasan\Orm\Field $field )
insert ข้อมูล
สำเร็จ คืนค่า id ที่เพิ่ม ผิดพลาด คืนค่า false.
insert ข้อมูล
สำเร็จ คืนค่า id ที่เพิ่ม ผิดพลาด คืนค่า false.
Parameters
Returns
integer|boolean
|
public
static
|
#
join( string $field, string $type, mixed $on )
INNER JOIN table ON ....
Parameters
- $field
- field class ของตารางที่ join
- $type
- เช่น LEFT, RIGHT, INNER...
- $on
- where condition สำหรับการ join
Returns
static
|
public
mixed
|
#
key( )
Returns
mixed
Implementation of
|
public
static
|
#
limit( integer $count, integer $start = 0 )
จำกัดผลลัพท์ และกำหนดรายการเริ่มต้น.
จำกัดผลลัพท์ และกำหนดรายการเริ่มต้น.
Parameters
- $count
- จำนวนผลลัท์ที่ต้องการ
- $start
- รายการเริ่มต้น
Returns
static
|
public
mixed
|
#
next( )
Returns
mixed
Implementation of
|
public
static
|
#
order( mixed $sorts )
สร้าง query เรียงลำดับ.
Parameters
- $sorts
- $sort array('field ASC','field DESC') หรือ 'field ASC', 'field DESC', ....
Returns
static
|
public
boolean
|
#
query( string $sql, array $values = array() )
ฟังก์ชั่นประมวลผลคำสั่ง SQL ที่ไม่ต้องการผลลัพท์ เช่น CREATE INSERT UPDATE
สำเร็จคืนค่า true ไม่สำเร็จคืนค่า false.
ฟังก์ชั่นประมวลผลคำสั่ง SQL ที่ไม่ต้องการผลลัพท์ เช่น CREATE INSERT UPDATE
สำเร็จคืนค่า true ไม่สำเร็จคืนค่า false.
Parameters
- $sql
- $values
- ถ้าระบุตัวแปรนี้จะเป็นการบังคับใช้คำสั่ง prepare แทน query
Returns
boolean
|
public
integer
|
#
recordCount( )
สอบถามจำนวน record ทั้งหมดที่ query แล้ว.
สอบถามจำนวน record ทั้งหมดที่ query แล้ว.
Returns
integer
|
public
|
#
rewind( )
inherited from Iterator.
Implementation of
|
public
static
|
#
take( integer $start,…, integer $count,… )
จำกัดจำนวนผลลัพท์
LIMIT $start, $count.
จำกัดจำนวนผลลัพท์
LIMIT $start, $count.
Parameters
- $start,…
- ข้อมูลเริ่มต้น
- $count,…
- จำนวนผลลัพธ์ที่ต้องการ
Returns
static
|
public
static
|
#
toArray( )
คืนค่าข้อมูลเป็น Array
ฟังก์ชั่นนี้ใช้เรียกก่อนการสอบถามข้อมูล.
คืนค่าข้อมูลเป็น Array
ฟังก์ชั่นนี้ใช้เรียกก่อนการสอบถามข้อมูล.
Returns
static
|
public
Kotchasan\Database\QueryBuilder
|
#
toQueryBuilder( )
ส่งออกฐานข้อมูลเป็น QueryBuilder.
ส่งออกฐานข้อมูลเป็น QueryBuilder.
Returns
|
public
boolean
|
#
update( array $condition, array|Kotchasan\Orm\Field $save )
อัปเดตข้อมูล
สำเร็จ คืนค่า true, ผิดพลาด คืนค่า false.
อัปเดตข้อมูล
สำเร็จ คืนค่า true, ผิดพลาด คืนค่า false.
Parameters
Returns
boolean
|
public
boolean
|
#
updateAll( array $save )
อัปเดตข้อมูลทุก record.
สำเร็จ คืนค่า true, ผิดพลาด คืนค่า false.
อัปเดตข้อมูลทุก record.
สำเร็จ คืนค่า true, ผิดพลาด คืนค่า false.
Parameters
- $save
- ข้อมูลที่ต้องการบันทึก array('key1'=>'value1', 'key2'=>'value2', ...)
Returns
boolean
|
public
mixed
|
#
valid( )
Returns
mixed
Implementation of
|
public
static
|
#
where( mixed $where = array(), string $oprator = 'AND' )
WHERE ....
int ค้นหาจาก primaryKey เช่น id=1 หมายถึง WHERE id=1
string เช่น QUERY ต่างๆ email='xxx.com' หมายถึง WHERE email='xxx.com'
array เช่น ('id', 1) หมายถึง WHERE id=1
array เช่น ('email', '!=', 'xxx.com') หมายถึง WHERE email!='xxx.com'
ถ้าเป็น array สามารถรุบได้หลายค่าโดยแต่ละค่าจะเชื่อมด้วย $oprator.
WHERE ....
int ค้นหาจาก primaryKey เช่น id=1 หมายถึง WHERE id=1
string เช่น QUERY ต่างๆ email='xxx.com' หมายถึง WHERE email='xxx.com'
array เช่น ('id', 1) หมายถึง WHERE id=1
array เช่น ('email', '!=', 'xxx.com') หมายถึง WHERE email!='xxx.com'
ถ้าเป็น array สามารถรุบได้หลายค่าโดยแต่ละค่าจะเชื่อมด้วย $oprator.
Parameters
- $where
- $oprator
- (options) AND (default), OR
Returns
static
|