Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
TP-PHP-LPPRISM
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD 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
Sofiane Lasri
TP-PHP-LPPRISM
Commits
9509fe70
Commit
9509fe70
authored
2 years ago
by
Sofiane Lasri
Browse files
Options
Downloads
Patches
Plain Diff
TP7 terminé.
parent
c1c649bc
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
controller/ControleurObjet.php
+27
-0
27 additions, 0 deletions
controller/ControleurObjet.php
index.php
+11
-10
11 additions, 10 deletions
index.php
models/Objet.php
+24
-0
24 additions, 0 deletions
models/Objet.php
with
62 additions
and
10 deletions
controller/ControleurObjet.php
+
27
−
0
View file @
9509fe70
...
@@ -127,4 +127,31 @@ class ControleurObjet
...
@@ -127,4 +127,31 @@ class ControleurObjet
'pageContent'
=>
"Il manque des paramètres dans l'url."
'pageContent'
=>
"Il manque des paramètres dans l'url."
]);
]);
}
}
public
static
function
supprimerObjet
():
string
{
$pageTitle
=
"Suppression d'un(e)
{
$_GET
[
"tableName"
]
}
"
;
if
(
!
empty
(
$_GET
[
"tableName"
])
&&
!
empty
(
$_GET
[
"idName"
])
&&
!
empty
(
$_GET
[
"idValue"
])){
$response
=
Objet
::
deleteObjectById
(
$_GET
[
"tableName"
],
[
"name"
=>
$_GET
[
"idName"
],
"value"
=>
$_GET
[
"idValue"
]
]);
if
(
$response
){
return
view
(
'simple-data'
,
[
'pageTitle'
=>
$pageTitle
,
'pageContent'
=>
"Objet supprimé avec succès."
]);
}
else
{
return
view
(
'simple-data'
,
[
'pageTitle'
=>
$pageTitle
,
'pageContent'
=>
"Erreur lors de la suppression de l'objet."
]);
}
}
return
view
(
'simple-data'
,
[
'pageTitle'
=>
$pageTitle
,
'pageContent'
=>
"Il manque des paramètres dans l'url."
]);
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
index.php
+
11
−
10
View file @
9509fe70
...
@@ -30,6 +30,7 @@ if (empty($_REQUEST["action"])) {
...
@@ -30,6 +30,7 @@ if (empty($_REQUEST["action"])) {
"lireLivres"
=>
ControleurLivre
::
lireLivres
(),
"lireLivres"
=>
ControleurLivre
::
lireLivres
(),
"describeTable"
=>
ControleurObjet
::
describeTable
(),
"describeTable"
=>
ControleurObjet
::
describeTable
(),
"modifierObjet"
=>
ControleurObjet
::
modifyObject
(),
"modifierObjet"
=>
ControleurObjet
::
modifyObject
(),
"supprimerObjet"
=>
ControleurObjet
::
supprimerObjet
(),
default
=>
ControleurAuteur
::
lireAuteur
(),
default
=>
ControleurAuteur
::
lireAuteur
(),
};
};
}
catch
(
Exception
$e
)
{
}
catch
(
Exception
$e
)
{
...
...
This diff is collapsed.
Click to expand it.
models/Objet.php
+
24
−
0
View file @
9509fe70
...
@@ -42,6 +42,7 @@ class Objet
...
@@ -42,6 +42,7 @@ class Objet
public
static
function
addObject
(
String
$tableName
,
array
$columns
)
:
array
public
static
function
addObject
(
String
$tableName
,
array
$columns
)
:
array
{
{
$result
[
"status"
]
=
"success"
;
$result
[
"status"
]
=
"success"
;
$result
[
"message"
]
=
"
$tableName
créé avec succès !"
;
$validation
=
Objet
::
verifyTableAndFormat
(
$tableName
,
$columns
);
$validation
=
Objet
::
verifyTableAndFormat
(
$tableName
,
$columns
);
if
(
$validation
[
"status"
]
!==
"success"
){
if
(
$validation
[
"status"
]
!==
"success"
){
...
@@ -225,4 +226,27 @@ class Objet
...
@@ -225,4 +226,27 @@ class Objet
"message"
=>
"Validation réussie."
"message"
=>
"Validation réussie."
];
];
}
}
public
static
function
deleteObjectById
(
string
$tableName
,
array
$id
):
bool
{
$validation
=
Objet
::
verifyTableAndFormat
(
$tableName
);
if
(
$validation
[
"status"
]
!==
"success"
){
return
false
;
}
if
(
empty
(
$id
[
"name"
])
||
empty
(
$id
[
"value"
])
||
!
isAlphaNumeric
(
$id
[
"name"
])){
return
false
;
}
// On prépare la requête
$queryString
=
(
"DELETE FROM
$tableName
WHERE "
.
$id
[
"name"
]
.
"=?"
);
$insertQuery
=
Database
::
pdo
()
->
prepare
(
$queryString
);
try
{
// Et on l'exécute
$insertQuery
->
execute
([
$id
[
"value"
]]);
}
catch
(
PDOException
$e
)
{
echo
$e
->
getMessage
();
return
false
;
}
return
true
;
}
}
}
\ No newline at end of file
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