TalkPHP
 
 
Account Login
Latest Articles
» The basic usage of PHPTAL, a XML/XHTML template library for PHP
» Vulnerable methods and the areas they are commonly trusted in.
» Simple way to protect a form from bot
» The Basics On: How Session Stealing Works
» How to keep your forms from double posting data
IRC Channel
IRC Speech Bubble Join the friendly bunch on IRC...
(#TalkPHP on Freenode)

...Also available via a web interface.

See this thread for information on the TalkPHP Free Hugs Initiative™. Subject to availability.
Associates
Associates
CSS Tutorials
Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old 07-14-2008, 04:45 PM   #1 (permalink)
The Contributor
 
abiko's Avatar
 
Join Date: Feb 2008
Location: Croatia
Posts: 90
Thanks: 4
abiko is on a distinguished road
Default 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!!
__________________
Back from sysadmins to the programmers.
Send a message via ICQ to abiko Send a message via MSN to abiko
abiko is offline  
Reply With Quote
Old 07-14-2008, 04:51 PM   #2 (permalink)
The Contributor
 
Ross's Avatar
 
Join Date: Jan 2008
Location: England, UK
Posts: 83
Thanks: 3
Ross is on a distinguished road
Default

Quote:
Originally Posted by abiko View Post
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.
Ross is offline  
Reply With Quote
The Following User Says Thank You to Ross For This Useful Post:
abiko (07-14-2008)
Old 07-14-2008, 05:50 PM   #3 (permalink)
The Contributor
 
abiko's Avatar
 
Join Date: Feb 2008
Location: Croatia
Posts: 90
Thanks: 4
abiko is on a distinguished road
Default

That's a great idea, thank you :)
__________________
Back from sysadmins to the programmers.
Send a message via ICQ to abiko Send a message via MSN to abiko
abiko is offline  
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


All times are GMT. The time now is 08:13 PM.

 
     

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Inactive Reminders By Icora Web Design