PHP code example of xwoo / data-type

1. Go to this page and download the library: Download xwoo/data-type library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

xwoo / data-type example snippets




use XWC\Data\Decorators\Model;

#[Model(
    name: 'book',
    table: '{{PREFIX}}books',
    core_props: array(
        'title' => array(
            'default' => '',
            'type'    => 'string',
        ),
        'slug' => array(
            'default' => '',
            'type'    => 'slug',
        ),
        'price' => array(
            'default' => 0,
            'type'    => 'float',
        ),
    ),
)]
final class Book extends XWC_Data {
    protected $object_type = 'book';
}



$book = xwc_get_object(15, 'book', null);

$books = xwc_get_objects(
    'book',
    array(
        'limit'   => 10,
        'orderby' => 'title',
        'order'   => 'ASC',
    ),
);