PHP code example of stdtech / dbo

1. Go to this page and download the library: Download stdtech/dbo 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/ */

    

stdtech / dbo example snippets


$T["pack"] = array(
    "table" => "pack",
    "key" => "id",
    "fields" => array(
        "id" => "int",
        "name" => "char",
        "date_created" => "date",
        "desired_size" => "int",
        "pages_min" => "int",
        "pages_max" => "int",
        "theme_id" => "int",
        "is_full" => "int"
    )
);

$db = new DBObject($config);
$db->init_tables($T);

$row = array(
    "id" => 1,
    "name" => "Alex",
    "date_created" => "2014-03-03 11:12:33",
    "desired_size" => 15,
    ...
);

$rows = $db->get('pack', 3); 

array(
	0 => array(
	    "id" => 3,
	    "name" => "Mike",
	    "date_created" => "2014-03-03 11:12:33",
	    "desired_size" => 15,
		...
	)
)

$filter = array(
	"name" => "Alex"
);
$db->get('pack', $filter) 

array(
	0 => array(
	    "id" => 1,
	    "name" => "Alex",
	    "date_created" => "2014-03-03 11:12:33",
	    "desired_size" => 15,
		...
	),
	...
)

$filter = array(
	"name" => ">Alex"  // символ '>' в начале строки, допускаются <, <=, >, >=, =, != (по-умолчанию =)
);
$db->get('pack', $filter) 

array(
	0 => array(
	    "id" => 1,
	    "name" => "Alex",
	    "date_created" => "2014-03-03 11:12:33",
	    "desired_size" => 15,
		...
	),
	...
)

$db->set('pack', $row, 3); 

$db->set('pack', $row, 3, false); 

$db->set('pack', $row, $filter); 

$db->set('pack', $row); 

$filter = array(
	"name" => ">Alex",
	"col_name_1" => "scalar"
	"col_name_2" => array("scalar_1", "scalar_2")
);