dbscript
[ class tree: dbscript ] [ index: dbscript ] [ all elements ]

Class: Model

Source Location: /model.php

Class Overview


Data Model


Author(s):

Version:

  • 0.1.2

Variables

Methods


Child classes:

MySQLTable
MySQL Table
PostgreSQLTable
PostgreSQL Table

Class Details

[line 53]
Data Model

Describes a database table: fields, rules and relationships.

Automatically composes simple JOIN queries for relationships described in the models via has_many, has_one, etc.

Usage:

  1.    // define a new table named photos
  2.   $model =$db->model'photo' );
  3.  
  4.    // define the fields in the table
  5.   $model->auto_field'id' );
  6.  $model->file_field'image' );
  7.  $model->char_field'title'255 );
  8.  $model->text_field'caption' );
  9.  
  10.    // create the table in the database
  11.   $model->save();
  12.  
  13.    // deny access to everybody, unless they are an administrator
  14.   $model->let_access'all:never all:admin' );
  15.  
  16.    // function to test whether current user is an administrator
  17.   function admin({
  18.    return true;
  19.  }

More info... http://dbscript.net/model




Tags:

version:  0.1.2
access:  public
author:  Brian Hendrickson <brian@dbscript.net>


[ Top ]


Class Variables

$access_list =

[line 83]

list of security access rules


Type:   string[]


[ Top ]

$allowed_methods =

[line 113]

list of public methods


Type:   string[]


[ Top ]

$custom_class =

[line 107]

proper CamelCase name of data model object


Type:   string


[ Top ]

$exists =

[line 65]

true if table exists in database


Type:   boolean


[ Top ]

$field_array =

[line 71]

list of field names


Type:   string[]


[ Top ]

$field_attrs =

[line 77]

list of field attributes


Type:   string[]


[ Top ]

$limit =

[line 125]

limit query to x records


Type:   integer


[ Top ]

$offset =

[line 119]

when querying with find(), offset by x records


Type:   integer


[ Top ]

$order =

[line 137]

order query ASC or DESC


Type:   string


[ Top ]

$orderby =

[line 131]

order query by this column


Type:   string


[ Top ]

$params =

[line 143]

list of Collection/Feed params for layout


Type:   string[]


[ Top ]

$primary_key =

[line 89]

name of primary key field


Type:   string


[ Top ]

$relations =

[line 101]

list of relationships to other tables


Type:   string[]


[ Top ]

$table =

[line 59]

name of the database table


Type:   string


[ Top ]

$uri_key =

[line 95]

name of collection key field


Type:   string


[ Top ]



Class Methods


method base [line 245]

void base( [ $custom_class = NULL])



Parameters:

   $custom_class  

[ Top ]

method belongs_to [line 373]

void belongs_to( $relstring)



Parameters:

   $relstring  

[ Top ]

method can_delete [line 526]

void can_delete( )



[ Top ]

method can_display [line 531]

void can_display( $resource)



Parameters:

   $resource  

[ Top ]

method can_display_fields [line 485]

void can_display_fields( $fields)



Parameters:

   $fields  

[ Top ]

method can_insert [line 521]

void can_insert( )



[ Top ]

method can_read [line 497]

void can_read( $resource)



Parameters:

   $resource  

[ Top ]

method can_read_fields [line 461]

void can_read_fields( $fields)



Parameters:

   $fields  

[ Top ]

method can_write [line 509]

void can_write( $resource)



Parameters:

   $resource  

[ Top ]

method can_write_fields [line 473]

void can_write_fields( $fields)



Parameters:

   $fields  

[ Top ]

method db_field [line 236]

void db_field( $field, $alias)



Parameters:

   $field  
   $alias  

[ Top ]

method delete_from_post [line 199]

void delete_from_post( &$req)



Parameters:

   &$req  

[ Top ]

method exists [line 241]

void exists( )



[ Top ]

method fields_from_request [line 203]

void fields_from_request( &$req)



Parameters:

   &$req  

[ Top ]

method field_attributes [line 293]

void field_attributes( $field, $arr)



Parameters:

   $field  
   $arr  

[ Top ]

method find [line 617]

void find( [ $id = NULL], [ $find_by = NULL])



Parameters:

   $id  
   $find_by  

[ Top ]

method find_by [line 632]

void find_by( $col, $val)



Parameters:

   $col  
   $val  

[ Top ]

method foreign_key_for [line 400]

void foreign_key_for( $table)



Parameters:

   $table  

[ Top ]

method has_and_belongs_to_many [line 369]

void has_and_belongs_to_many( $relstring)



Parameters:

   $relstring  

[ Top ]

method has_many [line 377]

void has_many( $relstring)



Parameters:

   $relstring  

[ Top ]

method has_one [line 381]

void has_one( $relstring)



Parameters:

   $relstring  

[ Top ]

method insert_from_post [line 145]

void insert_from_post( &$req)



Parameters:

   &$req  

[ Top ]

method is_allowed [line 359]

void is_allowed( $method)



Parameters:

   $method  

[ Top ]

method is_blob [line 612]

void is_blob( $field)



Parameters:

   $field  

[ Top ]

method join_table_for [line 420]

void join_table_for( $t1, $t2)



Parameters:

   $t1  
   $t2  

[ Top ]

method let_access [line 297]

void let_access( $fields)



Parameters:

   $fields  

[ Top ]

method let_display [line 335]

void let_display( $fields)



Parameters:

   $fields  

[ Top ]

method let_read [line 303]

void let_read( $fields)



Parameters:

   $fields  

[ Top ]

method let_write [line 319]

void let_write( $fields)



Parameters:

   $fields  

[ Top ]

method MoveFirst [line 636]

void MoveFirst( )



[ Top ]

method MoveNext [line 645]

void MoveNext( )



[ Top ]

method register [line 270]

void register( $custom_class)



Parameters:

   $custom_class  

[ Top ]

method rewind [line 544]

void rewind( )



[ Top ]

method rowcount [line 676]

void rowcount( )



[ Top ]

method save [line 571]

void save( )



[ Top ]

method session_exists [line 654]

void session_exists( )



[ Top ]

method set_action [line 351]

void set_action( $method)



Parameters:

   $method  

[ Top ]

method set_attribute [line 393]

void set_attribute( $attr, $field)



Parameters:

   $attr  
   $field  

[ Top ]

method set_field [line 277]

void set_field( $field, $data_type, [ $arr = NULL])



Parameters:

   $field  
   $data_type  
   $arr  

[ Top ]

method set_limit [line 660]

void set_limit( $limit)



Parameters:

   $limit  

[ Top ]

method set_offset [line 664]

void set_offset( $offset)



Parameters:

   $offset  

[ Top ]

method set_order [line 672]

void set_order( $order)



Parameters:

   $order  

[ Top ]

method set_orderby [line 668]

void set_orderby( $col)



Parameters:

   $col  

[ Top ]

method set_param [line 355]

void set_param( $param, $value)



Parameters:

   $param  
   $value  

[ Top ]

method set_primary_key [line 287]

void set_primary_key( $field)



Parameters:

   $field  

[ Top ]

method set_relation [line 427]

void set_relation( $relstring, $type)



Parameters:

   $relstring  
   $type  

[ Top ]

method set_routes [line 548]

void set_routes( $table)



Parameters:

   $table  

[ Top ]

method set_uri_key [line 283]

void set_uri_key( $field)



Parameters:

   $field  

[ Top ]

method update_from_post [line 170]

void update_from_post( &$req)



Parameters:

   &$req  

[ Top ]

method validates_presence_of [line 385]

void validates_presence_of( $field)



Parameters:

   $field  

[ Top ]

method validates_uniqueness_of [line 389]

void validates_uniqueness_of( $field)



Parameters:

   $field  

[ Top ]


Documentation generated on Mon, 19 Feb 2007 10:24:50 -0800 by phpDocumentor 1.3.1