Reference: https://bigprof.com/blog/appgini/a-work ... gini-apps/
I've implemented this feature in my application, I need help for optimize Update and Delete function.
For update I used this code:
Code: Select all
function Tag_before_update(&$data, $memberInfo, &$args) {
//Check for duplicate name
$nomenew = $data['Nome'];
$check = sql("select * from Tag where Nome='$nomenew'", $eo);
if ($check->num_rows == 0) {
//Retrieve current name for REPLACE query
$selectedID = makeSafe($data['selectedID']);
$result = sql("select * from Tag where id='{$selectedID}'", $eo);
if ($result->num_rows > 0) {
while ($row = $result->fetch_assoc()) {
$nomeold = $row['Nome'];
}
}
sql("UPDATE Clients SET Tag = REPLACE(Corsi, '$nomeold', '$nomenew')", $eo);
}
}
Also if you think isn't a good solution I'm here for improve it
Database row Tag can contain array -> Tag1, Tag2, Tag3 ecc...
How I can manage for delete the correct Tag and also keep a correct array?
I think I need to REPLACE for ex. "Tag1" and also "Tag1, " (with space).
Do you have better idea?
Thanks for help!