Doxygen
This commit is contained in:
parent
d434dcc85b
commit
f0dcd8ad51
@ -1,5 +1,5 @@
|
|||||||
<?php
|
<?php
|
||||||
/* Copyright (C) 2007-2008 Laurent Destailleur <eldy@users.sourceforge.net>
|
/* Copyright (C) 2007-2011 Laurent Destailleur <eldy@users.sourceforge.net>
|
||||||
* Copyright (C) ---Put here your own copyright and developer email---
|
* Copyright (C) ---Put here your own copyright and developer email---
|
||||||
*
|
*
|
||||||
* This program is free software; you can redistribute it and/or modify
|
* This program is free software; you can redistribute it and/or modify
|
||||||
@ -44,35 +44,35 @@ class Skeleton_class // extends CommonObject
|
|||||||
var $errors=array(); //!< To return several error codes (or messages)
|
var $errors=array(); //!< To return several error codes (or messages)
|
||||||
//var $element='skeleton'; //!< Id that identify managed objects
|
//var $element='skeleton'; //!< Id that identify managed objects
|
||||||
//var $table_element='skeleton'; //!< Name of table without prefix where object is stored
|
//var $table_element='skeleton'; //!< Name of table without prefix where object is stored
|
||||||
|
|
||||||
var $id;
|
var $id;
|
||||||
var $prop1;
|
var $prop1;
|
||||||
var $prop2;
|
var $prop2;
|
||||||
//...
|
//...
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Constructor
|
* Constructor
|
||||||
* \param DB Database handler
|
* @param DB Database handler
|
||||||
*/
|
*/
|
||||||
function Skeleton_class($DB)
|
function Skeleton_class($DB)
|
||||||
{
|
{
|
||||||
$this->db = $DB;
|
$this->db = $DB;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Create in database
|
* Create object into database
|
||||||
* \param user User that create
|
* @param user User that create
|
||||||
* \param notrigger 0=launch triggers after, 1=disable triggers
|
* @param notrigger 0=launch triggers after, 1=disable triggers
|
||||||
* \return int <0 if KO, Id of created object if OK
|
* @return int <0 if KO, Id of created object if OK
|
||||||
*/
|
*/
|
||||||
function create($user, $notrigger=0)
|
function create($user, $notrigger=0)
|
||||||
{
|
{
|
||||||
global $conf, $langs;
|
global $conf, $langs;
|
||||||
$error=0;
|
$error=0;
|
||||||
|
|
||||||
// Clean parameters
|
// Clean parameters
|
||||||
if (isset($this->prop1)) $this->prop1=trim($this->prop1);
|
if (isset($this->prop1)) $this->prop1=trim($this->prop1);
|
||||||
if (isset($this->prop2)) $this->prop2=trim($this->prop2);
|
if (isset($this->prop2)) $this->prop2=trim($this->prop2);
|
||||||
@ -80,7 +80,7 @@ class Skeleton_class // extends CommonObject
|
|||||||
|
|
||||||
// Check parameters
|
// Check parameters
|
||||||
// Put here code to add control on parameters values
|
// Put here code to add control on parameters values
|
||||||
|
|
||||||
// Insert request
|
// Insert request
|
||||||
$sql = "INSERT INTO ".MAIN_DB_PREFIX."mytable(";
|
$sql = "INSERT INTO ".MAIN_DB_PREFIX."mytable(";
|
||||||
$sql.= " field1,";
|
$sql.= " field1,";
|
||||||
@ -93,20 +93,20 @@ class Skeleton_class // extends CommonObject
|
|||||||
$sql.= ")";
|
$sql.= ")";
|
||||||
|
|
||||||
$this->db->begin();
|
$this->db->begin();
|
||||||
|
|
||||||
dol_syslog(get_class($this)."::create sql=".$sql, LOG_DEBUG);
|
dol_syslog(get_class($this)."::create sql=".$sql, LOG_DEBUG);
|
||||||
$resql=$this->db->query($sql);
|
$resql=$this->db->query($sql);
|
||||||
if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
|
if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
|
||||||
|
|
||||||
if (! $error)
|
if (! $error)
|
||||||
{
|
{
|
||||||
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."mytable");
|
$this->id = $this->db->last_insert_id(MAIN_DB_PREFIX."mytable");
|
||||||
|
|
||||||
if (! $notrigger)
|
if (! $notrigger)
|
||||||
{
|
{
|
||||||
// Uncomment this and change MYOBJECT to your own tag if you
|
// Uncomment this and change MYOBJECT to your own tag if you
|
||||||
// want this action call a trigger.
|
// want this action call a trigger.
|
||||||
|
|
||||||
//// Call triggers
|
//// Call triggers
|
||||||
//include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php");
|
//include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php");
|
||||||
//$interface=new Interfaces($this->db);
|
//$interface=new Interfaces($this->db);
|
||||||
@ -123,7 +123,7 @@ class Skeleton_class // extends CommonObject
|
|||||||
{
|
{
|
||||||
dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR);
|
dol_syslog(get_class($this)."::create ".$errmsg, LOG_ERR);
|
||||||
$this->error.=($this->error?', '.$errmsg:$errmsg);
|
$this->error.=($this->error?', '.$errmsg:$errmsg);
|
||||||
}
|
}
|
||||||
$this->db->rollback();
|
$this->db->rollback();
|
||||||
return -1*$error;
|
return -1*$error;
|
||||||
}
|
}
|
||||||
@ -134,11 +134,11 @@ class Skeleton_class // extends CommonObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Load object in memory from database
|
* Load object in memory from database
|
||||||
* \param id id object
|
* @param id id object
|
||||||
* \return int <0 if KO, >0 if OK
|
* @return int <0 if KO, >0 if OK
|
||||||
*/
|
*/
|
||||||
function fetch($id)
|
function fetch($id)
|
||||||
{
|
{
|
||||||
@ -150,7 +150,7 @@ class Skeleton_class // extends CommonObject
|
|||||||
//...
|
//...
|
||||||
$sql.= " FROM ".MAIN_DB_PREFIX."mytable as t";
|
$sql.= " FROM ".MAIN_DB_PREFIX."mytable as t";
|
||||||
$sql.= " WHERE t.rowid = ".$id;
|
$sql.= " WHERE t.rowid = ".$id;
|
||||||
|
|
||||||
dol_syslog(get_class($this)."::fetch sql=".$sql, LOG_DEBUG);
|
dol_syslog(get_class($this)."::fetch sql=".$sql, LOG_DEBUG);
|
||||||
$resql=$this->db->query($sql);
|
$resql=$this->db->query($sql);
|
||||||
if ($resql)
|
if ($resql)
|
||||||
@ -158,14 +158,14 @@ class Skeleton_class // extends CommonObject
|
|||||||
if ($this->db->num_rows($resql))
|
if ($this->db->num_rows($resql))
|
||||||
{
|
{
|
||||||
$obj = $this->db->fetch_object($resql);
|
$obj = $this->db->fetch_object($resql);
|
||||||
|
|
||||||
$this->id = $obj->rowid;
|
$this->id = $obj->rowid;
|
||||||
$this->prop1 = $obj->field1;
|
$this->prop1 = $obj->field1;
|
||||||
$this->prop2 = $obj->field2;
|
$this->prop2 = $obj->field2;
|
||||||
//...
|
//...
|
||||||
}
|
}
|
||||||
$this->db->free($resql);
|
$this->db->free($resql);
|
||||||
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@ -175,19 +175,19 @@ class Skeleton_class // extends CommonObject
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Update database
|
* Update object into database
|
||||||
* \param user User that modify
|
* @param user User that modify
|
||||||
* \param notrigger 0=launch triggers after, 1=disable triggers
|
* @param notrigger 0=launch triggers after, 1=disable triggers
|
||||||
* \return int <0 if KO, >0 if OK
|
* @return int <0 if KO, >0 if OK
|
||||||
*/
|
*/
|
||||||
function update($user=0, $notrigger=0)
|
function update($user=0, $notrigger=0)
|
||||||
{
|
{
|
||||||
global $conf, $langs;
|
global $conf, $langs;
|
||||||
$error=0;
|
$error=0;
|
||||||
|
|
||||||
// Clean parameters
|
// Clean parameters
|
||||||
if (isset($this->prop1)) $this->prop1=trim($this->prop1);
|
if (isset($this->prop1)) $this->prop1=trim($this->prop1);
|
||||||
if (isset($this->prop2)) $this->prop2=trim($this->prop2);
|
if (isset($this->prop2)) $this->prop2=trim($this->prop2);
|
||||||
@ -204,18 +204,18 @@ class Skeleton_class // extends CommonObject
|
|||||||
$sql.= " WHERE rowid=".$this->id;
|
$sql.= " WHERE rowid=".$this->id;
|
||||||
|
|
||||||
$this->db->begin();
|
$this->db->begin();
|
||||||
|
|
||||||
dol_syslog(get_class($this)."::update sql=".$sql, LOG_DEBUG);
|
dol_syslog(get_class($this)."::update sql=".$sql, LOG_DEBUG);
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
|
if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
|
||||||
|
|
||||||
if (! $error)
|
if (! $error)
|
||||||
{
|
{
|
||||||
if (! $notrigger)
|
if (! $notrigger)
|
||||||
{
|
{
|
||||||
// Uncomment this and change MYOBJECT to your own tag if you
|
// Uncomment this and change MYOBJECT to your own tag if you
|
||||||
// want this action call a trigger.
|
// want this action call a trigger.
|
||||||
|
|
||||||
//// Call triggers
|
//// Call triggers
|
||||||
//include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php");
|
//include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php");
|
||||||
//$interface=new Interfaces($this->db);
|
//$interface=new Interfaces($this->db);
|
||||||
@ -224,7 +224,7 @@ class Skeleton_class // extends CommonObject
|
|||||||
//// End call triggers
|
//// End call triggers
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Commit or rollback
|
// Commit or rollback
|
||||||
if ($error)
|
if ($error)
|
||||||
{
|
{
|
||||||
@ -232,7 +232,7 @@ class Skeleton_class // extends CommonObject
|
|||||||
{
|
{
|
||||||
dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR);
|
dol_syslog(get_class($this)."::update ".$errmsg, LOG_ERR);
|
||||||
$this->error.=($this->error?', '.$errmsg:$errmsg);
|
$this->error.=($this->error?', '.$errmsg:$errmsg);
|
||||||
}
|
}
|
||||||
$this->db->rollback();
|
$this->db->rollback();
|
||||||
return -1*$error;
|
return -1*$error;
|
||||||
}
|
}
|
||||||
@ -240,46 +240,46 @@ class Skeleton_class // extends CommonObject
|
|||||||
{
|
{
|
||||||
$this->db->commit();
|
$this->db->commit();
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Delete object in database
|
* Delete object in database
|
||||||
* \param user User that delete
|
* @param user User that delete
|
||||||
* \param notrigger 0=launch triggers after, 1=disable triggers
|
* @param notrigger 0=launch triggers after, 1=disable triggers
|
||||||
* \return int <0 if KO, >0 if OK
|
* @return int <0 if KO, >0 if OK
|
||||||
*/
|
*/
|
||||||
function delete($user, $notrigger=0)
|
function delete($user, $notrigger=0)
|
||||||
{
|
{
|
||||||
global $conf, $langs;
|
global $conf, $langs;
|
||||||
$error=0;
|
$error=0;
|
||||||
|
|
||||||
$sql = "DELETE FROM ".MAIN_DB_PREFIX."mytable";
|
$sql = "DELETE FROM ".MAIN_DB_PREFIX."mytable";
|
||||||
$sql.= " WHERE rowid=".$this->id;
|
$sql.= " WHERE rowid=".$this->id;
|
||||||
|
|
||||||
$this->db->begin();
|
$this->db->begin();
|
||||||
|
|
||||||
dol_syslog(get_class($this)."::delete sql=".$sql);
|
dol_syslog(get_class($this)."::delete sql=".$sql);
|
||||||
$resql = $this->db->query($sql);
|
$resql = $this->db->query($sql);
|
||||||
if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
|
if (! $resql) { $error++; $this->errors[]="Error ".$this->db->lasterror(); }
|
||||||
|
|
||||||
if (! $error)
|
if (! $error)
|
||||||
{
|
{
|
||||||
if (! $notrigger)
|
if (! $notrigger)
|
||||||
{
|
{
|
||||||
// Uncomment this and change MYOBJECT to your own tag if you
|
// Uncomment this and change MYOBJECT to your own tag if you
|
||||||
// want this action call a trigger.
|
// want this action call a trigger.
|
||||||
|
|
||||||
//// Call triggers
|
//// Call triggers
|
||||||
//include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php");
|
//include_once(DOL_DOCUMENT_ROOT . "/core/class/interfaces.class.php");
|
||||||
//$interface=new Interfaces($this->db);
|
//$interface=new Interfaces($this->db);
|
||||||
//$result=$interface->run_triggers('MYOBJECT_DELETE',$this,$user,$langs,$conf);
|
//$result=$interface->run_triggers('MYOBJECT_DELETE',$this,$user,$langs,$conf);
|
||||||
//if ($result < 0) { $error++; $this->errors=$interface->errors; }
|
//if ($result < 0) { $error++; $this->errors=$interface->errors; }
|
||||||
//// End call triggers
|
//// End call triggers
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Commit or rollback
|
// Commit or rollback
|
||||||
if ($error)
|
if ($error)
|
||||||
{
|
{
|
||||||
@ -287,7 +287,7 @@ class Skeleton_class // extends CommonObject
|
|||||||
{
|
{
|
||||||
dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR);
|
dol_syslog(get_class($this)."::delete ".$errmsg, LOG_ERR);
|
||||||
$this->error.=($this->error?', '.$errmsg:$errmsg);
|
$this->error.=($this->error?', '.$errmsg:$errmsg);
|
||||||
}
|
}
|
||||||
$this->db->rollback();
|
$this->db->rollback();
|
||||||
return -1*$error;
|
return -1*$error;
|
||||||
}
|
}
|
||||||
@ -299,18 +299,18 @@ class Skeleton_class // extends CommonObject
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Load an object from its id and create a new one in database
|
* Load an object from its id and create a new one in database
|
||||||
* \param fromid Id of object to clone
|
* @param fromid Id of object to clone
|
||||||
* \return int New id of clone
|
* @return int New id of clone
|
||||||
*/
|
*/
|
||||||
function createFromClone($fromid)
|
function createFromClone($fromid)
|
||||||
{
|
{
|
||||||
global $user,$langs;
|
global $user,$langs;
|
||||||
|
|
||||||
$error=0;
|
$error=0;
|
||||||
|
|
||||||
$object=new Skeleton_class($this->db);
|
$object=new Skeleton_class($this->db);
|
||||||
|
|
||||||
$this->db->begin();
|
$this->db->begin();
|
||||||
@ -322,24 +322,24 @@ class Skeleton_class // extends CommonObject
|
|||||||
|
|
||||||
// Clear fields
|
// Clear fields
|
||||||
// ...
|
// ...
|
||||||
|
|
||||||
// Create clone
|
// Create clone
|
||||||
$result=$object->create($user);
|
$result=$object->create($user);
|
||||||
|
|
||||||
// Other options
|
// Other options
|
||||||
if ($result < 0)
|
if ($result < 0)
|
||||||
{
|
{
|
||||||
$this->error=$object->error;
|
$this->error=$object->error;
|
||||||
$error++;
|
$error++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! $error)
|
if (! $error)
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// End
|
// End
|
||||||
if (! $error)
|
if (! $error)
|
||||||
{
|
{
|
||||||
@ -353,10 +353,10 @@ class Skeleton_class // extends CommonObject
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief Initialise object with example values
|
* Initialisz object with example values
|
||||||
* \remarks id must be 0 if object instance is a specimen.
|
* Id must be 0 if object instance is a specimen.
|
||||||
*/
|
*/
|
||||||
function initAsSpecimen()
|
function initAsSpecimen()
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user