php - Some Tips to properly number SQL queries -


as amateur php developer have problem of mixing sequences , variables.

short :

so tips keep in mind when writing webpage has many sql queries.

i have thought of idea of making function not sure if of good.

long:

the problem have php page has many sql queries followed result, row , row_number, , die() if result unsuccessful after running query.

i number them sql1, result1, row1, error1, mysqlouput1 , sql2.... , on..

when add 1 more query after 5 or 6 days have go through whole code find out last sequence used , take next one, many times use same , creates strange problems.

the same problem variables, same page loading again , again different post , get ids keeping track of variables messy.

so tips keep code sequenced, readable , variable names unique , understandable.

i have though of writing function takes sql input , gives result, row, row count, , error output.

what experienced people suggest ?

thanks.

at first should try use relevant names variables. if lookin users use variables $sqlusers, $queryusers, $resultusers/$usersarray

the idea function 1 way tackle problem, no longer possible code errors in process itself, if not want switch objectoriented programming choose way.

another way mix, create classes in handle database-interactions specific domains. i.e. class userdatahandler have methods getuserbyid(), getallusers() et cetera. way still have write querying process, know queries are, have them in structured way, there no problems naming variables inside methods, , code doesn't messy have different files different domains -> separation of domainspecific code.

can explain problem request-variables($_post , $_get) little more? why site called many different variables, maybe structure application little better.


Comments

Popular posts from this blog

Magento/PHP - Get phones on all members in a customer group -

php - .htaccess mod_rewrite for dynamic url which has domain names -

Website Login Issue developed in magento -