Location: PHPKode > scripts > RS Asset > rs-asset/example.php
<?php

header('Content-type: text/plain');

include_once('class.asset.php');
include_once('class.mysql.php');

$db_conf = array(
	'host'	=>	'localhost',
	'user'	=>	'undefine_tester',
	'pass'	=>	'tester',
	'db'	=>	'undefine_tester',
	'pers'	=>	false // persistent connection?
);
$db = new mysql($db_conf);

$table = 'tester';
$tester_definition = array(
	'primaryKey'	=>	'id', // primary key column
	
	'elements'	=> array(
		/*
			please use the following format for element definitions:
			
			'unique name of element'	=>	array(
				'default'	=>	'default value (if not specified upon adding new record)',
				'sql_path'	=>	'column name in table',
				'modifiers'	=>	array(
					'encode'	=>	'html',
					'encode'	=>	'url'
				)
			)
		*/
		
		'id'	=>	array(
			'sql_path'	=>	'id'
		),
		
		'date'	=>	array(
			'default'	=>	time(),
			'sql_path'	=>	'date',
			'modifiers'	=>	array(
				'date_format'	=>	'F j, Y, g:i a'
			)
		),
		
		'title'	=> array(
			'sql_path'	=>	'title'
		)
	),
	
	// templated sql queries
	'list_sql'	=>	"select %sql_val% from `" . $table . "` %sql_order% %sql_limit%", // get all values
	'edit_sql'	=>	"select * from `" . $table . "` where `" . $param . "`='%param%' limit 1", // get single value
	'save_sql'	=>	"update `" . $table . "` set %update_sql% where `" . $param . "`='%param%' limit 1", // save
	'add_sql'	=>	"insert into `" . $table . "` (%sql_left%) values (%sql_right%)", // add
	'delete_sql'	=>	"delete from `" . $table . "` where `" . $param . "` in (%param%)" // delete
);

$tester_asset = new asset($tester_definition, $db);

$test_add = array(
	'title'	=>	'test'
);
$tester_asset->add($test_add);

$list = $tester_asset->get();
print_r($list);

?>
Return current item: RS Asset