1.5deprecatedAdvanced Symphony Database Connector (ASDC)

Efficient database library

Clone URLhttps://github.com/symphonycms/asdc.git

Add as a submodulegit submodule add https://github.com/symphonycms/asdc.git extensions/asdc --recursive

Compatibility

2.x.x2.1.x2.2.x2.3.x2.4.x2.5.x2.6.02.6.12.6.22.6.32.6.42.6.52.6.62.6.72.6.82.6.92.6.102.6.11
1.21.41.41.5NoNoNoNoNoNoNoNoNoNoNoNoNoNo

Readme

Advanced Symphony Database Connector (ASDC)

  • Version: 1.5
  • Author: Alistair Kearney ([email protected])
  • Build Date: 19th September 2012
  • Requirements: Symphony 2.3 or above

A more efficient database library that can be used by developers as an alternative to the built in MySQL database connector. Note, this does not replace the existing driver used throughout Symphony, but is used in tandem to it.

ASDCLoader::instance() will auto-discover the existing Database object and use its connection resource. It is possible to also use this library outside of Symphony, or establish a new database connection (See example 3)

INSTALLATION

** Note: The latest version can always be grabbed with git clone git://github.com/symphonycms/asdc.git**

  1. Upload the asdc folder in to your Symphony /extensions folder.

  2. Enable it by selecting the "Advanced Symphony Database Connector (ASDC)", choose Enable from the with-selected menu, then click Apply.

USAGE

Example 1 - no profiling:

require_once(EXTENSIONS . '/asdc/lib/class.asdc.php');

try{
    $db = ASDCLoader::instance();
    $result = $db->query("SELECT * FROM `sym_pages` LIMIT 1");

    print_r($result->current());
}
catch(Exception $e){
    vprintf('%d: %s on query "%s"', $db->lastError());
}

Example 2 - profiling:

require_once(EXTENSIONS . '/asdc/lib/class.asdc.php');

try{
    $db = ASDCLoader::instance(true);  ## TURN ON PROFILING HERE!
    $result = $db->query("SELECT * FROM `sym_pages` LIMIT 1");

    print_r($result->current());
    print_r($db->log());

}
catch(Exception $e){
    vprintf('%d: %s on query "%s"', $db->lastError());
}

Example 3 - Connection without the loader:

require_once(EXTENSIONS . '/asdc/lib/class.asdc.php');

$db = new ASDCMySQL;

### Optional ###
$db->character_encoding = 'utf8';
$db->character_set = 'utf8';
$db->prefix = 'eh_';
$db->force_query_caching = true;
###

try{
    $db->connect('mysql://username:[email protected]:3306/my_table/);
    print 'SUCCESS!';
}
catch(Exception $e){
    print $e->getMessage();
}

Version history

Symphony 2.3 to 2.3.x

  • Updated to work with Symphony 2.3.x. Dropped support for lower versions. Please use v 1.4.

Symphony 2.0.6 to 2.2.x

  • Few tweaks to prevent the Log filling up with warnings

Symphony 2.0.6 to 2.2.x

  • Fixed some problems with passing around the DB resource under Symphony 2.0.7

Symphony 2.0 to 2.0.6

  • Added a truncate function

Symphony 2.0 to 2.0.6

  • ASDCLoader::instance() will correctly determine if currently operating from the Front end or Admin.