라이브러리

[PHP] SwooleTable::column - 열의 데이터 유형과 크기를 설정합니다.




SwooleTable::column


SwooleTable::column은 SwooleTable의 열(column)에서 데이터를 읽고 쓰기 위한 메소드입니다.

# 사용법


#hostingforum.kr
php

$table = new SwooleTable(10, 1024);

$table->column('id', SwooleTable::TYPE_INT, 4);

$table->column('name', SwooleTable::TYPE_STRING, 32);

$table->create();



# column 메소드의 인자


* `name`: 열의 이름입니다.
* `type`: 열의 데이터 타입입니다. SwooleTable::TYPE_INT, SwooleTable::TYPE_STRING, SwooleTable::TYPE_FLOAT, SwooleTable::TYPE_DOUBLE, SwooleTable::TYPE_BOOL, SwooleTable::TYPE_TIMESTAMP, SwooleTable::TYPE_ARRAY, SwooleTable::TYPE_OBJECT, SwooleTable::TYPE_PACKED, SwooleTable::TYPE_NULL 중 하나를 선택할 수 있습니다.
* `size`: 열의 크기입니다.

# 예제


#hostingforum.kr
php

$table = new SwooleTable(10, 1024);

$table->column('id', SwooleTable::TYPE_INT, 4);

$table->column('name', SwooleTable::TYPE_STRING, 32);

$table->create();



// 데이터 삽입

$table->set(1, ['id' => 1, 'name' => 'John']);

$table->set(2, ['id' => 2, 'name' => 'Jane']);



// 데이터 읽기

$data = $table->get(1);

echo $data['id'] . "
"; // 1

echo $data['name'] . "
"; // John



// 데이터 수정

$table->set(1, ['id' => 1, 'name' => 'Jim']);

$data = $table->get(1);

echo $data['id'] . "
"; // 1

echo $data['name'] . "
"; // Jim



// 데이터 삭제

$table->del(2);



# column 메소드의 사용


SwooleTable::column 메소드는 SwooleTable의 열(column)에서 데이터를 읽고 쓰기 위한 메소드입니다. 이 메소드는 SwooleTable::create 메소드와 함께 사용하여 SwooleTable을 생성할 수 있습니다.

# column 메소드의 예외


* `name` 인자가 중복되면 예외가 발생합니다.
* `type` 인자가 잘못되면 예외가 발생합니다.
* `size` 인자가 잘못되면 예외가 발생합니다.

# column 메소드의 추천 사용법


* SwooleTable::create 메소드와 함께 사용하여 SwooleTable을 생성할 수 있습니다.
* 데이터 삽입, 읽기, 수정, 삭제를 위한 메소드인 SwooleTable::set, SwooleTable::get, SwooleTable::del을 함께 사용할 수 있습니다.
  • profile_image
    나우호스팅 @pcs8404 

    호스팅포럼 화이팅!

    댓글목록

    등록된 댓글이 없습니다.

  • 전체 8,985건 / 94 페이지

검색

게시물 검색