CyberX

RevolveR DBX: ABQ JOIN support

Hi, all. Today I was integrate new DBX core into RevolveR CMS for some tests thats represent new JOIN queries syntax support. Today all RevolveR CMS DB core works under ABQ(array based queries).

Now in work cache for JOIN queries but seems all engine works fine.

For example I have to show how to perform INNER JOIN under DBX. First, we have to define DB table fields structure. For emaple I define two tables:

$STRUCT_NODES = [
	'field_id' => [
		'type'   => 'num', // int
		'auto'   => true,  // auto increment
		'length' => 255,
		'value'  => 0
	],
	'field_title' => [
		'type'   => 'text', // varchar
		'length' => 50,
		'fill'   => true
	],
	'field_content' => [
		'type'   => 'text', // varchar
		'length' => 10000,
		'fill'   => true
	],
	'field_description' => [
		'type'   => 'text', // varchar
		'length' => 10000,
		'fill'   => true
	],
	'field_user' => [
		'type'   => 'text',
		'length' => 50,
		'fill'	 => true
	],
	'field_time' => [
		'type'   => 'text',
		'length' => 50,
		'fill'	 => true
	],
	'field_route' => [
		'type'   => 'text',
		'length' => 100,
		'fill'	 => true
	],
	'field_category' => [
		'type'   => 'num',
		'length' => 100,
		'fill'	 => true
	],
	'field_published' => [
		'type'   => 'num',
		'length' => 1,
		'fill'   => false
	]
];

$STRUCT_COMMENTS = [
	'field_id' => [
		'type'   => 'num', // int
		'auto'   => true,  // auto increment
		'length' => 255,
		'value'  => 0
	],
	'field_node_id' => [
		'type'   => 'num',
		'length' => 50,
		'fill'	 => true
	],
	'field_user_id' => [
		'type'   => 'num',
		'length' => 50,
		'fill'	 => true
	],
	'field_user_name' => [
		'type'   => 'text',
		'length' => 100,
		'fill'	 => true
	],
	'field_content' => [
		'type'   => 'text', // varchar
		'length' => 10000,
		'fill'   => true
	],
	'field_time' => [
		'type'   => 'text',
		'length' => 100,
		'fill'	 => true
	],
	'field_published' => [
		'type' 	 => 'num',
		'length' => 1,
		'fill'	 => false
	]
];

Next, we have to configure querie:

	$cFields = ['field_id', 'field_node_id', 'field_user_id', 'field_user_name', 'field_content', 'field_time', 'field_published'];
	$nFields = ['field_id', 'field_title', 'field_content', 'field_description', 'field_user', 'field_time', 'field_route', 'field_category', 'field_published'];

	$nFields['field_id']['criterion_field'] = 'field_id';
	$nFields['field_id']['linked_field'] = 'field_node_id';

	$ncFields = [
		$cFields,
		$nFields
	];

Next, we have to perform query using syntax below:

	unset( $dbx::$result['result'] ); // clean previous result


	$dbx::query('j', ['revolver__nodes', 'revolver__comments'], $ncFields);

DBX automatically configure next SQL syntax:

SELECT `revolver__nodes`.*, `revolver__comments`.* FROM `revolver__nodes` INNER JOIN `revolver__comments` ON(`revolver__nodes`.field_id=`revolver__comments`.field_node_id);

DBX version 1.1.3 avalible on GitHub.

Comments …

You can write here as guest with moderation. Please confirm your person if you have an account or register.

Add a review as guest
Lets draw: