xuServer  4.2
xuServer est un Framework ORM écrit en PHP pour des bases de données MySQL.
Public Member Functions | Data Fields | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes
xsModel Class Reference

This Class holds the Generic ORM and CRUD functionalities. More...

Inheritance diagram for xsModel:
xsConcept xsComponent xsClass xsCollection xsProperty

Public Member Functions

 init ()
 
 load ($id="")
 
 build ($mci="", $debug=false)
 
 sql ($criteria="__NOTHING__")
 
 sql_create ()
 
 sql_read ()
 
 sql_update ()
 
 sql_delete ()
 
 sql_copy ()
 
 sql_each ()
 
 sql_stats ()
 
 sql_search ($term="")
 
 stats ($pFunc="")
 
 count ()
 
 sum ()
 
 min ()
 
 max ()
 
 avg ()
 
 percent ()
 
 every ()
 
 any ()
 
 CRUD ($CRUD="")
 
- Public Member Functions inherited from xsConcept
 mciparse ($string="")
 this method parses the given string parameter to determine the module name the concept name and the id of the object More...
 
 privilege ($key="")
 
 foldername ($autocreate=false)
 
 design_readclass ()
 
 design_constructor ()
 

Data Fields

 $db_table ="xam_user"
 name of the table in Database that stores class instances More...
 
 $db_index =""
 name of table field that stores the auto_increment primary key More...
 
 $db_title =""
 name of table field that stores the class title if not specified before using xsClass::load(), the second table column is used More...
 
 $is_built =false
 flag to test if object has been build (metadata, methods ...) More...
 
 $title ="__notitle__"
 this property stores the common name given to an instance of the class More...
 
 $name ="__notitle__"
 this property stores : More...
 
 $can_create =1
 can user create concept instance More...
 
 $can_read =1
 can user read concept instance More...
 
 $can_update =1
 can user update concept instance More...
 
 $can_delete =1
 can user delete concept instance More...
 
 $can_search =1
 can user search concept instance More...
 
 $sql_load_alias =Array()
 
- Data Fields inherited from xsConcept
 $mci =""
 identification of the class concatenation of module_concept_dbid More...
 
 $module ="xam"
 name of the module that deals with the object held by xsClass (convention : word before the first "_" in tablename) More...
 
 $concept ="user"
 name of the class beeing held by xsClass. concept is the name of the php class that extends metaclass xsClass More...
 
 $includeFile =""
 path to the business class file if exists More...
 
 $logoPath =""
 path to the logo of current class More...
 
 $privilegeKey =""
 privilege name defined on child classes More...
 
 $db_id =0
 unique identifyer of primary key, instance number of the class More...
 

Protected Member Functions

 instance ($stmt, $collections="__NONE__")
 
 build_sql ()
 
 build_collections ($criteria="__NOTHING__")
 
- Protected Member Functions inherited from xsConcept
 mciSet ()
 

Protected Attributes

 $sql_statement =""
 last build sql statement : More...
 
 $sql_statement_create =""
 create an instance in db More...
 
 $sql_statement_read =""
 read an instance in db More...
 
 $sql_statement_update =""
 update an instance in db More...
 
 $sql_statement_delete =""
 delete an instance in db More...
 
 $sql_statement_each =""
 sql each stand for selecting objects in db More...
 
 $sql_statement_stats =""
 

Private Member Functions

 build_reset ()
 
 build_metadata ()
 
 build_methods ()
 

Private Attributes

 $build_collections_done = false
 flag that determines whether the collections Array have been computed More...
 

Detailed Description

This Class holds the Generic ORM and CRUD functionalities.

The attributes defined at this abstraction level allow to :

Author
Gael JAUNIN

Member Function Documentation

◆ any()

any ( )

◆ avg()

avg ( )

◆ build()

build (   $mci = "",
  $debug = false 
)

fundamental method on xsClass metaclass that reset structure (properties and collections) and retreive instance information from Database note : calling function newxsClass(mci),the system will try to use child class where special definitions and treatments can be done, prior of instace use

Parameters
xsConcept | string | integer$mci: the id of the instance to, load into the metaclass if object given copies minimal metadata definition. if string given, $mci has the following syntax : tablename(id) or tablename_id. module and concept are deduced from "_" separated tablenames ex : sys_user_country(1569) => module="sys"; concept=user_country; id=1569 ex : store_basketFruits(15)=> module="store"; concept=basketFruits; id=15 ex : old_cars=> module="old"; concept=cars; id=0 if integer given, the metaclass will be reloaded considering $mci to be the new id. this will work only when metaclass tablename has already been parsed
Returns
xsClass
See also
xsConcept

◆ build_collections()

build_collections (   $criteria = "__NOTHING__")
protected

reads Database and evaluates possible collections for current metaclass. this method should be called on Instance or Metadata is built warning : heavy treatment

See also
xsClass::onMetadata()
xsClass::onInstance()

◆ build_metadata()

build_metadata ( )
private

building xsClass::properties array from mysql meta data using SHOW FULL COLUMNS statement any property within $object is accessible using :

  • array notation : $object->properties['name']->value || type ...
  • § notation : $object->§name->value || type ...
  • stored value of any property is also accessible using $object->§name thanks to __toString() php-nagic method on
    See also
    xsProperty::xsProperty() @ return $this

xuxa debug 07/04/2015

◆ build_methods()

build_methods ( )
private

Méthode chainable

Returns
xsClass build method array using reflection class
See also
xsClass::instance()

◆ build_reset()

build_reset ( )
private

resetting metaclass property and collection arrays. §properties won't be reset so calling load twice, changind mci, will

Todo:
inheritance

◆ build_sql()

build_sql ( )
protected

◆ count()

count ( )

◆ CRUD()

CRUD (   $CRUD = "")

Applies the CRUD privileges on object (xsClass, xsProperty, xsMethod, xsCollection)

Parameters
string$CRUD
Returns
string|xsModel

◆ every()

every ( )

◆ init()

init ( )

◆ instance()

instance (   $stmt,
  $collections = "__NONE__" 
)
protected

Méthode chainable

Returns
xsClass when xsClass or (lower child) metadata is loaded, this protected method loads properties values from Database into a xsClass object it fetchs foreign keys values, if necessary, using alias columns previously calculated if no instance is found in Database, $db_id is reset to 0
See also
xsClass::load()
xsClass::load()

◆ load()

load (   $id = "")

public method that loads an object from database chainable

Returns
xsClass public method that loads an object from database
See also
xsClass::build_sqlstatements()
xsClass::instance()

◆ max()

max ( )

◆ min()

min ( )

◆ percent()

percent ( )

◆ sql()

sql (   $criteria = "__NOTHING__")

compute sql_statement

◆ sql_copy()

sql_copy ( )

◆ sql_create()

sql_create ( )

generate INSERT sql statement

Returns
string

◆ sql_delete()

sql_delete ( )

◆ sql_each()

sql_each ( )

◆ sql_read()

sql_read ( )

◆ sql_search()

sql_search (   $term = "")

◆ sql_stats()

sql_stats ( )

◆ sql_update()

sql_update ( )

◆ stats()

stats (   $pFunc = "")

◆ sum()

sum ( )

Field Documentation

◆ $build_collections_done

$build_collections_done = false
private

flag that determines whether the collections Array have been computed

◆ $can_create

$can_create =1

can user create concept instance

  • object : user can create
  • property : may property be in insert formular

◆ $can_delete

$can_delete =1

can user delete concept instance

  • object : user can delete
  • property : not used

◆ $can_read

$can_read =1

can user read concept instance

  • object : user can read (view)
  • property : may property be displayed in tables

◆ $can_search

$can_search =1

can user search concept instance

  • object : user can search (view)
  • property : may property been searched

◆ $can_update

$can_update =1

can user update concept instance

  • object : user can update
  • property : may property be displayed in update formular

◆ $db_index

$db_index =""

name of table field that stores the auto_increment primary key

◆ $db_table

$db_table ="xam_user"

name of the table in Database that stores class instances

◆ $db_title

$db_title =""

name of table field that stores the class title if not specified before using xsClass::load(), the second table column is used

See also
xsClass::$title

◆ $is_built

$is_built =false

flag to test if object has been build (metadata, methods ...)

◆ $name

$name ="__notitle__"

this property stores :

◆ $sql_load_alias

$sql_load_alias =Array()

◆ $sql_statement

$sql_statement =""
protected

last build sql statement :

See also
xsClass::build_sqlstatements() : calculated statement that describes metaclass note : WHERE statement is not included; It must be concatenated, depending on context
xsClass::sql_update() : calculated statement for metaclass update in Database (WHERE clause included)
xsClass::sql_insert() : calculated statement for metaclass instance creation in Database

◆ $sql_statement_create

$sql_statement_create =""
protected

create an instance in db

◆ $sql_statement_delete

$sql_statement_delete =""
protected

delete an instance in db

◆ $sql_statement_each

$sql_statement_each =""
protected

sql each stand for selecting objects in db

See also
xsClass::find()

◆ $sql_statement_read

$sql_statement_read =""
protected

read an instance in db

◆ $sql_statement_stats

$sql_statement_stats =""
protected

◆ $sql_statement_update

$sql_statement_update =""
protected

update an instance in db

◆ $title

$title ="__notitle__"

this property stores the common name given to an instance of the class

See also
$db_title