Data Adapter API

Component ID

1533670

Component name

Data Adapter API

Component type

module

Maintenance status

Development status

Component security advisory coverage

not-covered

Component created

Component changed

Component body

Data adapter API module provides an abstract interface much like an Object Relation Mappers for Drupal module developer. The project is developed for Drupal 6 and inspired by Drupal 7 Database access layer. It need more refinements as it was build on base of initial requirements.

NOTE: The documentation is still incomplete and project has no current activity.

Load data access layer adapter

<?php
$node = get_data_adapter('database_table', 'table_alias', 'database_connection_name');
?>

Get SQL Query

<?php
$result = $node->fields(array('nid', 'title'))->conditions(array('nid'=>1, 'title' => array('adopt%', 'LIKE')),30,0)->sort(array('`nid` ASC'))->joins(
            'left', 
            array(
                'table' => array('node_revisions', 'nr'),
                'map' => array('nid', 'nid'),
                'fields' => array('body'),
                ))->get_select_query();
?>

Dynamic function

<?php
$node->load_by_nid(1487);
?>

Select Query

<?php
$result = $node->fields(array('nid', 'title'))->conditions(array('nid'=>1, 'title' => array('adopt%', 'LIKE')),30,0)->sort(array('`nid` ASC'))->joins(
            'left', 
            array(
                'table' => array('node_revisions', 'nr'),
                'map' => array('nid', 'nid'),
                'fields' => array('body'),
                ))->load();
?>

Insert Query

<?php
$node->values(array
                (array(
                        'page', 
                        'My Title node a' ,
                        1 ,
                        1 ,
                        time()
                ), array(
                        'page', 
                        'My Title node b',
                        1,
                        1,
                        time()
                ))
        )->set(array(
                'type' , 
                'title' ,
                'uid' ,
                'status' ,
                'created'
        ))->save();
?>

Update Query

<?php
$node->changes(array('vid' => 1487))->conditions(array('nid' => 1487))->update();
?>

Remove Query

<?php
$node->conditions(array('nid' => 1487, 'vid' => 1487))->remove();
?>