The Holy Grail of PHP

    Date: 08/09/05 (PHP Community)    Keywords: php, database, sql, web

    Thought I'd share this with the community. I'll be writing a real walkthrough soon, as this combo is too good to keep to myself.
    Would love to hear any comments, criticisms, or alternatives. If anyone is interested in helping write a few pages on the topic, send me an email or something too.


    What do you get when you combine an automated database object abstraction layer, an embedded templating engine, and an AJAX library?

    Unparalled rapid modular development fusing the web's hottest technologies.
    And it's easy.

    PEAR DB_DataObject
    PHP Smarty
    xajax

    What's it look like? Here's a teenie example.

    index.php

    
    
    
    
    	
    		printJavascript(); ?>
    		Test
    	
    	
    		
    ID:



    ajax.php
    addAssign("content","innerHTML", $v->getNote($id));
    
    	return $objResponse->getXML();
    }
    
    $xajax = new xajax();
    
    $xajax->registerFunction("getNote");
    $xajax->processRequests();
    ?>



    template.php
    template_dir = 'tpl/';
    		$this->compile_dir = 'tpl/comp';
    		$this->config_dir = 'tpl/conf';
    		$this->cache_dir = 'tpl/cache';
    	}
    
    	function getNote($id = null) {
    		$note = DB_DataObject::Factory('notes');
    		$note->get($id);
    		$this->assign('note', $note);
    		return $this->fetch('note.tpl');
    	}
    }
    ?>



    tpl/note.tpl
    {$note->name}
    {$note->body}



    data.php



    schema.sql
    CREATE DATABASE organizer;
    USE organizer;
    
    CREATE TABLE notes (
    	id INT UNSIGNED NOT NULL AUTO_INCREMENT,
    	name VARCHAR(32),
    	body TEXT,
    	PRIMARY KEY(id)
    );




    Source: http://www.livejournal.com/community/php/333380.html

« hola once more || PHP Question »


antivirus | apache | asp | blogging | browser | bugtracking | cms | crm | css | database | ebay | ecommerce | google | hosting | html | java | jsp | linux | microsoft | mysql | offshore | offshoring | oscommerce | php | postgresql | programming | rss | security | seo | shopping | software | spam | spyware | sql | technology | templates | tracker | virus | web | xml | yahoo | home