mysql - how to use php to select value from a table use some keys -


I want to write a function that takes 2 parameters: one is the name of the table and the other is an associative array of keys Now I have a function:

// $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $ $$$$$$$$$$$$$$$$$$$$$ $ Table; $ I = sizeof ($ keyValues); Forex currency ($ key as $ $ value = & gt; $ val) {if ($ i == 1) $ qry = "WHERE". $ Key "=". $ Kiwal [$ key] ""; Else $ qry = "AND" $ Key "=". $ Keywall [$ key] ""; $ I ++; } // resonance is "query:". $ Qry; $ Result = mysql_query ($ qry) or die ("query $ qry fail."); If the result returned ($ result = mysql_fetch_assoc ($ result)); Second false return; } // GetAllFrom but this is not work Can someone help me in modifying this and can tell me what is Forex ($ key = $ as the original value => gt; ; $ Val) mean? I am confused. Thanks!

You can solve the code, but I will tell you to solve that specific problem Do not try the code, because this is an old inappropriate solution that you want to delete the ASAP later.

What you want to do is to use the PDO adapter

The advantage of doing this is that you get protection from all the evils hidden in user input, Good durations are available, which solve the problems you describe properly.

This is a function that I do to do this in my code, it can look a little bit advanced, but if you consult with manual, then you should not have trouble solving it.

  Select public function ($ table, array $ terms) {$ where = array (); Foreign currency ($ COL $ => $ terms as $ value) {$ input [":" $ col] = $ value; $ Where [] = $ col "=:" $ Col; } $ Sql ​​= "Choose from" $ Table "WHERE". Ipload ("and", $ where); Return (int) $ this- & gt; Ready ($ sql) - & gt; Execute ($ terms) - & gt; GetLastInsertId (); }   

To understand the Forecast Loop, I will read the manual created in the function, I would recommend that

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -