New example using the Page-View Pattern

Discuss anything that's related to the Raxan framework

New example using the Page-View Pattern

Postby raymond » Wed May 26, 2010 4:56 am

The upcoming RC1 release will not only make it easier to build powerful web applications with the new Page-View Pattern but it will also reduce the amount of code required.

Here's an example from the latest developer snapshot:

Code: Select all

require_once '../raxan/pdi/autostart.php';

 * @property RaxanPDO $db
class NotesPage extends RaxanWebPage {

    protected $db;
    protected $showRenderTime = true;

    protected function _config() {
        $this->autoAppendViews = true; //'index,form';
        $this->preserveFormContent = true;
        $this->masterTemplate = 'views/notes.html';
        //$this->db = $this->Raxan->connect('sqlite:'.dirname(__FILE__).'/notes.db',null,null,true);    // SQLite DB
        $this->db = $this->Raxan->connect('mysql:host=localhost; dbname=notes','user','password',true); // MySQL DB

    // Views ---

    protected function _indexView() {
        if (!$this->isPostBack) $lst = $this->db->table('notes');
        else  {
            $search ='%'.$this->post->querytxt.'%';
            $lst = $this->db->table('notes','subject like ?',$search);

    protected function _formView() {
        $id = $this->get->intVal('id');
        if ($id && !$this->isPostBack){
            $data = $this->db->table('notes id,subject,message','id=?',$id);
            $this->title->text('Edit Note');

    protected function _detailsView() {
        $id = $this->get->intVal('id');
        $data = $this->db->table('notes id,subject,message','id=?',$id);

    // Events

    protected function deleteNote($e) {
        $this->flashmsg('Record sucessfully removed','bounce','notice');

    protected function saveNote($e) {
        $id = $this->post->intVal('id');
        $data = $this->post->filterValues('subject,message');

        if (!$id) $rt = $this->db->tableInsert('notes',$data);
        else $rt = $this->db->tableUpdate('notes',$data,'id=?',$id);

        if (!$rt) $this->flashmsg('Error while updating record.');
        else $this->flashmsg('Record sucessfully saved','explode','success close click-cursor');





Here's a screen shot of the Notes example:
Notes Screenshot
notes.png (17.18 KiB) Viewed 7114 times

Get the Developer Snapshot here: ... p&can=2&q=
Site Admin
Posts: 215
Joined: Tue Mar 17, 2009 5:04 am

Return to General Discussions

Who is online

Users browsing this forum: No registered users and 3 guests