TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   Advanced PHP Programming (http://www.talkphp.com/advanced-php-programming/)
-   -   Advices on a framework (http://www.talkphp.com/advanced-php-programming/3118-advices-framework.html)

abiko 07-14-2008 04:45 PM

Advices on a framework
 
Currently I'm developing my own lightweight framework for simpler apps..
I want your advice on some aspect if it - mostly on the database backend, controller functioning and template processing.

First things first:

Controller
Controllers are defined in a config file, you could call them routes. If an non exsistent controller is entered the default controller is called.
It is a copy of an idea you can find in Zend/Kohana etc.

Database Backend
For every aspect of database operations there is a single class for it - connect to the database, select, insert etc..
Here is a sample how to get a data from the table:
PHP Code:

$select = new x3Database_Select();
$select->Select'title, sadrzaj');
$select->From('frame_blog');
$select->Where( array( 'user_id' => '2''active' => '1') );
$select->Limit('0,10');

$handle $select->exec();
while( 
$r x3Database_Fetch::Assoc$handle ) ) {
       
$kr[] = $r;


Templating
Templates are in a pure-php style. Class used for it can parse and output or "compile", or sub-process the single part, a module, and return the processed part to the main template, the main design.


Can you suggest some ideas to the whole concept, or correct me where I'm going wrong. Thank you!!

Ross 07-14-2008 04:51 PM

Quote:

Originally Posted by abiko (Post 17031)
Database Backend
For every aspect of database operations there is a single class for it - connect to the database, select, insert etc..
Here is a sample how to get a data from the table:
PHP Code:

$select = new x3Database_Select();
$select->Select'title, sadrzaj');
$select->From('frame_blog');
$select->Where( array( 'user_id' => '2''active' => '1') );
$select->Limit('0,10');

$handle $select->exec();
while( 
$r x3Database_Fetch::Assoc$handle ) ) {
       
$kr[] = $r;



I woukld prefer it all in the __constructor, like so:

PHP Code:

$select = new x3Database_Select($database_conn'*''tbl_name', array( 'user_id' => '2''active' => '1'), 030); 

And then return results in MySQLi Result class style.

abiko 07-14-2008 05:50 PM

That's a great idea, thank you :)


All times are GMT. The time now is 09:43 AM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0