GALLERY

Class Gallery cung cấp các method thao tác với các bộ sưu tập

Group Gallery

#Get

static function Gallery::get($args);
$gallery = Gallery::get(1);
/* stdClass Object (
    [id] => 1
    [object_type] => gallery
    [name] => Ảnh sản phẩm
    [options] =>
    [order] => 0
    [created] => 2020-07-20 11:48:27
    [updated] =>
    [public] => 1
) */
$gallery = Gallery::get(['id' => 1, 'select' => 'id, name']);
/* stdClass Object (
    [id] => 1
    [name] => Ảnh sản phẩm
) */

#Gets

static function Gallery::gets($args);
$gallery = Gallery::gets(['select' => 'id, name']);
/* Array (
    [0] => stdClass Object (
        [id] => 1
        [name] => Danh mục sản phẩm
    )
    [1] => stdClass Object (
        [id] => 2
        [name] => Video
    )
)*/

#Insert

Tạo một thư viện mới hoặc cập nhật thư viện

static function Gallery::insert($args);

#Parameters

Tham số $args mảng (array) các tham số

Nếu tham số $args có 'id' được đặt thành một giá trị thì gallery sẽ được cập nhật và ngược lại là thêm mới.

Parameter Value Description
id int | default 0 Nếu khác 0 bài đối tượng sẽ được cập nhật.
name string Tên đối tượng.
object_type string Loại đối tượng (gallery, page, post, post_categories, prodcuts).

#Delete

Khi xóa gallery các gallery item cũng sẽ bị xóa

static function Gallery::delete($id);

Gallery Item

#Get

static function Gallery::getItem($args);

#Gets

Lấy danh sách gallery item của một gallery hoặc object

static function Gallery::getsItem($args);

#Parameters

Tham số $args có thể là :

Mảng (array) các tham số

Parameter Value Description
group int Id gallery cần lấy item.
object_id int ID object cần lấy item
object_type string Loại object cần lấy item

Lấy gallery item của gallery có id là 1

Gallery::getsItem(1)

Lấy gallery item của page có id là 1

Gallery::getsItem(['object' => '1', 'object_type' => 'page'])

Lấy gallery item của post có id là 1 và post type là post

Gallery::getsItem(['object' => '1', 'object_type' => 'post_post'])

Lấy gallery item của product có id là 1

Gallery::getsItem(['object' => '1', 'object_type' => 'products'])

#Count

static function Gallery::countItem($args);

#Insert

Thêm item vào gallery hoặc một object

static function Gallery::insertItem($args);

#Parameters

Tham số $args mảng (array) các tham số

Nếu tham số $args có 'id' được đặt thành một giá trị thì gallery item sẽ được cập nhật và ngược lại là thêm mới.

Parameter Value Description
id int | default 0 Nếu khác 0 bài đối tượng sẽ được cập nhật.
group_id int | default 0 ID gallery nếu thêm đối tượng vào gallery.
object_id int | default 0 ID object nếu thêm đối tượng vào object.
object_type string Loại đối tượng (gallery, page, prodcuts).

Đối với đối tương post : post_{post_type}

Đối với đối tương post_categories : post_categories_{cate_type}

Đối với đối tương product : products

type string Loại file (image, video, file).
options array Danh sách các dữ liệu mở rộng của item sẽ được lưu vào gallery item metadata.

#Delete

Xóa gallery item bao gồm xóa các metadata được thêm bằng meta gallery item

static function Gallery::deleteItem($id);

Xóa gallery item của một object

static function Gallery::deleteItemByObject($id, $object_type);

Item Metadata

#Get

Hàm này dùng để lấy một metadata trong cơ sở dữ liệu

static function Gallery::getItemMeta($itemID, $meta_key = '', $single = false);

#Update

Hàm này cập nhật giá trị cho một meta key nào đó, nếu meta_key không tồn tại sẽ tạo mới metadata

static function Gallery::updateItemMeta($itemID, $meta_key, $meta_value);

#Delete

Hàm này xóa một hoặc nhiều metas ra khỏi cơ sở dữ liệu, cấu trúc như sau:

static function Gallery::deleteItemMeta($itemID, $meta_key = '', $meta_value = ');