PHP Classes

Observation on update method

Recommend this page to a friend!

      PHP DAL  >  All threads  >  Observation on update method  >  (Un) Subscribe thread alerts  
Subject:Observation on update method
Summary:The update function needs more than one criteria for updating
Messages:5
Author:Isaac
Date:2020-04-29 13:23:31
 

  1. Observation on update method   Reply   Report abuse  
Picture of Isaac Isaac - 2020-04-29 13:23:31
Good work done for this DAL Class, I observed that the method / function for updating table in database is having only one parameter for the update key and value, there are circumstances where user will need to update a table meeting two or more criterias, not only one criteria that one will update a table.
thanks.

  2. Re: Observation on update method   Reply   Report abuse  
Picture of mhmd jawad mhmd jawad - 2020-05-03 18:35:47 - In reply to message 1 from Isaac
Thank you for your feedback
I have used the execute_query for when there are more customized queries other than the basic update/delete/insert ones.
However I have considered your thoughts and made two additional functions, one for doing the update you mentioned and another to perform a delete with multiple where clauses, I also added additional glue to choose 'and'/'or' to join there where parameters.
other customized queries can be executed using the execute_query function.
names of functions are criteriaUpdate and criteriaDelete.
Regards.

  3. Re: Observation on update method   Reply   Report abuse  
Picture of ahmad ahmad - 2020-05-08 04:57:09 - In reply to message 2 from mhmd jawad
hi hamoude
fix the line 134:
if($gule == null)
to
if($glue == null)

  4. Re: Observation on update method   Reply   Report abuse  
Picture of mhmd jawad mhmd jawad - 2020-05-10 22:17:37 - In reply to message 3 from ahmad
Corrected
Thank you :)

  5. Re: Observation on update method   Reply   Report abuse  
Picture of Isaac Isaac - 2020-05-13 06:15:00 - In reply to message 4 from mhmd jawad
I'm sorry, I should have commented since, all the typographical bugs have been corrected at my end too, but one logical bug that I couldn't fish out is this:

Given that :
$criteria = array('gender'=>'male','status'=>'active');
$data = array('gender'='female');

When I passed the parameters to the update criteria function, it will not perform the update because both the $criteria and $data has one of the same field attribute 'gender' but returns 1

When I also passed the $criteria and $data with different fields name, it will perform the update and return 1 as output.