DBLite is a lightweight replacement for PEAR::DB. It provides basic functionality for interraction with database.
This class is due to reimplementation in 4.1. New implementation will have the same interface, however will use PDO. It will also introduce new dynamic queries [Roadmap]
Typical use of DBlite
// reads DSN from configuration file and establishes connection with database
$this->api->dbConnect();
// executes query instantly
$this->api->db->query('SET sort_buffer_size=10000');
$p=$this->add('HtmlElement')->addClass('box metallic');
$p->add('H2')->set('Sample Feedback Form');
$f=$p->add('Form');
$rfr=$f->add('HtmlElement',null,'hint')
->addStyle('float','right')->addStyle('width','300px');
$this->hint=$rfr->add('Hint')
->set('Field-related information will appear here');
//$this->hint->js(true)->css(array('float'=>'right','width'=>'300px'));
$rfr->add('P')->set('What do you think about Agile Toolkit so far?');
$f->addField('line','email','email')
->setFieldHint('optional')
->js('focus',$this->showHint('Newsletter Subscription',
'We would like to ocassionally send you newsletter
containing Agile Toolkit security
updates, new feature highlights and other important information.'));
$f->addField('line','name','Full Name')
->setFieldHint('optional')
->js('focus',$this->showHint('Your Full Name',
'Knowing your name will help us to properly address you in the
newsletters.
'));
$ff=$f->addField('text','feedback')
->set('Your feedback, good or bad, is extremely important to us. Please '.
'type your impressions here, or suggest us how we can improve our site');
$ff->js(true)->closest('dl')->hide();
$ff->js(true)->appendTo($rfr)->css(array('height'=>'200px'));
$ff->js('click')->select();
$f->addField('dropdown','interest','Your Interest')
->setValueList(array(
'dev'=>'Developer',
'busines'=>'Business Owner',
'journalist'=>'Journalist',
'other'=>'Other',
))
->js('focus',$this->showHint('What is your interest in Agile Toolkit?','
Knowing your interest will help us to choose the right lingo and update type
'));
$f->addField('Slider','impact','Impact')
->setLabels('Lifechanging','Minor')
->js('change',$this->showHint('Is Agile Toolkit a big deal?','
Do you think that approach used in Agile Toolkit could become big?
'));
$f->addField('checkbox','proj','try Agile Toolkit in your next project?')
->js('change',$this->showHint('Learning Agile Toolkit is exciting!',
'It takes 1-3 weeks to master Agile Toolkit. '.
'Would you like to give Agile Toolkit a try in your next project?'));
$f->addField('radio','decide','Decision maker')
->setValueList(array(
'me'=>'myself',
'boss'=>'someone else',
))
->js('change',$this->showHint('Who is the decision maker?',
'Are you free to decide which framework to use or will '.
'you need to convince someone else to try Agile Toolkit?'));
$f->addField('checkbox','subscribe','subscribe to Agile Toolkit newsletter')
->set(true);
$f->setSource('intimate');
$f->addSubmit('Proceed');
if($f->isSubmitted()){
if($f->get('subscribe') && $f->get('email')){
// yay subscribe
$c=$this->add('Controller_crm_CampaignMonitor');
$result=$c->addRequest('AddSubscriber')
->set('ListID',$this->api->getConfig('crm/cm/list/atk'))
->set('Email',$f->get('email'))
->set('Name',$f->get('name'))
->process()->result;
}
$f->update();
$f->js()->univ()->location($this->api->getDestinationURL('../tweet'))->execute();
}
You can specify DSN as associative array instead of string. Example: $dsn=array( 'type'=>'mysql', 'user'=>'john', 'pass'=>'secret', 'host'=>'127.0.0.1', 'db'=>'mydb' ); Different database drivers may have their specific DSN format or additional options in assocative array.
OBSOLETE. Will be removed in v4.1
Execution of a query which returns data is typically implemented through use of cursor handles. Using this handle data can be fetched even if additional queries are executed along the way. In reality fetching data from two queries at the same time is a very rare situation and to simplify access, toolkit saves most recent cursor handle into $db->cursor. However in a perfectly normal scenario it may happend that you need to execute a query while data is still being fetched. For that reason, all instant queries such as getOne or getAll as well as those performed through DSQL will not override current cursor.
Query to execute. Can be either String or Dynamic SQL
Array with values for parametric queries
OBSOLETE. Will be removed in v4.1
OBSOLETE. Will be removed in v4.1
Array with values for parametric queries
Test123 | Test123 | Test123 | Test123 | Test123 |
---|---|---|---|---|
Method Name | Test | Test | Test | Test |
Method Name | Test | Test | Test | Test |
Method Name | Test | Test | Test | Test |