function init() { parent::init(); $this->set('descr', 'AbsractObject is anchestor of all classes in Agile Toolkit. Do not inherit from this class direcly but use one of it\'s 3 descendants: AbstractView, AbstractModel, AbstractController'); $mvc = $this->addMoreInfo('Model View Controller')->setDescr('MVC in Agile Toolkit is similar to MVC implementation in other frameworks, although there are also major differences.'); $mvc->add('H3')->set('What is classic use of MVC'); $mvc->add('P')->set('Concept of MVC was first publicized by ObjectiveC based frameworks from NeXT which was later acquired by Apple Computer Inc. In Web it was used by WebObjects, also distributed by NeXT. In traditional sense, view is a static content prepared by some tool which explains how UI looks on the screen. Model is either a data object or XML container also prepared and managed by some tool'); $mvc->add('P')->set('Nor view nor model in their original imprementation could contain the code. Today many developers see that as a inconvenience and therefore the concept is being shifted.'); $mvc->add('H3')->set('Models in Agile Toolkit'); $mvc->add('P')->set('Models in Agile Toolkit are classes. You can choose your parent from AbstractModel, Model or Model_Table. If you are going to use Database, then the most obvious choice for any model would be Model_Table. Model_Table offers a wide range of utilities in dynamically building or modifying model structure, working with values, operating with database.'); $mvc->add('H3')->set('Views in Agile Toolkit'); $mvc->add('P')->set('In other frameworks View would be a piece of HTML code. However the code on its own might be insufficient, therefore some pseudo-control elements make it into there or even PHP code is allowed ot be executed. In Agile Toolkit View is a class. That class can have some dynmaic behaviour and have either standard or custom template but certainly any View in Agile Toolkit can just be placed on the page and will be displayed properly'); $this->addExample('Typical use of DBlite')->setDescr(<<<'EOD' // 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'); EOD ); $this->addExample('Establishing additional database connection')->setDescr(<<<'EOD' $db2=$this->add('DBlite') ->connect('mysql://*****:*****@1.2.3.4/mydb'); $db2->query('show tables'); while($row=$db2->fetchRow()){ echo $row[0]; } EOD ); /* $this->addNote('Obsolete')->setDescr('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]'); */ }
function init() { parent::init(); $this->set('descr', ' DBlite class will allow your application to interact with SQL database. To define, which database type should be used (MySQL, PostrgreSQL, etc) as well as provide database access information, you need to supply DSN (Database Source Name). Typically [DSN is supplied in configuration file]. In typical applications you do not need to use DBlite class directly. Use [$api->dbConnect()] to establish connection automatically. This will ceate DBlite object, which will be accessible through $api->db property. It is strongly advised to used [DSQL class] for any database interactions. However, should you require direct database access, you may use DBlite directly. Finally - you can establish multiple connections to multiple databases by creating additional instances of DBlite. '); }
function init() { parent::init(); $this->set('descr', ' '); $this->add('Doc_Example')->setCode(<<<'EOD' $p->add('Form'); EOD ); $this->addExample('Establishing additional database connection')->setDescr(<<<'EOD' $db2=$this->add('DBlite') ->connect('mysql://*****:*****@1.2.3.4/mydb'); $db2->query('show tables'); while($row=$db2->fetchRow()){ echo $row[0]; } EOD ); }
function init() { parent::init(); $this->set('descr', ' DBlite class will allow your application to interact with SQL database. To define, which database type should be used (MySQL, PostrgreSQL, etc) as well as provide database access information, you need to supply DSN (Database Source Name). Typically [DSN is supplied in configuration file]. In typical applications you do not need to use DBlite class directly. Use [$api->dbConnect()] to establish connection automatically. This will ceate DBlite object, which will be accessible through $api->db property. It is strongly advised to used [DSQL class] for any database interactions. However, should you require direct database access, you may use DBlite directly. Finally - you can establish multiple connections to multiple databases by creating additional instances of DBlite. '); $this->addMoreInfo('Why executing SQL directly is a bad idea?')->setDescr('When developer have to design all SQL queries in the software, there are several disadvantages: First - developer must write every single query himself. Toolkit can\'t help you by creating them automatically for you. Secondly - once query is written and passed to a function, that function is no longer able to change it (for example to introduce additional WHERE clause or to JOIN related table). Finally - by asking developer to take care of all the SQL queries, due to human error, they may introduce security risks, such as [SQL injections]. Parametric queries solve security issue, however they do nothing about first two issues. [Dynamic SQL] is a class instead of the string. After you create DSQL object, you can execute its methods to change the query. Similarly other components of the framework can do some adjustments for you. Arguments you pass to those methods are automatically validated / quoted as required. ')->addExample('Typical use of Dynamic SQL')->setDescr(<<<'EOD' // Creating new DSQL query $dynamic_query = $this->api->db->dsql(); // Specifying table, conditions and fields $dynamic_query ->table('employee') ->where('salary>',1000) ->field('name') ; // Changes to query can be performed at any time. In this // example we use user-supplied parameter "search" // without additional validation. Method where() // does those checks for us. if(isset($_GET['search'])){ $dynamic_query->where('name',$_GET['search']); } // If you try to use query as string, it will generate // SQL line automatically. echo $dynamic_query; // Outputs: SELECT name FROM employee WHERE salary>1000 // and name="Tom" // You can execute query directly through one of the // methods starting with "do_" $data = $dynamic_query->do_getAll(); EOD ); $this->addMoreInfo('When you should use DBlite')->setDescr('When Dynamic SQL does not provide required functionality. For example it can be used to begin transactions, perform commits or use database-specific queries (such as "set names="UTF8") '); $this->addExample('Typical use of DBlite')->setDescr(<<<'EOD' // 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'); EOD ); $this->addExample('Establishing additional database connection')->setDescr(<<<'EOD' $db2=$this->add('DBlite') ->connect('mysql://*****:*****@1.2.3.4/mydb'); $db2->query('show tables'); while($row=$db2->fetchRow()){ echo $row[0]; } EOD ); $this->addNote('Obsolete')->setDescr('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]'); }