Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
dolibarr
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Container registry
Model registry
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Software_Artifact_Infrastructure_Repository
dolibarr
Commits
0b7cbb50
Commit
0b7cbb50
authored
13 years ago
by
Laurent Destailleur
Browse files
Options
Downloads
Patches
Plain Diff
Update template fo class. delete actions must be done in opposite order
of create actions.
parent
42082129
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
dev/skeletons/skeleton_class.class.php
+25
-24
25 additions, 24 deletions
dev/skeletons/skeleton_class.class.php
with
25 additions
and
24 deletions
dev/skeletons/skeleton_class.class.php
+
25
−
24
View file @
0b7cbb50
<?php
/* Copyright (C) 2007-201
1
Laurent Destailleur <eldy@users.sourceforge.net>
/* Copyright (C) 2007-201
2
Laurent Destailleur <eldy@users.sourceforge.net>
* Copyright (C) ---Put here your own copyright and developer email---
*
* This program is free software; you can redistribute it and/or modify
...
...
@@ -30,8 +30,7 @@
/**
* \class Skeleton_Class
* \brief Put here description of your class
* Put here description of your class
*/
class
Skeleton_Class
// extends CommonObject
{
...
...
@@ -50,7 +49,7 @@ class Skeleton_Class // extends CommonObject
/**
* Constructor
*
* @param
DoliDb $db Database handler
* @param
DoliDb $db Database handler
*/
function
Skeleton_Class
(
$db
)
{
...
...
@@ -62,9 +61,9 @@ class Skeleton_Class // extends CommonObject
/**
* Create object into database
*
* @param
User $user User that create
* @param
int $notrigger 0=launch triggers after, 1=disable triggers
* @return
int <0 if KO, Id of created object if OK
* @param
User $user User that create
* @param int $notrigger 0=launch triggers after, 1=disable triggers
* @return int <0 if KO, Id of created object if OK
*/
function
create
(
$user
,
$notrigger
=
0
)
{
...
...
@@ -136,8 +135,8 @@ class Skeleton_Class // extends CommonObject
/**
* Load object in memory from database
*
* @param
int $id Id object
* @return
int <0 if KO, >0 if OK
* @param
int
$id Id object
* @return int
<0 if KO, >0 if OK
*/
function
fetch
(
$id
)
{
...
...
@@ -179,9 +178,9 @@ class Skeleton_Class // extends CommonObject
/**
* Update object into database
*
* @param
User $user User that modify
* @param
int $notrigger 0=launch triggers after, 1=disable triggers
* @return
int <0 if KO, >0 if OK
* @param
User $user User that modify
* @param int $notrigger 0=launch triggers after, 1=disable triggers
* @return int <0 if KO, >0 if OK
*/
function
update
(
$user
=
0
,
$notrigger
=
0
)
{
...
...
@@ -247,8 +246,8 @@ class Skeleton_Class // extends CommonObject
/**
* Delete object in database
*
* @param
User $user User that delete
* @param
int $notrigger 0=launch triggers after, 1=disable triggers
* @param User $user User that delete
* @param int $notrigger 0=launch triggers after, 1=disable triggers
* @return int <0 if KO, >0 if OK
*/
function
delete
(
$user
,
$notrigger
=
0
)
...
...
@@ -256,15 +255,8 @@ class Skeleton_Class // extends CommonObject
global
$conf
,
$langs
;
$error
=
0
;
$sql
=
"DELETE FROM "
.
MAIN_DB_PREFIX
.
"mytable"
;
$sql
.
=
" WHERE rowid="
.
$this
->
id
;
$this
->
db
->
begin
();
dol_syslog
(
get_class
(
$this
)
.
"::delete sql="
.
$sql
);
$resql
=
$this
->
db
->
query
(
$sql
);
if
(
!
$resql
)
{
$error
++
;
$this
->
errors
[]
=
"Error "
.
$this
->
db
->
lasterror
();
}
if
(
!
$error
)
{
if
(
!
$notrigger
)
...
...
@@ -281,6 +273,16 @@ class Skeleton_Class // extends CommonObject
}
}
if
(
!
$error
)
{
$sql
=
"DELETE FROM "
.
MAIN_DB_PREFIX
.
"mytable"
;
$sql
.
=
" WHERE rowid="
.
$this
->
id
;
dol_syslog
(
get_class
(
$this
)
.
"::delete sql="
.
$sql
);
$resql
=
$this
->
db
->
query
(
$sql
);
if
(
!
$resql
)
{
$error
++
;
$this
->
errors
[]
=
"Error "
.
$this
->
db
->
lasterror
();
}
}
// Commit or rollback
if
(
$error
)
{
...
...
@@ -304,8 +306,8 @@ class Skeleton_Class // extends CommonObject
/**
* Load an object from its id and create a new one in database
*
* @param
int $fromid Id of object to clone
* @return
int New id of clone
* @param
int $fromid Id of object to clone
* @return int New id of clone
*/
function
createFromClone
(
$fromid
)
{
...
...
@@ -339,7 +341,6 @@ class Skeleton_Class // extends CommonObject
{
}
// End
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment