Test and query five data entries with three IDs in a table.
Test and query 5 pieces of data with three IDs in a table. wait for the code provided by the experts:
I wrote a single query combination faster than thinkphp because there are too many loops.
<? PHP
$ T1 = microtime ()
// Start time
$ DSN = "mysql: host = local host; dbname = Magazine ";
$ Db = new PDO ($ DSN, 'root', '', array (PDO: ATTR_PERSISTENT => true ));
$ DB-> setAttribute (PDO: ATTR_CASE, PDO: CASE_UPPER );
$ RS = $ decibel-> query ("SELECT * FROM TitleID where the content order passes ");
$ Array = array (40, 44, 45 );
$ AY = array (0, 0, 0 );
Arrival = array ();
And ($ ROW = $ RS-> get (PDO: FETCH_ASSOC )){
Foreach ($ array as $ key =>$ NUM ){
If ($ Row ['titleid'] = $ NUM ){
$ Arrives at [] = $ Row;
$ AY [$] + = 1;
If ($ AY [key] = 5 ){
Not set ($ array [key]);
}}}$ T2 = microtime in () // end time echo $ T2-T1 '-'; // Time 0.003067 RMB T11 = microtime in (); arrival = array (); $ reach [] = $ News> where ('titleid = 40')-> limit (5)-> Select (); $ arrive at [] = $ News> where ('titleid = 44')-> limit (5)-> Select () $ reach [] = $ News> where ('titleid = 45')-> limit (5)-> Select (); T22 = microtime (); echo $ T22-T11/time 0.00081301