<? header ( 'Content-type: text/html; charset=UTF-8' ) ; $mysql_host = 'localhost' ; $mysql_username = 'root' ; $mysql_password = '12345' ; $mysql_database = 'test' ; // , $mysql_table1 = 'table1' ; $mysql_table2 = 'table2' ; $memcache_host = 'localhost' ; $memcache_port = 11211 ; $mysql = mysql_connect ( $mysql_host , $mysql_username , $mysql_password ) ; if ( ! $mysql ) die ( " MySQL: $mysql_username @ $mysql_host / $mysql_password " ) ; if ( ! mysql_select_db ( $mysql_database ) ) die ( " : $mysql_database " ) ; $memcache = new Memcache ; if ( ! $memcache -> pconnect ( $memcache_host , $memcache_port ) ) die ( "Memcached : $memcache_host : $memcache_port " ) ; function cacheGet ( $key ) { global $memcache ; return $memcache -> get ( $key ) ; } function cacheSet ( $key , $data , $delay ) { global $memcache ; return $memcache -> set ( $key , $data , 0 , $delay ) ; } function sqlExtractTables ( & $query ) { preg_match_all ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , $query , $tables ) ; if ( ! $tables [ 1 ] ) die ( " , '<<table_name>>': $query " ) ; $query = preg_replace ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , "\ \1 " , $query ) ; return $tables [ 1 ] ; } function sqlQuery ( $query ) { $resource = mysql_query ( $query ) ; if ( ! $resource ) die ( " : $query <br> " . mysql_error ( ) ) ; echo "<b> :</b> $query <br>" ; return $resource ; } function sqlSet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) cacheSet ( $table , uniqid ( time ( ) , true ) , 24 * 3600 ) ; return sqlQuery ( $query ) ; } function sqlGet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) $appendix .= cacheGet ( $table ) ; $appendix = "/*" . md5 ( $appendix ) . "*/" ; $query = $query . $appendix ; $cache_key = md5 ( $query ) ; $result = cacheGet ( $cache_key ) ; if ( $result !== false ) { echo "<b> :</b> $query <br>" ; return $result ; } else echo "<b> :</b> $query <br>" ; $resource = sqlQuery ( $query ) ; $result = array ( ) ; while ( $row = mysql_fetch_assoc ( $resource ) ) { $result [ ] = $row ; } cacheSet ( $cache_key , $result , 3600 ) ; return $result ; } ?> <h2>. </h2> <h3> 2 </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; // "select * from <<$mysql_table1>> where id=1", ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3> </h3> <? sqlSet ( "delete from << $mysql_table2 >> where 1=0" ) ; ?> <h3> </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3>: , . </h3>
<? header ( 'Content-type: text/html; charset=UTF-8' ) ; $mysql_host = 'localhost' ; $mysql_username = 'root' ; $mysql_password = '12345' ; $mysql_database = 'test' ; // , $mysql_table1 = 'table1' ; $mysql_table2 = 'table2' ; $memcache_host = 'localhost' ; $memcache_port = 11211 ; $mysql = mysql_connect ( $mysql_host , $mysql_username , $mysql_password ) ; if ( ! $mysql ) die ( " MySQL: $mysql_username @ $mysql_host / $mysql_password " ) ; if ( ! mysql_select_db ( $mysql_database ) ) die ( " : $mysql_database " ) ; $memcache = new Memcache ; if ( ! $memcache -> pconnect ( $memcache_host , $memcache_port ) ) die ( "Memcached : $memcache_host : $memcache_port " ) ; function cacheGet ( $key ) { global $memcache ; return $memcache -> get ( $key ) ; } function cacheSet ( $key , $data , $delay ) { global $memcache ; return $memcache -> set ( $key , $data , 0 , $delay ) ; } function sqlExtractTables ( & $query ) { preg_match_all ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , $query , $tables ) ; if ( ! $tables [ 1 ] ) die ( " , '<<table_name>>': $query " ) ; $query = preg_replace ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , "\ \1 " , $query ) ; return $tables [ 1 ] ; } function sqlQuery ( $query ) { $resource = mysql_query ( $query ) ; if ( ! $resource ) die ( " : $query <br> " . mysql_error ( ) ) ; echo "<b> :</b> $query <br>" ; return $resource ; } function sqlSet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) cacheSet ( $table , uniqid ( time ( ) , true ) , 24 * 3600 ) ; return sqlQuery ( $query ) ; } function sqlGet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) $appendix .= cacheGet ( $table ) ; $appendix = "/*" . md5 ( $appendix ) . "*/" ; $query = $query . $appendix ; $cache_key = md5 ( $query ) ; $result = cacheGet ( $cache_key ) ; if ( $result !== false ) { echo "<b> :</b> $query <br>" ; return $result ; } else echo "<b> :</b> $query <br>" ; $resource = sqlQuery ( $query ) ; $result = array ( ) ; while ( $row = mysql_fetch_assoc ( $resource ) ) { $result [ ] = $row ; } cacheSet ( $cache_key , $result , 3600 ) ; return $result ; } ?> <h2>. </h2> <h3> 2 </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; // "select * from <<$mysql_table1>> where id=1", ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3> </h3> <? sqlSet ( "delete from << $mysql_table2 >> where 1=0" ) ; ?> <h3> </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3>: , . </h3>
<? header ( 'Content-type: text/html; charset=UTF-8' ) ; $mysql_host = 'localhost' ; $mysql_username = 'root' ; $mysql_password = '12345' ; $mysql_database = 'test' ; // , $mysql_table1 = 'table1' ; $mysql_table2 = 'table2' ; $memcache_host = 'localhost' ; $memcache_port = 11211 ; $mysql = mysql_connect ( $mysql_host , $mysql_username , $mysql_password ) ; if ( ! $mysql ) die ( " MySQL: $mysql_username @ $mysql_host / $mysql_password " ) ; if ( ! mysql_select_db ( $mysql_database ) ) die ( " : $mysql_database " ) ; $memcache = new Memcache ; if ( ! $memcache -> pconnect ( $memcache_host , $memcache_port ) ) die ( "Memcached : $memcache_host : $memcache_port " ) ; function cacheGet ( $key ) { global $memcache ; return $memcache -> get ( $key ) ; } function cacheSet ( $key , $data , $delay ) { global $memcache ; return $memcache -> set ( $key , $data , 0 , $delay ) ; } function sqlExtractTables ( & $query ) { preg_match_all ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , $query , $tables ) ; if ( ! $tables [ 1 ] ) die ( " , '<<table_name>>': $query " ) ; $query = preg_replace ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , "\ \1 " , $query ) ; return $tables [ 1 ] ; } function sqlQuery ( $query ) { $resource = mysql_query ( $query ) ; if ( ! $resource ) die ( " : $query <br> " . mysql_error ( ) ) ; echo "<b> :</b> $query <br>" ; return $resource ; } function sqlSet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) cacheSet ( $table , uniqid ( time ( ) , true ) , 24 * 3600 ) ; return sqlQuery ( $query ) ; } function sqlGet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) $appendix .= cacheGet ( $table ) ; $appendix = "/*" . md5 ( $appendix ) . "*/" ; $query = $query . $appendix ; $cache_key = md5 ( $query ) ; $result = cacheGet ( $cache_key ) ; if ( $result !== false ) { echo "<b> :</b> $query <br>" ; return $result ; } else echo "<b> :</b> $query <br>" ; $resource = sqlQuery ( $query ) ; $result = array ( ) ; while ( $row = mysql_fetch_assoc ( $resource ) ) { $result [ ] = $row ; } cacheSet ( $cache_key , $result , 3600 ) ; return $result ; } ?> <h2>. </h2> <h3> 2 </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; // "select * from <<$mysql_table1>> where id=1", ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3> </h3> <? sqlSet ( "delete from << $mysql_table2 >> where 1=0" ) ; ?> <h3> </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3>: , . </h3>
<? header ( 'Content-type: text/html; charset=UTF-8' ) ; $mysql_host = 'localhost' ; $mysql_username = 'root' ; $mysql_password = '12345' ; $mysql_database = 'test' ; // , $mysql_table1 = 'table1' ; $mysql_table2 = 'table2' ; $memcache_host = 'localhost' ; $memcache_port = 11211 ; $mysql = mysql_connect ( $mysql_host , $mysql_username , $mysql_password ) ; if ( ! $mysql ) die ( " MySQL: $mysql_username @ $mysql_host / $mysql_password " ) ; if ( ! mysql_select_db ( $mysql_database ) ) die ( " : $mysql_database " ) ; $memcache = new Memcache ; if ( ! $memcache -> pconnect ( $memcache_host , $memcache_port ) ) die ( "Memcached : $memcache_host : $memcache_port " ) ; function cacheGet ( $key ) { global $memcache ; return $memcache -> get ( $key ) ; } function cacheSet ( $key , $data , $delay ) { global $memcache ; return $memcache -> set ( $key , $data , 0 , $delay ) ; } function sqlExtractTables ( & $query ) { preg_match_all ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , $query , $tables ) ; if ( ! $tables [ 1 ] ) die ( " , '<<table_name>>': $query " ) ; $query = preg_replace ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , "\ \1 " , $query ) ; return $tables [ 1 ] ; } function sqlQuery ( $query ) { $resource = mysql_query ( $query ) ; if ( ! $resource ) die ( " : $query <br> " . mysql_error ( ) ) ; echo "<b> :</b> $query <br>" ; return $resource ; } function sqlSet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) cacheSet ( $table , uniqid ( time ( ) , true ) , 24 * 3600 ) ; return sqlQuery ( $query ) ; } function sqlGet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) $appendix .= cacheGet ( $table ) ; $appendix = "/*" . md5 ( $appendix ) . "*/" ; $query = $query . $appendix ; $cache_key = md5 ( $query ) ; $result = cacheGet ( $cache_key ) ; if ( $result !== false ) { echo "<b> :</b> $query <br>" ; return $result ; } else echo "<b> :</b> $query <br>" ; $resource = sqlQuery ( $query ) ; $result = array ( ) ; while ( $row = mysql_fetch_assoc ( $resource ) ) { $result [ ] = $row ; } cacheSet ( $cache_key , $result , 3600 ) ; return $result ; } ?> <h2>. </h2> <h3> 2 </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; // "select * from <<$mysql_table1>> where id=1", ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3> </h3> <? sqlSet ( "delete from << $mysql_table2 >> where 1=0" ) ; ?> <h3> </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3>: , . </h3>
<? header ( 'Content-type: text/html; charset=UTF-8' ) ; $mysql_host = 'localhost' ; $mysql_username = 'root' ; $mysql_password = '12345' ; $mysql_database = 'test' ; // , $mysql_table1 = 'table1' ; $mysql_table2 = 'table2' ; $memcache_host = 'localhost' ; $memcache_port = 11211 ; $mysql = mysql_connect ( $mysql_host , $mysql_username , $mysql_password ) ; if ( ! $mysql ) die ( " MySQL: $mysql_username @ $mysql_host / $mysql_password " ) ; if ( ! mysql_select_db ( $mysql_database ) ) die ( " : $mysql_database " ) ; $memcache = new Memcache ; if ( ! $memcache -> pconnect ( $memcache_host , $memcache_port ) ) die ( "Memcached : $memcache_host : $memcache_port " ) ; function cacheGet ( $key ) { global $memcache ; return $memcache -> get ( $key ) ; } function cacheSet ( $key , $data , $delay ) { global $memcache ; return $memcache -> set ( $key , $data , 0 , $delay ) ; } function sqlExtractTables ( & $query ) { preg_match_all ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , $query , $tables ) ; if ( ! $tables [ 1 ] ) die ( " , '<<table_name>>': $query " ) ; $query = preg_replace ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , "\ \1 " , $query ) ; return $tables [ 1 ] ; } function sqlQuery ( $query ) { $resource = mysql_query ( $query ) ; if ( ! $resource ) die ( " : $query <br> " . mysql_error ( ) ) ; echo "<b> :</b> $query <br>" ; return $resource ; } function sqlSet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) cacheSet ( $table , uniqid ( time ( ) , true ) , 24 * 3600 ) ; return sqlQuery ( $query ) ; } function sqlGet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) $appendix .= cacheGet ( $table ) ; $appendix = "/*" . md5 ( $appendix ) . "*/" ; $query = $query . $appendix ; $cache_key = md5 ( $query ) ; $result = cacheGet ( $cache_key ) ; if ( $result !== false ) { echo "<b> :</b> $query <br>" ; return $result ; } else echo "<b> :</b> $query <br>" ; $resource = sqlQuery ( $query ) ; $result = array ( ) ; while ( $row = mysql_fetch_assoc ( $resource ) ) { $result [ ] = $row ; } cacheSet ( $cache_key , $result , 3600 ) ; return $result ; } ?> <h2>. </h2> <h3> 2 </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; // "select * from <<$mysql_table1>> where id=1", ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3> </h3> <? sqlSet ( "delete from << $mysql_table2 >> where 1=0" ) ; ?> <h3> </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3>: , . </h3>
<? header ( 'Content-type: text/html; charset=UTF-8' ) ; $mysql_host = 'localhost' ; $mysql_username = 'root' ; $mysql_password = '12345' ; $mysql_database = 'test' ; // , $mysql_table1 = 'table1' ; $mysql_table2 = 'table2' ; $memcache_host = 'localhost' ; $memcache_port = 11211 ; $mysql = mysql_connect ( $mysql_host , $mysql_username , $mysql_password ) ; if ( ! $mysql ) die ( " MySQL: $mysql_username @ $mysql_host / $mysql_password " ) ; if ( ! mysql_select_db ( $mysql_database ) ) die ( " : $mysql_database " ) ; $memcache = new Memcache ; if ( ! $memcache -> pconnect ( $memcache_host , $memcache_port ) ) die ( "Memcached : $memcache_host : $memcache_port " ) ; function cacheGet ( $key ) { global $memcache ; return $memcache -> get ( $key ) ; } function cacheSet ( $key , $data , $delay ) { global $memcache ; return $memcache -> set ( $key , $data , 0 , $delay ) ; } function sqlExtractTables ( & $query ) { preg_match_all ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , $query , $tables ) ; if ( ! $tables [ 1 ] ) die ( " , '<<table_name>>': $query " ) ; $query = preg_replace ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , "\ \1 " , $query ) ; return $tables [ 1 ] ; } function sqlQuery ( $query ) { $resource = mysql_query ( $query ) ; if ( ! $resource ) die ( " : $query <br> " . mysql_error ( ) ) ; echo "<b> :</b> $query <br>" ; return $resource ; } function sqlSet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) cacheSet ( $table , uniqid ( time ( ) , true ) , 24 * 3600 ) ; return sqlQuery ( $query ) ; } function sqlGet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) $appendix .= cacheGet ( $table ) ; $appendix = "/*" . md5 ( $appendix ) . "*/" ; $query = $query . $appendix ; $cache_key = md5 ( $query ) ; $result = cacheGet ( $cache_key ) ; if ( $result !== false ) { echo "<b> :</b> $query <br>" ; return $result ; } else echo "<b> :</b> $query <br>" ; $resource = sqlQuery ( $query ) ; $result = array ( ) ; while ( $row = mysql_fetch_assoc ( $resource ) ) { $result [ ] = $row ; } cacheSet ( $cache_key , $result , 3600 ) ; return $result ; } ?> <h2>. </h2> <h3> 2 </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; // "select * from <<$mysql_table1>> where id=1", ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3> </h3> <? sqlSet ( "delete from << $mysql_table2 >> where 1=0" ) ; ?> <h3> </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3>: , . </h3>
<? header ( 'Content-type: text/html; charset=UTF-8' ) ; $mysql_host = 'localhost' ; $mysql_username = 'root' ; $mysql_password = '12345' ; $mysql_database = 'test' ; // , $mysql_table1 = 'table1' ; $mysql_table2 = 'table2' ; $memcache_host = 'localhost' ; $memcache_port = 11211 ; $mysql = mysql_connect ( $mysql_host , $mysql_username , $mysql_password ) ; if ( ! $mysql ) die ( " MySQL: $mysql_username @ $mysql_host / $mysql_password " ) ; if ( ! mysql_select_db ( $mysql_database ) ) die ( " : $mysql_database " ) ; $memcache = new Memcache ; if ( ! $memcache -> pconnect ( $memcache_host , $memcache_port ) ) die ( "Memcached : $memcache_host : $memcache_port " ) ; function cacheGet ( $key ) { global $memcache ; return $memcache -> get ( $key ) ; } function cacheSet ( $key , $data , $delay ) { global $memcache ; return $memcache -> set ( $key , $data , 0 , $delay ) ; } function sqlExtractTables ( & $query ) { preg_match_all ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , $query , $tables ) ; if ( ! $tables [ 1 ] ) die ( " , '<<table_name>>': $query " ) ; $query = preg_replace ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , "\ \1 " , $query ) ; return $tables [ 1 ] ; } function sqlQuery ( $query ) { $resource = mysql_query ( $query ) ; if ( ! $resource ) die ( " : $query <br> " . mysql_error ( ) ) ; echo "<b> :</b> $query <br>" ; return $resource ; } function sqlSet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) cacheSet ( $table , uniqid ( time ( ) , true ) , 24 * 3600 ) ; return sqlQuery ( $query ) ; } function sqlGet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) $appendix .= cacheGet ( $table ) ; $appendix = "/*" . md5 ( $appendix ) . "*/" ; $query = $query . $appendix ; $cache_key = md5 ( $query ) ; $result = cacheGet ( $cache_key ) ; if ( $result !== false ) { echo "<b> :</b> $query <br>" ; return $result ; } else echo "<b> :</b> $query <br>" ; $resource = sqlQuery ( $query ) ; $result = array ( ) ; while ( $row = mysql_fetch_assoc ( $resource ) ) { $result [ ] = $row ; } cacheSet ( $cache_key , $result , 3600 ) ; return $result ; } ?> <h2>. </h2> <h3> 2 </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; // "select * from <<$mysql_table1>> where id=1", ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3> </h3> <? sqlSet ( "delete from << $mysql_table2 >> where 1=0" ) ; ?> <h3> </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3>: , . </h3>
<? header ( 'Content-type: text/html; charset=UTF-8' ) ; $mysql_host = 'localhost' ; $mysql_username = 'root' ; $mysql_password = '12345' ; $mysql_database = 'test' ; // , $mysql_table1 = 'table1' ; $mysql_table2 = 'table2' ; $memcache_host = 'localhost' ; $memcache_port = 11211 ; $mysql = mysql_connect ( $mysql_host , $mysql_username , $mysql_password ) ; if ( ! $mysql ) die ( " MySQL: $mysql_username @ $mysql_host / $mysql_password " ) ; if ( ! mysql_select_db ( $mysql_database ) ) die ( " : $mysql_database " ) ; $memcache = new Memcache ; if ( ! $memcache -> pconnect ( $memcache_host , $memcache_port ) ) die ( "Memcached : $memcache_host : $memcache_port " ) ; function cacheGet ( $key ) { global $memcache ; return $memcache -> get ( $key ) ; } function cacheSet ( $key , $data , $delay ) { global $memcache ; return $memcache -> set ( $key , $data , 0 , $delay ) ; } function sqlExtractTables ( & $query ) { preg_match_all ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , $query , $tables ) ; if ( ! $tables [ 1 ] ) die ( " , '<<table_name>>': $query " ) ; $query = preg_replace ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , "\ \1 " , $query ) ; return $tables [ 1 ] ; } function sqlQuery ( $query ) { $resource = mysql_query ( $query ) ; if ( ! $resource ) die ( " : $query <br> " . mysql_error ( ) ) ; echo "<b> :</b> $query <br>" ; return $resource ; } function sqlSet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) cacheSet ( $table , uniqid ( time ( ) , true ) , 24 * 3600 ) ; return sqlQuery ( $query ) ; } function sqlGet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) $appendix .= cacheGet ( $table ) ; $appendix = "/*" . md5 ( $appendix ) . "*/" ; $query = $query . $appendix ; $cache_key = md5 ( $query ) ; $result = cacheGet ( $cache_key ) ; if ( $result !== false ) { echo "<b> :</b> $query <br>" ; return $result ; } else echo "<b> :</b> $query <br>" ; $resource = sqlQuery ( $query ) ; $result = array ( ) ; while ( $row = mysql_fetch_assoc ( $resource ) ) { $result [ ] = $row ; } cacheSet ( $cache_key , $result , 3600 ) ; return $result ; } ?> <h2>. </h2> <h3> 2 </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; // "select * from <<$mysql_table1>> where id=1", ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3> </h3> <? sqlSet ( "delete from << $mysql_table2 >> where 1=0" ) ; ?> <h3> </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3>: , . </h3>
<? header ( 'Content-type: text/html; charset=UTF-8' ) ; $mysql_host = 'localhost' ; $mysql_username = 'root' ; $mysql_password = '12345' ; $mysql_database = 'test' ; // , $mysql_table1 = 'table1' ; $mysql_table2 = 'table2' ; $memcache_host = 'localhost' ; $memcache_port = 11211 ; $mysql = mysql_connect ( $mysql_host , $mysql_username , $mysql_password ) ; if ( ! $mysql ) die ( " MySQL: $mysql_username @ $mysql_host / $mysql_password " ) ; if ( ! mysql_select_db ( $mysql_database ) ) die ( " : $mysql_database " ) ; $memcache = new Memcache ; if ( ! $memcache -> pconnect ( $memcache_host , $memcache_port ) ) die ( "Memcached : $memcache_host : $memcache_port " ) ; function cacheGet ( $key ) { global $memcache ; return $memcache -> get ( $key ) ; } function cacheSet ( $key , $data , $delay ) { global $memcache ; return $memcache -> set ( $key , $data , 0 , $delay ) ; } function sqlExtractTables ( & $query ) { preg_match_all ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , $query , $tables ) ; if ( ! $tables [ 1 ] ) die ( " , '<<table_name>>': $query " ) ; $query = preg_replace ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , "\ \1 " , $query ) ; return $tables [ 1 ] ; } function sqlQuery ( $query ) { $resource = mysql_query ( $query ) ; if ( ! $resource ) die ( " : $query <br> " . mysql_error ( ) ) ; echo "<b> :</b> $query <br>" ; return $resource ; } function sqlSet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) cacheSet ( $table , uniqid ( time ( ) , true ) , 24 * 3600 ) ; return sqlQuery ( $query ) ; } function sqlGet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) $appendix .= cacheGet ( $table ) ; $appendix = "/*" . md5 ( $appendix ) . "*/" ; $query = $query . $appendix ; $cache_key = md5 ( $query ) ; $result = cacheGet ( $cache_key ) ; if ( $result !== false ) { echo "<b> :</b> $query <br>" ; return $result ; } else echo "<b> :</b> $query <br>" ; $resource = sqlQuery ( $query ) ; $result = array ( ) ; while ( $row = mysql_fetch_assoc ( $resource ) ) { $result [ ] = $row ; } cacheSet ( $cache_key , $result , 3600 ) ; return $result ; } ?> <h2>. </h2> <h3> 2 </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; // "select * from <<$mysql_table1>> where id=1", ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3> </h3> <? sqlSet ( "delete from << $mysql_table2 >> where 1=0" ) ; ?> <h3> </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3>: , . </h3>
<? header ( 'Content-type: text/html; charset=UTF-8' ) ; $mysql_host = 'localhost' ; $mysql_username = 'root' ; $mysql_password = '12345' ; $mysql_database = 'test' ; // , $mysql_table1 = 'table1' ; $mysql_table2 = 'table2' ; $memcache_host = 'localhost' ; $memcache_port = 11211 ; $mysql = mysql_connect ( $mysql_host , $mysql_username , $mysql_password ) ; if ( ! $mysql ) die ( " MySQL: $mysql_username @ $mysql_host / $mysql_password " ) ; if ( ! mysql_select_db ( $mysql_database ) ) die ( " : $mysql_database " ) ; $memcache = new Memcache ; if ( ! $memcache -> pconnect ( $memcache_host , $memcache_port ) ) die ( "Memcached : $memcache_host : $memcache_port " ) ; function cacheGet ( $key ) { global $memcache ; return $memcache -> get ( $key ) ; } function cacheSet ( $key , $data , $delay ) { global $memcache ; return $memcache -> set ( $key , $data , 0 , $delay ) ; } function sqlExtractTables ( & $query ) { preg_match_all ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , $query , $tables ) ; if ( ! $tables [ 1 ] ) die ( " , '<<table_name>>': $query " ) ; $query = preg_replace ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , "\ \1 " , $query ) ; return $tables [ 1 ] ; } function sqlQuery ( $query ) { $resource = mysql_query ( $query ) ; if ( ! $resource ) die ( " : $query <br> " . mysql_error ( ) ) ; echo "<b> :</b> $query <br>" ; return $resource ; } function sqlSet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) cacheSet ( $table , uniqid ( time ( ) , true ) , 24 * 3600 ) ; return sqlQuery ( $query ) ; } function sqlGet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) $appendix .= cacheGet ( $table ) ; $appendix = "/*" . md5 ( $appendix ) . "*/" ; $query = $query . $appendix ; $cache_key = md5 ( $query ) ; $result = cacheGet ( $cache_key ) ; if ( $result !== false ) { echo "<b> :</b> $query <br>" ; return $result ; } else echo "<b> :</b> $query <br>" ; $resource = sqlQuery ( $query ) ; $result = array ( ) ; while ( $row = mysql_fetch_assoc ( $resource ) ) { $result [ ] = $row ; } cacheSet ( $cache_key , $result , 3600 ) ; return $result ; } ?> <h2>. </h2> <h3> 2 </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; // "select * from <<$mysql_table1>> where id=1", ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3> </h3> <? sqlSet ( "delete from << $mysql_table2 >> where 1=0" ) ; ?> <h3> </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3>: , . </h3>
<? header ( 'Content-type: text/html; charset=UTF-8' ) ; $mysql_host = 'localhost' ; $mysql_username = 'root' ; $mysql_password = '12345' ; $mysql_database = 'test' ; // , $mysql_table1 = 'table1' ; $mysql_table2 = 'table2' ; $memcache_host = 'localhost' ; $memcache_port = 11211 ; $mysql = mysql_connect ( $mysql_host , $mysql_username , $mysql_password ) ; if ( ! $mysql ) die ( " MySQL: $mysql_username @ $mysql_host / $mysql_password " ) ; if ( ! mysql_select_db ( $mysql_database ) ) die ( " : $mysql_database " ) ; $memcache = new Memcache ; if ( ! $memcache -> pconnect ( $memcache_host , $memcache_port ) ) die ( "Memcached : $memcache_host : $memcache_port " ) ; function cacheGet ( $key ) { global $memcache ; return $memcache -> get ( $key ) ; } function cacheSet ( $key , $data , $delay ) { global $memcache ; return $memcache -> set ( $key , $data , 0 , $delay ) ; } function sqlExtractTables ( & $query ) { preg_match_all ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , $query , $tables ) ; if ( ! $tables [ 1 ] ) die ( " , '<<table_name>>': $query " ) ; $query = preg_replace ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , "\ \1 " , $query ) ; return $tables [ 1 ] ; } function sqlQuery ( $query ) { $resource = mysql_query ( $query ) ; if ( ! $resource ) die ( " : $query <br> " . mysql_error ( ) ) ; echo "<b> :</b> $query <br>" ; return $resource ; } function sqlSet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) cacheSet ( $table , uniqid ( time ( ) , true ) , 24 * 3600 ) ; return sqlQuery ( $query ) ; } function sqlGet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) $appendix .= cacheGet ( $table ) ; $appendix = "/*" . md5 ( $appendix ) . "*/" ; $query = $query . $appendix ; $cache_key = md5 ( $query ) ; $result = cacheGet ( $cache_key ) ; if ( $result !== false ) { echo "<b> :</b> $query <br>" ; return $result ; } else echo "<b> :</b> $query <br>" ; $resource = sqlQuery ( $query ) ; $result = array ( ) ; while ( $row = mysql_fetch_assoc ( $resource ) ) { $result [ ] = $row ; } cacheSet ( $cache_key , $result , 3600 ) ; return $result ; } ?> <h2>. </h2> <h3> 2 </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; // "select * from <<$mysql_table1>> where id=1", ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3> </h3> <? sqlSet ( "delete from << $mysql_table2 >> where 1=0" ) ; ?> <h3> </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3>: , . </h3>
<? header ( 'Content-type: text/html; charset=UTF-8' ) ; $mysql_host = 'localhost' ; $mysql_username = 'root' ; $mysql_password = '12345' ; $mysql_database = 'test' ; // , $mysql_table1 = 'table1' ; $mysql_table2 = 'table2' ; $memcache_host = 'localhost' ; $memcache_port = 11211 ; $mysql = mysql_connect ( $mysql_host , $mysql_username , $mysql_password ) ; if ( ! $mysql ) die ( " MySQL: $mysql_username @ $mysql_host / $mysql_password " ) ; if ( ! mysql_select_db ( $mysql_database ) ) die ( " : $mysql_database " ) ; $memcache = new Memcache ; if ( ! $memcache -> pconnect ( $memcache_host , $memcache_port ) ) die ( "Memcached : $memcache_host : $memcache_port " ) ; function cacheGet ( $key ) { global $memcache ; return $memcache -> get ( $key ) ; } function cacheSet ( $key , $data , $delay ) { global $memcache ; return $memcache -> set ( $key , $data , 0 , $delay ) ; } function sqlExtractTables ( & $query ) { preg_match_all ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , $query , $tables ) ; if ( ! $tables [ 1 ] ) die ( " , '<<table_name>>': $query " ) ; $query = preg_replace ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , "\ \1 " , $query ) ; return $tables [ 1 ] ; } function sqlQuery ( $query ) { $resource = mysql_query ( $query ) ; if ( ! $resource ) die ( " : $query <br> " . mysql_error ( ) ) ; echo "<b> :</b> $query <br>" ; return $resource ; } function sqlSet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) cacheSet ( $table , uniqid ( time ( ) , true ) , 24 * 3600 ) ; return sqlQuery ( $query ) ; } function sqlGet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) $appendix .= cacheGet ( $table ) ; $appendix = "/*" . md5 ( $appendix ) . "*/" ; $query = $query . $appendix ; $cache_key = md5 ( $query ) ; $result = cacheGet ( $cache_key ) ; if ( $result !== false ) { echo "<b> :</b> $query <br>" ; return $result ; } else echo "<b> :</b> $query <br>" ; $resource = sqlQuery ( $query ) ; $result = array ( ) ; while ( $row = mysql_fetch_assoc ( $resource ) ) { $result [ ] = $row ; } cacheSet ( $cache_key , $result , 3600 ) ; return $result ; } ?> <h2>. </h2> <h3> 2 </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; // "select * from <<$mysql_table1>> where id=1", ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3> </h3> <? sqlSet ( "delete from << $mysql_table2 >> where 1=0" ) ; ?> <h3> </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3>: , . </h3>
<? header ( 'Content-type: text/html; charset=UTF-8' ) ; $mysql_host = 'localhost' ; $mysql_username = 'root' ; $mysql_password = '12345' ; $mysql_database = 'test' ; // , $mysql_table1 = 'table1' ; $mysql_table2 = 'table2' ; $memcache_host = 'localhost' ; $memcache_port = 11211 ; $mysql = mysql_connect ( $mysql_host , $mysql_username , $mysql_password ) ; if ( ! $mysql ) die ( " MySQL: $mysql_username @ $mysql_host / $mysql_password " ) ; if ( ! mysql_select_db ( $mysql_database ) ) die ( " : $mysql_database " ) ; $memcache = new Memcache ; if ( ! $memcache -> pconnect ( $memcache_host , $memcache_port ) ) die ( "Memcached : $memcache_host : $memcache_port " ) ; function cacheGet ( $key ) { global $memcache ; return $memcache -> get ( $key ) ; } function cacheSet ( $key , $data , $delay ) { global $memcache ; return $memcache -> set ( $key , $data , 0 , $delay ) ; } function sqlExtractTables ( & $query ) { preg_match_all ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , $query , $tables ) ; if ( ! $tables [ 1 ] ) die ( " , '<<table_name>>': $query " ) ; $query = preg_replace ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , "\ \1 " , $query ) ; return $tables [ 1 ] ; } function sqlQuery ( $query ) { $resource = mysql_query ( $query ) ; if ( ! $resource ) die ( " : $query <br> " . mysql_error ( ) ) ; echo "<b> :</b> $query <br>" ; return $resource ; } function sqlSet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) cacheSet ( $table , uniqid ( time ( ) , true ) , 24 * 3600 ) ; return sqlQuery ( $query ) ; } function sqlGet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) $appendix .= cacheGet ( $table ) ; $appendix = "/*" . md5 ( $appendix ) . "*/" ; $query = $query . $appendix ; $cache_key = md5 ( $query ) ; $result = cacheGet ( $cache_key ) ; if ( $result !== false ) { echo "<b> :</b> $query <br>" ; return $result ; } else echo "<b> :</b> $query <br>" ; $resource = sqlQuery ( $query ) ; $result = array ( ) ; while ( $row = mysql_fetch_assoc ( $resource ) ) { $result [ ] = $row ; } cacheSet ( $cache_key , $result , 3600 ) ; return $result ; } ?> <h2>. </h2> <h3> 2 </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; // "select * from <<$mysql_table1>> where id=1", ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3> </h3> <? sqlSet ( "delete from << $mysql_table2 >> where 1=0" ) ; ?> <h3> </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3>: , . </h3>
<? header ( 'Content-type: text/html; charset=UTF-8' ) ; $mysql_host = 'localhost' ; $mysql_username = 'root' ; $mysql_password = '12345' ; $mysql_database = 'test' ; // , $mysql_table1 = 'table1' ; $mysql_table2 = 'table2' ; $memcache_host = 'localhost' ; $memcache_port = 11211 ; $mysql = mysql_connect ( $mysql_host , $mysql_username , $mysql_password ) ; if ( ! $mysql ) die ( " MySQL: $mysql_username @ $mysql_host / $mysql_password " ) ; if ( ! mysql_select_db ( $mysql_database ) ) die ( " : $mysql_database " ) ; $memcache = new Memcache ; if ( ! $memcache -> pconnect ( $memcache_host , $memcache_port ) ) die ( "Memcached : $memcache_host : $memcache_port " ) ; function cacheGet ( $key ) { global $memcache ; return $memcache -> get ( $key ) ; } function cacheSet ( $key , $data , $delay ) { global $memcache ; return $memcache -> set ( $key , $data , 0 , $delay ) ; } function sqlExtractTables ( & $query ) { preg_match_all ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , $query , $tables ) ; if ( ! $tables [ 1 ] ) die ( " , '<<table_name>>': $query " ) ; $query = preg_replace ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , "\ \1 " , $query ) ; return $tables [ 1 ] ; } function sqlQuery ( $query ) { $resource = mysql_query ( $query ) ; if ( ! $resource ) die ( " : $query <br> " . mysql_error ( ) ) ; echo "<b> :</b> $query <br>" ; return $resource ; } function sqlSet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) cacheSet ( $table , uniqid ( time ( ) , true ) , 24 * 3600 ) ; return sqlQuery ( $query ) ; } function sqlGet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) $appendix .= cacheGet ( $table ) ; $appendix = "/*" . md5 ( $appendix ) . "*/" ; $query = $query . $appendix ; $cache_key = md5 ( $query ) ; $result = cacheGet ( $cache_key ) ; if ( $result !== false ) { echo "<b> :</b> $query <br>" ; return $result ; } else echo "<b> :</b> $query <br>" ; $resource = sqlQuery ( $query ) ; $result = array ( ) ; while ( $row = mysql_fetch_assoc ( $resource ) ) { $result [ ] = $row ; } cacheSet ( $cache_key , $result , 3600 ) ; return $result ; } ?> <h2>. </h2> <h3> 2 </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; // "select * from <<$mysql_table1>> where id=1", ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3> </h3> <? sqlSet ( "delete from << $mysql_table2 >> where 1=0" ) ; ?> <h3> </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3>: , . </h3>
<? header ( 'Content-type: text/html; charset=UTF-8' ) ; $mysql_host = 'localhost' ; $mysql_username = 'root' ; $mysql_password = '12345' ; $mysql_database = 'test' ; // , $mysql_table1 = 'table1' ; $mysql_table2 = 'table2' ; $memcache_host = 'localhost' ; $memcache_port = 11211 ; $mysql = mysql_connect ( $mysql_host , $mysql_username , $mysql_password ) ; if ( ! $mysql ) die ( " MySQL: $mysql_username @ $mysql_host / $mysql_password " ) ; if ( ! mysql_select_db ( $mysql_database ) ) die ( " : $mysql_database " ) ; $memcache = new Memcache ; if ( ! $memcache -> pconnect ( $memcache_host , $memcache_port ) ) die ( "Memcached : $memcache_host : $memcache_port " ) ; function cacheGet ( $key ) { global $memcache ; return $memcache -> get ( $key ) ; } function cacheSet ( $key , $data , $delay ) { global $memcache ; return $memcache -> set ( $key , $data , 0 , $delay ) ; } function sqlExtractTables ( & $query ) { preg_match_all ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , $query , $tables ) ; if ( ! $tables [ 1 ] ) die ( " , '<<table_name>>': $query " ) ; $query = preg_replace ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , "\ \1 " , $query ) ; return $tables [ 1 ] ; } function sqlQuery ( $query ) { $resource = mysql_query ( $query ) ; if ( ! $resource ) die ( " : $query <br> " . mysql_error ( ) ) ; echo "<b> :</b> $query <br>" ; return $resource ; } function sqlSet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) cacheSet ( $table , uniqid ( time ( ) , true ) , 24 * 3600 ) ; return sqlQuery ( $query ) ; } function sqlGet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) $appendix .= cacheGet ( $table ) ; $appendix = "/*" . md5 ( $appendix ) . "*/" ; $query = $query . $appendix ; $cache_key = md5 ( $query ) ; $result = cacheGet ( $cache_key ) ; if ( $result !== false ) { echo "<b> :</b> $query <br>" ; return $result ; } else echo "<b> :</b> $query <br>" ; $resource = sqlQuery ( $query ) ; $result = array ( ) ; while ( $row = mysql_fetch_assoc ( $resource ) ) { $result [ ] = $row ; } cacheSet ( $cache_key , $result , 3600 ) ; return $result ; } ?> <h2>. </h2> <h3> 2 </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; // "select * from <<$mysql_table1>> where id=1", ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3> </h3> <? sqlSet ( "delete from << $mysql_table2 >> where 1=0" ) ; ?> <h3> </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3>: , . </h3>
<? header ( 'Content-type: text/html; charset=UTF-8' ) ; $mysql_host = 'localhost' ; $mysql_username = 'root' ; $mysql_password = '12345' ; $mysql_database = 'test' ; // , $mysql_table1 = 'table1' ; $mysql_table2 = 'table2' ; $memcache_host = 'localhost' ; $memcache_port = 11211 ; $mysql = mysql_connect ( $mysql_host , $mysql_username , $mysql_password ) ; if ( ! $mysql ) die ( " MySQL: $mysql_username @ $mysql_host / $mysql_password " ) ; if ( ! mysql_select_db ( $mysql_database ) ) die ( " : $mysql_database " ) ; $memcache = new Memcache ; if ( ! $memcache -> pconnect ( $memcache_host , $memcache_port ) ) die ( "Memcached : $memcache_host : $memcache_port " ) ; function cacheGet ( $key ) { global $memcache ; return $memcache -> get ( $key ) ; } function cacheSet ( $key , $data , $delay ) { global $memcache ; return $memcache -> set ( $key , $data , 0 , $delay ) ; } function sqlExtractTables ( & $query ) { preg_match_all ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , $query , $tables ) ; if ( ! $tables [ 1 ] ) die ( " , '<<table_name>>': $query " ) ; $query = preg_replace ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , "\ \1 " , $query ) ; return $tables [ 1 ] ; } function sqlQuery ( $query ) { $resource = mysql_query ( $query ) ; if ( ! $resource ) die ( " : $query <br> " . mysql_error ( ) ) ; echo "<b> :</b> $query <br>" ; return $resource ; } function sqlSet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) cacheSet ( $table , uniqid ( time ( ) , true ) , 24 * 3600 ) ; return sqlQuery ( $query ) ; } function sqlGet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) $appendix .= cacheGet ( $table ) ; $appendix = "/*" . md5 ( $appendix ) . "*/" ; $query = $query . $appendix ; $cache_key = md5 ( $query ) ; $result = cacheGet ( $cache_key ) ; if ( $result !== false ) { echo "<b> :</b> $query <br>" ; return $result ; } else echo "<b> :</b> $query <br>" ; $resource = sqlQuery ( $query ) ; $result = array ( ) ; while ( $row = mysql_fetch_assoc ( $resource ) ) { $result [ ] = $row ; } cacheSet ( $cache_key , $result , 3600 ) ; return $result ; } ?> <h2>. </h2> <h3> 2 </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; // "select * from <<$mysql_table1>> where id=1", ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3> </h3> <? sqlSet ( "delete from << $mysql_table2 >> where 1=0" ) ; ?> <h3> </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3>: , . </h3>
<? header ( 'Content-type: text/html; charset=UTF-8' ) ; $mysql_host = 'localhost' ; $mysql_username = 'root' ; $mysql_password = '12345' ; $mysql_database = 'test' ; // , $mysql_table1 = 'table1' ; $mysql_table2 = 'table2' ; $memcache_host = 'localhost' ; $memcache_port = 11211 ; $mysql = mysql_connect ( $mysql_host , $mysql_username , $mysql_password ) ; if ( ! $mysql ) die ( " MySQL: $mysql_username @ $mysql_host / $mysql_password " ) ; if ( ! mysql_select_db ( $mysql_database ) ) die ( " : $mysql_database " ) ; $memcache = new Memcache ; if ( ! $memcache -> pconnect ( $memcache_host , $memcache_port ) ) die ( "Memcached : $memcache_host : $memcache_port " ) ; function cacheGet ( $key ) { global $memcache ; return $memcache -> get ( $key ) ; } function cacheSet ( $key , $data , $delay ) { global $memcache ; return $memcache -> set ( $key , $data , 0 , $delay ) ; } function sqlExtractTables ( & $query ) { preg_match_all ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , $query , $tables ) ; if ( ! $tables [ 1 ] ) die ( " , '<<table_name>>': $query " ) ; $query = preg_replace ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , "\ \1 " , $query ) ; return $tables [ 1 ] ; } function sqlQuery ( $query ) { $resource = mysql_query ( $query ) ; if ( ! $resource ) die ( " : $query <br> " . mysql_error ( ) ) ; echo "<b> :</b> $query <br>" ; return $resource ; } function sqlSet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) cacheSet ( $table , uniqid ( time ( ) , true ) , 24 * 3600 ) ; return sqlQuery ( $query ) ; } function sqlGet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) $appendix .= cacheGet ( $table ) ; $appendix = "/*" . md5 ( $appendix ) . "*/" ; $query = $query . $appendix ; $cache_key = md5 ( $query ) ; $result = cacheGet ( $cache_key ) ; if ( $result !== false ) { echo "<b> :</b> $query <br>" ; return $result ; } else echo "<b> :</b> $query <br>" ; $resource = sqlQuery ( $query ) ; $result = array ( ) ; while ( $row = mysql_fetch_assoc ( $resource ) ) { $result [ ] = $row ; } cacheSet ( $cache_key , $result , 3600 ) ; return $result ; } ?> <h2>. </h2> <h3> 2 </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; // "select * from <<$mysql_table1>> where id=1", ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3> </h3> <? sqlSet ( "delete from << $mysql_table2 >> where 1=0" ) ; ?> <h3> </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3>: , . </h3>
<? header ( 'Content-type: text/html; charset=UTF-8' ) ; $mysql_host = 'localhost' ; $mysql_username = 'root' ; $mysql_password = '12345' ; $mysql_database = 'test' ; // , $mysql_table1 = 'table1' ; $mysql_table2 = 'table2' ; $memcache_host = 'localhost' ; $memcache_port = 11211 ; $mysql = mysql_connect ( $mysql_host , $mysql_username , $mysql_password ) ; if ( ! $mysql ) die ( " MySQL: $mysql_username @ $mysql_host / $mysql_password " ) ; if ( ! mysql_select_db ( $mysql_database ) ) die ( " : $mysql_database " ) ; $memcache = new Memcache ; if ( ! $memcache -> pconnect ( $memcache_host , $memcache_port ) ) die ( "Memcached : $memcache_host : $memcache_port " ) ; function cacheGet ( $key ) { global $memcache ; return $memcache -> get ( $key ) ; } function cacheSet ( $key , $data , $delay ) { global $memcache ; return $memcache -> set ( $key , $data , 0 , $delay ) ; } function sqlExtractTables ( & $query ) { preg_match_all ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , $query , $tables ) ; if ( ! $tables [ 1 ] ) die ( " , '<<table_name>>': $query " ) ; $query = preg_replace ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , "\ \1 " , $query ) ; return $tables [ 1 ] ; } function sqlQuery ( $query ) { $resource = mysql_query ( $query ) ; if ( ! $resource ) die ( " : $query <br> " . mysql_error ( ) ) ; echo "<b> :</b> $query <br>" ; return $resource ; } function sqlSet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) cacheSet ( $table , uniqid ( time ( ) , true ) , 24 * 3600 ) ; return sqlQuery ( $query ) ; } function sqlGet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) $appendix .= cacheGet ( $table ) ; $appendix = "/*" . md5 ( $appendix ) . "*/" ; $query = $query . $appendix ; $cache_key = md5 ( $query ) ; $result = cacheGet ( $cache_key ) ; if ( $result !== false ) { echo "<b> :</b> $query <br>" ; return $result ; } else echo "<b> :</b> $query <br>" ; $resource = sqlQuery ( $query ) ; $result = array ( ) ; while ( $row = mysql_fetch_assoc ( $resource ) ) { $result [ ] = $row ; } cacheSet ( $cache_key , $result , 3600 ) ; return $result ; } ?> <h2>. </h2> <h3> 2 </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; // "select * from <<$mysql_table1>> where id=1", ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3> </h3> <? sqlSet ( "delete from << $mysql_table2 >> where 1=0" ) ; ?> <h3> </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3>: , . </h3>
<? header ( 'Content-type: text/html; charset=UTF-8' ) ; $mysql_host = 'localhost' ; $mysql_username = 'root' ; $mysql_password = '12345' ; $mysql_database = 'test' ; // , $mysql_table1 = 'table1' ; $mysql_table2 = 'table2' ; $memcache_host = 'localhost' ; $memcache_port = 11211 ; $mysql = mysql_connect ( $mysql_host , $mysql_username , $mysql_password ) ; if ( ! $mysql ) die ( " MySQL: $mysql_username @ $mysql_host / $mysql_password " ) ; if ( ! mysql_select_db ( $mysql_database ) ) die ( " : $mysql_database " ) ; $memcache = new Memcache ; if ( ! $memcache -> pconnect ( $memcache_host , $memcache_port ) ) die ( "Memcached : $memcache_host : $memcache_port " ) ; function cacheGet ( $key ) { global $memcache ; return $memcache -> get ( $key ) ; } function cacheSet ( $key , $data , $delay ) { global $memcache ; return $memcache -> set ( $key , $data , 0 , $delay ) ; } function sqlExtractTables ( & $query ) { preg_match_all ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , $query , $tables ) ; if ( ! $tables [ 1 ] ) die ( " , '<<table_name>>': $query " ) ; $query = preg_replace ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , "\ \1 " , $query ) ; return $tables [ 1 ] ; } function sqlQuery ( $query ) { $resource = mysql_query ( $query ) ; if ( ! $resource ) die ( " : $query <br> " . mysql_error ( ) ) ; echo "<b> :</b> $query <br>" ; return $resource ; } function sqlSet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) cacheSet ( $table , uniqid ( time ( ) , true ) , 24 * 3600 ) ; return sqlQuery ( $query ) ; } function sqlGet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) $appendix .= cacheGet ( $table ) ; $appendix = "/*" . md5 ( $appendix ) . "*/" ; $query = $query . $appendix ; $cache_key = md5 ( $query ) ; $result = cacheGet ( $cache_key ) ; if ( $result !== false ) { echo "<b> :</b> $query <br>" ; return $result ; } else echo "<b> :</b> $query <br>" ; $resource = sqlQuery ( $query ) ; $result = array ( ) ; while ( $row = mysql_fetch_assoc ( $resource ) ) { $result [ ] = $row ; } cacheSet ( $cache_key , $result , 3600 ) ; return $result ; } ?> <h2>. </h2> <h3> 2 </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; // "select * from <<$mysql_table1>> where id=1", ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3> </h3> <? sqlSet ( "delete from << $mysql_table2 >> where 1=0" ) ; ?> <h3> </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3>: , . </h3>
<? header ( 'Content-type: text/html; charset=UTF-8' ) ; $mysql_host = 'localhost' ; $mysql_username = 'root' ; $mysql_password = '12345' ; $mysql_database = 'test' ; // , $mysql_table1 = 'table1' ; $mysql_table2 = 'table2' ; $memcache_host = 'localhost' ; $memcache_port = 11211 ; $mysql = mysql_connect ( $mysql_host , $mysql_username , $mysql_password ) ; if ( ! $mysql ) die ( " MySQL: $mysql_username @ $mysql_host / $mysql_password " ) ; if ( ! mysql_select_db ( $mysql_database ) ) die ( " : $mysql_database " ) ; $memcache = new Memcache ; if ( ! $memcache -> pconnect ( $memcache_host , $memcache_port ) ) die ( "Memcached : $memcache_host : $memcache_port " ) ; function cacheGet ( $key ) { global $memcache ; return $memcache -> get ( $key ) ; } function cacheSet ( $key , $data , $delay ) { global $memcache ; return $memcache -> set ( $key , $data , 0 , $delay ) ; } function sqlExtractTables ( & $query ) { preg_match_all ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , $query , $tables ) ; if ( ! $tables [ 1 ] ) die ( " , '<<table_name>>': $query " ) ; $query = preg_replace ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , "\ \1 " , $query ) ; return $tables [ 1 ] ; } function sqlQuery ( $query ) { $resource = mysql_query ( $query ) ; if ( ! $resource ) die ( " : $query <br> " . mysql_error ( ) ) ; echo "<b> :</b> $query <br>" ; return $resource ; } function sqlSet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) cacheSet ( $table , uniqid ( time ( ) , true ) , 24 * 3600 ) ; return sqlQuery ( $query ) ; } function sqlGet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) $appendix .= cacheGet ( $table ) ; $appendix = "/*" . md5 ( $appendix ) . "*/" ; $query = $query . $appendix ; $cache_key = md5 ( $query ) ; $result = cacheGet ( $cache_key ) ; if ( $result !== false ) { echo "<b> :</b> $query <br>" ; return $result ; } else echo "<b> :</b> $query <br>" ; $resource = sqlQuery ( $query ) ; $result = array ( ) ; while ( $row = mysql_fetch_assoc ( $resource ) ) { $result [ ] = $row ; } cacheSet ( $cache_key , $result , 3600 ) ; return $result ; } ?> <h2>. </h2> <h3> 2 </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; // "select * from <<$mysql_table1>> where id=1", ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3> </h3> <? sqlSet ( "delete from << $mysql_table2 >> where 1=0" ) ; ?> <h3> </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3>: , . </h3>
<? header ( 'Content-type: text/html; charset=UTF-8' ) ; $mysql_host = 'localhost' ; $mysql_username = 'root' ; $mysql_password = '12345' ; $mysql_database = 'test' ; // , $mysql_table1 = 'table1' ; $mysql_table2 = 'table2' ; $memcache_host = 'localhost' ; $memcache_port = 11211 ; $mysql = mysql_connect ( $mysql_host , $mysql_username , $mysql_password ) ; if ( ! $mysql ) die ( " MySQL: $mysql_username @ $mysql_host / $mysql_password " ) ; if ( ! mysql_select_db ( $mysql_database ) ) die ( " : $mysql_database " ) ; $memcache = new Memcache ; if ( ! $memcache -> pconnect ( $memcache_host , $memcache_port ) ) die ( "Memcached : $memcache_host : $memcache_port " ) ; function cacheGet ( $key ) { global $memcache ; return $memcache -> get ( $key ) ; } function cacheSet ( $key , $data , $delay ) { global $memcache ; return $memcache -> set ( $key , $data , 0 , $delay ) ; } function sqlExtractTables ( & $query ) { preg_match_all ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , $query , $tables ) ; if ( ! $tables [ 1 ] ) die ( " , '<<table_name>>': $query " ) ; $query = preg_replace ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , "\ \1 " , $query ) ; return $tables [ 1 ] ; } function sqlQuery ( $query ) { $resource = mysql_query ( $query ) ; if ( ! $resource ) die ( " : $query <br> " . mysql_error ( ) ) ; echo "<b> :</b> $query <br>" ; return $resource ; } function sqlSet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) cacheSet ( $table , uniqid ( time ( ) , true ) , 24 * 3600 ) ; return sqlQuery ( $query ) ; } function sqlGet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) $appendix .= cacheGet ( $table ) ; $appendix = "/*" . md5 ( $appendix ) . "*/" ; $query = $query . $appendix ; $cache_key = md5 ( $query ) ; $result = cacheGet ( $cache_key ) ; if ( $result !== false ) { echo "<b> :</b> $query <br>" ; return $result ; } else echo "<b> :</b> $query <br>" ; $resource = sqlQuery ( $query ) ; $result = array ( ) ; while ( $row = mysql_fetch_assoc ( $resource ) ) { $result [ ] = $row ; } cacheSet ( $cache_key , $result , 3600 ) ; return $result ; } ?> <h2>. </h2> <h3> 2 </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; // "select * from <<$mysql_table1>> where id=1", ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3> </h3> <? sqlSet ( "delete from << $mysql_table2 >> where 1=0" ) ; ?> <h3> </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3>: , . </h3>
<? header ( 'Content-type: text/html; charset=UTF-8' ) ; $mysql_host = 'localhost' ; $mysql_username = 'root' ; $mysql_password = '12345' ; $mysql_database = 'test' ; // , $mysql_table1 = 'table1' ; $mysql_table2 = 'table2' ; $memcache_host = 'localhost' ; $memcache_port = 11211 ; $mysql = mysql_connect ( $mysql_host , $mysql_username , $mysql_password ) ; if ( ! $mysql ) die ( " MySQL: $mysql_username @ $mysql_host / $mysql_password " ) ; if ( ! mysql_select_db ( $mysql_database ) ) die ( " : $mysql_database " ) ; $memcache = new Memcache ; if ( ! $memcache -> pconnect ( $memcache_host , $memcache_port ) ) die ( "Memcached : $memcache_host : $memcache_port " ) ; function cacheGet ( $key ) { global $memcache ; return $memcache -> get ( $key ) ; } function cacheSet ( $key , $data , $delay ) { global $memcache ; return $memcache -> set ( $key , $data , 0 , $delay ) ; } function sqlExtractTables ( & $query ) { preg_match_all ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , $query , $tables ) ; if ( ! $tables [ 1 ] ) die ( " , '<<table_name>>': $query " ) ; $query = preg_replace ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , "\ \1 " , $query ) ; return $tables [ 1 ] ; } function sqlQuery ( $query ) { $resource = mysql_query ( $query ) ; if ( ! $resource ) die ( " : $query <br> " . mysql_error ( ) ) ; echo "<b> :</b> $query <br>" ; return $resource ; } function sqlSet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) cacheSet ( $table , uniqid ( time ( ) , true ) , 24 * 3600 ) ; return sqlQuery ( $query ) ; } function sqlGet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) $appendix .= cacheGet ( $table ) ; $appendix = "/*" . md5 ( $appendix ) . "*/" ; $query = $query . $appendix ; $cache_key = md5 ( $query ) ; $result = cacheGet ( $cache_key ) ; if ( $result !== false ) { echo "<b> :</b> $query <br>" ; return $result ; } else echo "<b> :</b> $query <br>" ; $resource = sqlQuery ( $query ) ; $result = array ( ) ; while ( $row = mysql_fetch_assoc ( $resource ) ) { $result [ ] = $row ; } cacheSet ( $cache_key , $result , 3600 ) ; return $result ; } ?> <h2>. </h2> <h3> 2 </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; // "select * from <<$mysql_table1>> where id=1", ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3> </h3> <? sqlSet ( "delete from << $mysql_table2 >> where 1=0" ) ; ?> <h3> </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3>: , . </h3>
<? header ( 'Content-type: text/html; charset=UTF-8' ) ; $mysql_host = 'localhost' ; $mysql_username = 'root' ; $mysql_password = '12345' ; $mysql_database = 'test' ; // , $mysql_table1 = 'table1' ; $mysql_table2 = 'table2' ; $memcache_host = 'localhost' ; $memcache_port = 11211 ; $mysql = mysql_connect ( $mysql_host , $mysql_username , $mysql_password ) ; if ( ! $mysql ) die ( " MySQL: $mysql_username @ $mysql_host / $mysql_password " ) ; if ( ! mysql_select_db ( $mysql_database ) ) die ( " : $mysql_database " ) ; $memcache = new Memcache ; if ( ! $memcache -> pconnect ( $memcache_host , $memcache_port ) ) die ( "Memcached : $memcache_host : $memcache_port " ) ; function cacheGet ( $key ) { global $memcache ; return $memcache -> get ( $key ) ; } function cacheSet ( $key , $data , $delay ) { global $memcache ; return $memcache -> set ( $key , $data , 0 , $delay ) ; } function sqlExtractTables ( & $query ) { preg_match_all ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , $query , $tables ) ; if ( ! $tables [ 1 ] ) die ( " , '<<table_name>>': $query " ) ; $query = preg_replace ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , "\ \1 " , $query ) ; return $tables [ 1 ] ; } function sqlQuery ( $query ) { $resource = mysql_query ( $query ) ; if ( ! $resource ) die ( " : $query <br> " . mysql_error ( ) ) ; echo "<b> :</b> $query <br>" ; return $resource ; } function sqlSet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) cacheSet ( $table , uniqid ( time ( ) , true ) , 24 * 3600 ) ; return sqlQuery ( $query ) ; } function sqlGet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) $appendix .= cacheGet ( $table ) ; $appendix = "/*" . md5 ( $appendix ) . "*/" ; $query = $query . $appendix ; $cache_key = md5 ( $query ) ; $result = cacheGet ( $cache_key ) ; if ( $result !== false ) { echo "<b> :</b> $query <br>" ; return $result ; } else echo "<b> :</b> $query <br>" ; $resource = sqlQuery ( $query ) ; $result = array ( ) ; while ( $row = mysql_fetch_assoc ( $resource ) ) { $result [ ] = $row ; } cacheSet ( $cache_key , $result , 3600 ) ; return $result ; } ?> <h2>. </h2> <h3> 2 </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; // "select * from <<$mysql_table1>> where id=1", ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3> </h3> <? sqlSet ( "delete from << $mysql_table2 >> where 1=0" ) ; ?> <h3> </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3>: , . </h3>
<? header ( 'Content-type: text/html; charset=UTF-8' ) ; $mysql_host = 'localhost' ; $mysql_username = 'root' ; $mysql_password = '12345' ; $mysql_database = 'test' ; // , $mysql_table1 = 'table1' ; $mysql_table2 = 'table2' ; $memcache_host = 'localhost' ; $memcache_port = 11211 ; $mysql = mysql_connect ( $mysql_host , $mysql_username , $mysql_password ) ; if ( ! $mysql ) die ( " MySQL: $mysql_username @ $mysql_host / $mysql_password " ) ; if ( ! mysql_select_db ( $mysql_database ) ) die ( " : $mysql_database " ) ; $memcache = new Memcache ; if ( ! $memcache -> pconnect ( $memcache_host , $memcache_port ) ) die ( "Memcached : $memcache_host : $memcache_port " ) ; function cacheGet ( $key ) { global $memcache ; return $memcache -> get ( $key ) ; } function cacheSet ( $key , $data , $delay ) { global $memcache ; return $memcache -> set ( $key , $data , 0 , $delay ) ; } function sqlExtractTables ( & $query ) { preg_match_all ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , $query , $tables ) ; if ( ! $tables [ 1 ] ) die ( " , '<<table_name>>': $query " ) ; $query = preg_replace ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , "\ \1 " , $query ) ; return $tables [ 1 ] ; } function sqlQuery ( $query ) { $resource = mysql_query ( $query ) ; if ( ! $resource ) die ( " : $query <br> " . mysql_error ( ) ) ; echo "<b> :</b> $query <br>" ; return $resource ; } function sqlSet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) cacheSet ( $table , uniqid ( time ( ) , true ) , 24 * 3600 ) ; return sqlQuery ( $query ) ; } function sqlGet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) $appendix .= cacheGet ( $table ) ; $appendix = "/*" . md5 ( $appendix ) . "*/" ; $query = $query . $appendix ; $cache_key = md5 ( $query ) ; $result = cacheGet ( $cache_key ) ; if ( $result !== false ) { echo "<b> :</b> $query <br>" ; return $result ; } else echo "<b> :</b> $query <br>" ; $resource = sqlQuery ( $query ) ; $result = array ( ) ; while ( $row = mysql_fetch_assoc ( $resource ) ) { $result [ ] = $row ; } cacheSet ( $cache_key , $result , 3600 ) ; return $result ; } ?> <h2>. </h2> <h3> 2 </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; // "select * from <<$mysql_table1>> where id=1", ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3> </h3> <? sqlSet ( "delete from << $mysql_table2 >> where 1=0" ) ; ?> <h3> </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3>: , . </h3>
<? header ( 'Content-type: text/html; charset=UTF-8' ) ; $mysql_host = 'localhost' ; $mysql_username = 'root' ; $mysql_password = '12345' ; $mysql_database = 'test' ; // , $mysql_table1 = 'table1' ; $mysql_table2 = 'table2' ; $memcache_host = 'localhost' ; $memcache_port = 11211 ; $mysql = mysql_connect ( $mysql_host , $mysql_username , $mysql_password ) ; if ( ! $mysql ) die ( " MySQL: $mysql_username @ $mysql_host / $mysql_password " ) ; if ( ! mysql_select_db ( $mysql_database ) ) die ( " : $mysql_database " ) ; $memcache = new Memcache ; if ( ! $memcache -> pconnect ( $memcache_host , $memcache_port ) ) die ( "Memcached : $memcache_host : $memcache_port " ) ; function cacheGet ( $key ) { global $memcache ; return $memcache -> get ( $key ) ; } function cacheSet ( $key , $data , $delay ) { global $memcache ; return $memcache -> set ( $key , $data , 0 , $delay ) ; } function sqlExtractTables ( & $query ) { preg_match_all ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , $query , $tables ) ; if ( ! $tables [ 1 ] ) die ( " , '<<table_name>>': $query " ) ; $query = preg_replace ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , "\ \1 " , $query ) ; return $tables [ 1 ] ; } function sqlQuery ( $query ) { $resource = mysql_query ( $query ) ; if ( ! $resource ) die ( " : $query <br> " . mysql_error ( ) ) ; echo "<b> :</b> $query <br>" ; return $resource ; } function sqlSet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) cacheSet ( $table , uniqid ( time ( ) , true ) , 24 * 3600 ) ; return sqlQuery ( $query ) ; } function sqlGet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) $appendix .= cacheGet ( $table ) ; $appendix = "/*" . md5 ( $appendix ) . "*/" ; $query = $query . $appendix ; $cache_key = md5 ( $query ) ; $result = cacheGet ( $cache_key ) ; if ( $result !== false ) { echo "<b> :</b> $query <br>" ; return $result ; } else echo "<b> :</b> $query <br>" ; $resource = sqlQuery ( $query ) ; $result = array ( ) ; while ( $row = mysql_fetch_assoc ( $resource ) ) { $result [ ] = $row ; } cacheSet ( $cache_key , $result , 3600 ) ; return $result ; } ?> <h2>. </h2> <h3> 2 </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; // "select * from <<$mysql_table1>> where id=1", ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3> </h3> <? sqlSet ( "delete from << $mysql_table2 >> where 1=0" ) ; ?> <h3> </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3>: , . </h3>
<? header ( 'Content-type: text/html; charset=UTF-8' ) ; $mysql_host = 'localhost' ; $mysql_username = 'root' ; $mysql_password = '12345' ; $mysql_database = 'test' ; // , $mysql_table1 = 'table1' ; $mysql_table2 = 'table2' ; $memcache_host = 'localhost' ; $memcache_port = 11211 ; $mysql = mysql_connect ( $mysql_host , $mysql_username , $mysql_password ) ; if ( ! $mysql ) die ( " MySQL: $mysql_username @ $mysql_host / $mysql_password " ) ; if ( ! mysql_select_db ( $mysql_database ) ) die ( " : $mysql_database " ) ; $memcache = new Memcache ; if ( ! $memcache -> pconnect ( $memcache_host , $memcache_port ) ) die ( "Memcached : $memcache_host : $memcache_port " ) ; function cacheGet ( $key ) { global $memcache ; return $memcache -> get ( $key ) ; } function cacheSet ( $key , $data , $delay ) { global $memcache ; return $memcache -> set ( $key , $data , 0 , $delay ) ; } function sqlExtractTables ( & $query ) { preg_match_all ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , $query , $tables ) ; if ( ! $tables [ 1 ] ) die ( " , '<<table_name>>': $query " ) ; $query = preg_replace ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , "\ \1 " , $query ) ; return $tables [ 1 ] ; } function sqlQuery ( $query ) { $resource = mysql_query ( $query ) ; if ( ! $resource ) die ( " : $query <br> " . mysql_error ( ) ) ; echo "<b> :</b> $query <br>" ; return $resource ; } function sqlSet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) cacheSet ( $table , uniqid ( time ( ) , true ) , 24 * 3600 ) ; return sqlQuery ( $query ) ; } function sqlGet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) $appendix .= cacheGet ( $table ) ; $appendix = "/*" . md5 ( $appendix ) . "*/" ; $query = $query . $appendix ; $cache_key = md5 ( $query ) ; $result = cacheGet ( $cache_key ) ; if ( $result !== false ) { echo "<b> :</b> $query <br>" ; return $result ; } else echo "<b> :</b> $query <br>" ; $resource = sqlQuery ( $query ) ; $result = array ( ) ; while ( $row = mysql_fetch_assoc ( $resource ) ) { $result [ ] = $row ; } cacheSet ( $cache_key , $result , 3600 ) ; return $result ; } ?> <h2>. </h2> <h3> 2 </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; // "select * from <<$mysql_table1>> where id=1", ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3> </h3> <? sqlSet ( "delete from << $mysql_table2 >> where 1=0" ) ; ?> <h3> </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3>: , . </h3>
<? header ( 'Content-type: text/html; charset=UTF-8' ) ; $mysql_host = 'localhost' ; $mysql_username = 'root' ; $mysql_password = '12345' ; $mysql_database = 'test' ; // , $mysql_table1 = 'table1' ; $mysql_table2 = 'table2' ; $memcache_host = 'localhost' ; $memcache_port = 11211 ; $mysql = mysql_connect ( $mysql_host , $mysql_username , $mysql_password ) ; if ( ! $mysql ) die ( " MySQL: $mysql_username @ $mysql_host / $mysql_password " ) ; if ( ! mysql_select_db ( $mysql_database ) ) die ( " : $mysql_database " ) ; $memcache = new Memcache ; if ( ! $memcache -> pconnect ( $memcache_host , $memcache_port ) ) die ( "Memcached : $memcache_host : $memcache_port " ) ; function cacheGet ( $key ) { global $memcache ; return $memcache -> get ( $key ) ; } function cacheSet ( $key , $data , $delay ) { global $memcache ; return $memcache -> set ( $key , $data , 0 , $delay ) ; } function sqlExtractTables ( & $query ) { preg_match_all ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , $query , $tables ) ; if ( ! $tables [ 1 ] ) die ( " , '<<table_name>>': $query " ) ; $query = preg_replace ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , "\ \1 " , $query ) ; return $tables [ 1 ] ; } function sqlQuery ( $query ) { $resource = mysql_query ( $query ) ; if ( ! $resource ) die ( " : $query <br> " . mysql_error ( ) ) ; echo "<b> :</b> $query <br>" ; return $resource ; } function sqlSet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) cacheSet ( $table , uniqid ( time ( ) , true ) , 24 * 3600 ) ; return sqlQuery ( $query ) ; } function sqlGet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) $appendix .= cacheGet ( $table ) ; $appendix = "/*" . md5 ( $appendix ) . "*/" ; $query = $query . $appendix ; $cache_key = md5 ( $query ) ; $result = cacheGet ( $cache_key ) ; if ( $result !== false ) { echo "<b> :</b> $query <br>" ; return $result ; } else echo "<b> :</b> $query <br>" ; $resource = sqlQuery ( $query ) ; $result = array ( ) ; while ( $row = mysql_fetch_assoc ( $resource ) ) { $result [ ] = $row ; } cacheSet ( $cache_key , $result , 3600 ) ; return $result ; } ?> <h2>. </h2> <h3> 2 </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; // "select * from <<$mysql_table1>> where id=1", ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3> </h3> <? sqlSet ( "delete from << $mysql_table2 >> where 1=0" ) ; ?> <h3> </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3>: , . </h3>
<? header ( 'Content-type: text/html; charset=UTF-8' ) ; $mysql_host = 'localhost' ; $mysql_username = 'root' ; $mysql_password = '12345' ; $mysql_database = 'test' ; // , $mysql_table1 = 'table1' ; $mysql_table2 = 'table2' ; $memcache_host = 'localhost' ; $memcache_port = 11211 ; $mysql = mysql_connect ( $mysql_host , $mysql_username , $mysql_password ) ; if ( ! $mysql ) die ( " MySQL: $mysql_username @ $mysql_host / $mysql_password " ) ; if ( ! mysql_select_db ( $mysql_database ) ) die ( " : $mysql_database " ) ; $memcache = new Memcache ; if ( ! $memcache -> pconnect ( $memcache_host , $memcache_port ) ) die ( "Memcached : $memcache_host : $memcache_port " ) ; function cacheGet ( $key ) { global $memcache ; return $memcache -> get ( $key ) ; } function cacheSet ( $key , $data , $delay ) { global $memcache ; return $memcache -> set ( $key , $data , 0 , $delay ) ; } function sqlExtractTables ( & $query ) { preg_match_all ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , $query , $tables ) ; if ( ! $tables [ 1 ] ) die ( " , '<<table_name>>': $query " ) ; $query = preg_replace ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , "\ \1 " , $query ) ; return $tables [ 1 ] ; } function sqlQuery ( $query ) { $resource = mysql_query ( $query ) ; if ( ! $resource ) die ( " : $query <br> " . mysql_error ( ) ) ; echo "<b> :</b> $query <br>" ; return $resource ; } function sqlSet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) cacheSet ( $table , uniqid ( time ( ) , true ) , 24 * 3600 ) ; return sqlQuery ( $query ) ; } function sqlGet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) $appendix .= cacheGet ( $table ) ; $appendix = "/*" . md5 ( $appendix ) . "*/" ; $query = $query . $appendix ; $cache_key = md5 ( $query ) ; $result = cacheGet ( $cache_key ) ; if ( $result !== false ) { echo "<b> :</b> $query <br>" ; return $result ; } else echo "<b> :</b> $query <br>" ; $resource = sqlQuery ( $query ) ; $result = array ( ) ; while ( $row = mysql_fetch_assoc ( $resource ) ) { $result [ ] = $row ; } cacheSet ( $cache_key , $result , 3600 ) ; return $result ; } ?> <h2>. </h2> <h3> 2 </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; // "select * from <<$mysql_table1>> where id=1", ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3> </h3> <? sqlSet ( "delete from << $mysql_table2 >> where 1=0" ) ; ?> <h3> </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3>: , . </h3>
<? header ( 'Content-type: text/html; charset=UTF-8' ) ; $mysql_host = 'localhost' ; $mysql_username = 'root' ; $mysql_password = '12345' ; $mysql_database = 'test' ; // , $mysql_table1 = 'table1' ; $mysql_table2 = 'table2' ; $memcache_host = 'localhost' ; $memcache_port = 11211 ; $mysql = mysql_connect ( $mysql_host , $mysql_username , $mysql_password ) ; if ( ! $mysql ) die ( " MySQL: $mysql_username @ $mysql_host / $mysql_password " ) ; if ( ! mysql_select_db ( $mysql_database ) ) die ( " : $mysql_database " ) ; $memcache = new Memcache ; if ( ! $memcache -> pconnect ( $memcache_host , $memcache_port ) ) die ( "Memcached : $memcache_host : $memcache_port " ) ; function cacheGet ( $key ) { global $memcache ; return $memcache -> get ( $key ) ; } function cacheSet ( $key , $data , $delay ) { global $memcache ; return $memcache -> set ( $key , $data , 0 , $delay ) ; } function sqlExtractTables ( & $query ) { preg_match_all ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , $query , $tables ) ; if ( ! $tables [ 1 ] ) die ( " , '<<table_name>>': $query " ) ; $query = preg_replace ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , "\ \1 " , $query ) ; return $tables [ 1 ] ; } function sqlQuery ( $query ) { $resource = mysql_query ( $query ) ; if ( ! $resource ) die ( " : $query <br> " . mysql_error ( ) ) ; echo "<b> :</b> $query <br>" ; return $resource ; } function sqlSet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) cacheSet ( $table , uniqid ( time ( ) , true ) , 24 * 3600 ) ; return sqlQuery ( $query ) ; } function sqlGet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) $appendix .= cacheGet ( $table ) ; $appendix = "/*" . md5 ( $appendix ) . "*/" ; $query = $query . $appendix ; $cache_key = md5 ( $query ) ; $result = cacheGet ( $cache_key ) ; if ( $result !== false ) { echo "<b> :</b> $query <br>" ; return $result ; } else echo "<b> :</b> $query <br>" ; $resource = sqlQuery ( $query ) ; $result = array ( ) ; while ( $row = mysql_fetch_assoc ( $resource ) ) { $result [ ] = $row ; } cacheSet ( $cache_key , $result , 3600 ) ; return $result ; } ?> <h2>. </h2> <h3> 2 </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; // "select * from <<$mysql_table1>> where id=1", ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3> </h3> <? sqlSet ( "delete from << $mysql_table2 >> where 1=0" ) ; ?> <h3> </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3>: , . </h3>
<? header ( 'Content-type: text/html; charset=UTF-8' ) ; $mysql_host = 'localhost' ; $mysql_username = 'root' ; $mysql_password = '12345' ; $mysql_database = 'test' ; // , $mysql_table1 = 'table1' ; $mysql_table2 = 'table2' ; $memcache_host = 'localhost' ; $memcache_port = 11211 ; $mysql = mysql_connect ( $mysql_host , $mysql_username , $mysql_password ) ; if ( ! $mysql ) die ( " MySQL: $mysql_username @ $mysql_host / $mysql_password " ) ; if ( ! mysql_select_db ( $mysql_database ) ) die ( " : $mysql_database " ) ; $memcache = new Memcache ; if ( ! $memcache -> pconnect ( $memcache_host , $memcache_port ) ) die ( "Memcached : $memcache_host : $memcache_port " ) ; function cacheGet ( $key ) { global $memcache ; return $memcache -> get ( $key ) ; } function cacheSet ( $key , $data , $delay ) { global $memcache ; return $memcache -> set ( $key , $data , 0 , $delay ) ; } function sqlExtractTables ( & $query ) { preg_match_all ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , $query , $tables ) ; if ( ! $tables [ 1 ] ) die ( " , '<<table_name>>': $query " ) ; $query = preg_replace ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , "\ \1 " , $query ) ; return $tables [ 1 ] ; } function sqlQuery ( $query ) { $resource = mysql_query ( $query ) ; if ( ! $resource ) die ( " : $query <br> " . mysql_error ( ) ) ; echo "<b> :</b> $query <br>" ; return $resource ; } function sqlSet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) cacheSet ( $table , uniqid ( time ( ) , true ) , 24 * 3600 ) ; return sqlQuery ( $query ) ; } function sqlGet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) $appendix .= cacheGet ( $table ) ; $appendix = "/*" . md5 ( $appendix ) . "*/" ; $query = $query . $appendix ; $cache_key = md5 ( $query ) ; $result = cacheGet ( $cache_key ) ; if ( $result !== false ) { echo "<b> :</b> $query <br>" ; return $result ; } else echo "<b> :</b> $query <br>" ; $resource = sqlQuery ( $query ) ; $result = array ( ) ; while ( $row = mysql_fetch_assoc ( $resource ) ) { $result [ ] = $row ; } cacheSet ( $cache_key , $result , 3600 ) ; return $result ; } ?> <h2>. </h2> <h3> 2 </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; // "select * from <<$mysql_table1>> where id=1", ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3> </h3> <? sqlSet ( "delete from << $mysql_table2 >> where 1=0" ) ; ?> <h3> </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3>: , . </h3>
<? header ( 'Content-type: text/html; charset=UTF-8' ) ; $mysql_host = 'localhost' ; $mysql_username = 'root' ; $mysql_password = '12345' ; $mysql_database = 'test' ; // , $mysql_table1 = 'table1' ; $mysql_table2 = 'table2' ; $memcache_host = 'localhost' ; $memcache_port = 11211 ; $mysql = mysql_connect ( $mysql_host , $mysql_username , $mysql_password ) ; if ( ! $mysql ) die ( " MySQL: $mysql_username @ $mysql_host / $mysql_password " ) ; if ( ! mysql_select_db ( $mysql_database ) ) die ( " : $mysql_database " ) ; $memcache = new Memcache ; if ( ! $memcache -> pconnect ( $memcache_host , $memcache_port ) ) die ( "Memcached : $memcache_host : $memcache_port " ) ; function cacheGet ( $key ) { global $memcache ; return $memcache -> get ( $key ) ; } function cacheSet ( $key , $data , $delay ) { global $memcache ; return $memcache -> set ( $key , $data , 0 , $delay ) ; } function sqlExtractTables ( & $query ) { preg_match_all ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , $query , $tables ) ; if ( ! $tables [ 1 ] ) die ( " , '<<table_name>>': $query " ) ; $query = preg_replace ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , "\ \1 " , $query ) ; return $tables [ 1 ] ; } function sqlQuery ( $query ) { $resource = mysql_query ( $query ) ; if ( ! $resource ) die ( " : $query <br> " . mysql_error ( ) ) ; echo "<b> :</b> $query <br>" ; return $resource ; } function sqlSet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) cacheSet ( $table , uniqid ( time ( ) , true ) , 24 * 3600 ) ; return sqlQuery ( $query ) ; } function sqlGet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) $appendix .= cacheGet ( $table ) ; $appendix = "/*" . md5 ( $appendix ) . "*/" ; $query = $query . $appendix ; $cache_key = md5 ( $query ) ; $result = cacheGet ( $cache_key ) ; if ( $result !== false ) { echo "<b> :</b> $query <br>" ; return $result ; } else echo "<b> :</b> $query <br>" ; $resource = sqlQuery ( $query ) ; $result = array ( ) ; while ( $row = mysql_fetch_assoc ( $resource ) ) { $result [ ] = $row ; } cacheSet ( $cache_key , $result , 3600 ) ; return $result ; } ?> <h2>. </h2> <h3> 2 </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; // "select * from <<$mysql_table1>> where id=1", ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3> </h3> <? sqlSet ( "delete from << $mysql_table2 >> where 1=0" ) ; ?> <h3> </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3>: , . </h3>
<? header ( 'Content-type: text/html; charset=UTF-8' ) ; $mysql_host = 'localhost' ; $mysql_username = 'root' ; $mysql_password = '12345' ; $mysql_database = 'test' ; // , $mysql_table1 = 'table1' ; $mysql_table2 = 'table2' ; $memcache_host = 'localhost' ; $memcache_port = 11211 ; $mysql = mysql_connect ( $mysql_host , $mysql_username , $mysql_password ) ; if ( ! $mysql ) die ( " MySQL: $mysql_username @ $mysql_host / $mysql_password " ) ; if ( ! mysql_select_db ( $mysql_database ) ) die ( " : $mysql_database " ) ; $memcache = new Memcache ; if ( ! $memcache -> pconnect ( $memcache_host , $memcache_port ) ) die ( "Memcached : $memcache_host : $memcache_port " ) ; function cacheGet ( $key ) { global $memcache ; return $memcache -> get ( $key ) ; } function cacheSet ( $key , $data , $delay ) { global $memcache ; return $memcache -> set ( $key , $data , 0 , $delay ) ; } function sqlExtractTables ( & $query ) { preg_match_all ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , $query , $tables ) ; if ( ! $tables [ 1 ] ) die ( " , '<<table_name>>': $query " ) ; $query = preg_replace ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , "\ \1 " , $query ) ; return $tables [ 1 ] ; } function sqlQuery ( $query ) { $resource = mysql_query ( $query ) ; if ( ! $resource ) die ( " : $query <br> " . mysql_error ( ) ) ; echo "<b> :</b> $query <br>" ; return $resource ; } function sqlSet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) cacheSet ( $table , uniqid ( time ( ) , true ) , 24 * 3600 ) ; return sqlQuery ( $query ) ; } function sqlGet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) $appendix .= cacheGet ( $table ) ; $appendix = "/*" . md5 ( $appendix ) . "*/" ; $query = $query . $appendix ; $cache_key = md5 ( $query ) ; $result = cacheGet ( $cache_key ) ; if ( $result !== false ) { echo "<b> :</b> $query <br>" ; return $result ; } else echo "<b> :</b> $query <br>" ; $resource = sqlQuery ( $query ) ; $result = array ( ) ; while ( $row = mysql_fetch_assoc ( $resource ) ) { $result [ ] = $row ; } cacheSet ( $cache_key , $result , 3600 ) ; return $result ; } ?> <h2>. </h2> <h3> 2 </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; // "select * from <<$mysql_table1>> where id=1", ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3> </h3> <? sqlSet ( "delete from << $mysql_table2 >> where 1=0" ) ; ?> <h3> </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3>: , . </h3>
<? header ( 'Content-type: text/html; charset=UTF-8' ) ; $mysql_host = 'localhost' ; $mysql_username = 'root' ; $mysql_password = '12345' ; $mysql_database = 'test' ; // , $mysql_table1 = 'table1' ; $mysql_table2 = 'table2' ; $memcache_host = 'localhost' ; $memcache_port = 11211 ; $mysql = mysql_connect ( $mysql_host , $mysql_username , $mysql_password ) ; if ( ! $mysql ) die ( " MySQL: $mysql_username @ $mysql_host / $mysql_password " ) ; if ( ! mysql_select_db ( $mysql_database ) ) die ( " : $mysql_database " ) ; $memcache = new Memcache ; if ( ! $memcache -> pconnect ( $memcache_host , $memcache_port ) ) die ( "Memcached : $memcache_host : $memcache_port " ) ; function cacheGet ( $key ) { global $memcache ; return $memcache -> get ( $key ) ; } function cacheSet ( $key , $data , $delay ) { global $memcache ; return $memcache -> set ( $key , $data , 0 , $delay ) ; } function sqlExtractTables ( & $query ) { preg_match_all ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , $query , $tables ) ; if ( ! $tables [ 1 ] ) die ( " , '<<table_name>>': $query " ) ; $query = preg_replace ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , "\ \1 " , $query ) ; return $tables [ 1 ] ; } function sqlQuery ( $query ) { $resource = mysql_query ( $query ) ; if ( ! $resource ) die ( " : $query <br> " . mysql_error ( ) ) ; echo "<b> :</b> $query <br>" ; return $resource ; } function sqlSet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) cacheSet ( $table , uniqid ( time ( ) , true ) , 24 * 3600 ) ; return sqlQuery ( $query ) ; } function sqlGet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) $appendix .= cacheGet ( $table ) ; $appendix = "/*" . md5 ( $appendix ) . "*/" ; $query = $query . $appendix ; $cache_key = md5 ( $query ) ; $result = cacheGet ( $cache_key ) ; if ( $result !== false ) { echo "<b> :</b> $query <br>" ; return $result ; } else echo "<b> :</b> $query <br>" ; $resource = sqlQuery ( $query ) ; $result = array ( ) ; while ( $row = mysql_fetch_assoc ( $resource ) ) { $result [ ] = $row ; } cacheSet ( $cache_key , $result , 3600 ) ; return $result ; } ?> <h2>. </h2> <h3> 2 </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; // "select * from <<$mysql_table1>> where id=1", ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3> </h3> <? sqlSet ( "delete from << $mysql_table2 >> where 1=0" ) ; ?> <h3> </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3>: , . </h3>
<? header ( 'Content-type: text/html; charset=UTF-8' ) ; $mysql_host = 'localhost' ; $mysql_username = 'root' ; $mysql_password = '12345' ; $mysql_database = 'test' ; // , $mysql_table1 = 'table1' ; $mysql_table2 = 'table2' ; $memcache_host = 'localhost' ; $memcache_port = 11211 ; $mysql = mysql_connect ( $mysql_host , $mysql_username , $mysql_password ) ; if ( ! $mysql ) die ( " MySQL: $mysql_username @ $mysql_host / $mysql_password " ) ; if ( ! mysql_select_db ( $mysql_database ) ) die ( " : $mysql_database " ) ; $memcache = new Memcache ; if ( ! $memcache -> pconnect ( $memcache_host , $memcache_port ) ) die ( "Memcached : $memcache_host : $memcache_port " ) ; function cacheGet ( $key ) { global $memcache ; return $memcache -> get ( $key ) ; } function cacheSet ( $key , $data , $delay ) { global $memcache ; return $memcache -> set ( $key , $data , 0 , $delay ) ; } function sqlExtractTables ( & $query ) { preg_match_all ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , $query , $tables ) ; if ( ! $tables [ 1 ] ) die ( " , '<<table_name>>': $query " ) ; $query = preg_replace ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , "\ \1 " , $query ) ; return $tables [ 1 ] ; } function sqlQuery ( $query ) { $resource = mysql_query ( $query ) ; if ( ! $resource ) die ( " : $query <br> " . mysql_error ( ) ) ; echo "<b> :</b> $query <br>" ; return $resource ; } function sqlSet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) cacheSet ( $table , uniqid ( time ( ) , true ) , 24 * 3600 ) ; return sqlQuery ( $query ) ; } function sqlGet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) $appendix .= cacheGet ( $table ) ; $appendix = "/*" . md5 ( $appendix ) . "*/" ; $query = $query . $appendix ; $cache_key = md5 ( $query ) ; $result = cacheGet ( $cache_key ) ; if ( $result !== false ) { echo "<b> :</b> $query <br>" ; return $result ; } else echo "<b> :</b> $query <br>" ; $resource = sqlQuery ( $query ) ; $result = array ( ) ; while ( $row = mysql_fetch_assoc ( $resource ) ) { $result [ ] = $row ; } cacheSet ( $cache_key , $result , 3600 ) ; return $result ; } ?> <h2>. </h2> <h3> 2 </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; // "select * from <<$mysql_table1>> where id=1", ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3> </h3> <? sqlSet ( "delete from << $mysql_table2 >> where 1=0" ) ; ?> <h3> </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3>: , . </h3>
<? header ( 'Content-type: text/html; charset=UTF-8' ) ; $mysql_host = 'localhost' ; $mysql_username = 'root' ; $mysql_password = '12345' ; $mysql_database = 'test' ; // , $mysql_table1 = 'table1' ; $mysql_table2 = 'table2' ; $memcache_host = 'localhost' ; $memcache_port = 11211 ; $mysql = mysql_connect ( $mysql_host , $mysql_username , $mysql_password ) ; if ( ! $mysql ) die ( " MySQL: $mysql_username @ $mysql_host / $mysql_password " ) ; if ( ! mysql_select_db ( $mysql_database ) ) die ( " : $mysql_database " ) ; $memcache = new Memcache ; if ( ! $memcache -> pconnect ( $memcache_host , $memcache_port ) ) die ( "Memcached : $memcache_host : $memcache_port " ) ; function cacheGet ( $key ) { global $memcache ; return $memcache -> get ( $key ) ; } function cacheSet ( $key , $data , $delay ) { global $memcache ; return $memcache -> set ( $key , $data , 0 , $delay ) ; } function sqlExtractTables ( & $query ) { preg_match_all ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , $query , $tables ) ; if ( ! $tables [ 1 ] ) die ( " , '<<table_name>>': $query " ) ; $query = preg_replace ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , "\ \1 " , $query ) ; return $tables [ 1 ] ; } function sqlQuery ( $query ) { $resource = mysql_query ( $query ) ; if ( ! $resource ) die ( " : $query <br> " . mysql_error ( ) ) ; echo "<b> :</b> $query <br>" ; return $resource ; } function sqlSet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) cacheSet ( $table , uniqid ( time ( ) , true ) , 24 * 3600 ) ; return sqlQuery ( $query ) ; } function sqlGet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) $appendix .= cacheGet ( $table ) ; $appendix = "/*" . md5 ( $appendix ) . "*/" ; $query = $query . $appendix ; $cache_key = md5 ( $query ) ; $result = cacheGet ( $cache_key ) ; if ( $result !== false ) { echo "<b> :</b> $query <br>" ; return $result ; } else echo "<b> :</b> $query <br>" ; $resource = sqlQuery ( $query ) ; $result = array ( ) ; while ( $row = mysql_fetch_assoc ( $resource ) ) { $result [ ] = $row ; } cacheSet ( $cache_key , $result , 3600 ) ; return $result ; } ?> <h2>. </h2> <h3> 2 </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; // "select * from <<$mysql_table1>> where id=1", ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3> </h3> <? sqlSet ( "delete from << $mysql_table2 >> where 1=0" ) ; ?> <h3> </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3>: , . </h3>
<? header ( 'Content-type: text/html; charset=UTF-8' ) ; $mysql_host = 'localhost' ; $mysql_username = 'root' ; $mysql_password = '12345' ; $mysql_database = 'test' ; // , $mysql_table1 = 'table1' ; $mysql_table2 = 'table2' ; $memcache_host = 'localhost' ; $memcache_port = 11211 ; $mysql = mysql_connect ( $mysql_host , $mysql_username , $mysql_password ) ; if ( ! $mysql ) die ( " MySQL: $mysql_username @ $mysql_host / $mysql_password " ) ; if ( ! mysql_select_db ( $mysql_database ) ) die ( " : $mysql_database " ) ; $memcache = new Memcache ; if ( ! $memcache -> pconnect ( $memcache_host , $memcache_port ) ) die ( "Memcached : $memcache_host : $memcache_port " ) ; function cacheGet ( $key ) { global $memcache ; return $memcache -> get ( $key ) ; } function cacheSet ( $key , $data , $delay ) { global $memcache ; return $memcache -> set ( $key , $data , 0 , $delay ) ; } function sqlExtractTables ( & $query ) { preg_match_all ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , $query , $tables ) ; if ( ! $tables [ 1 ] ) die ( " , '<<table_name>>': $query " ) ; $query = preg_replace ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , "\ \1 " , $query ) ; return $tables [ 1 ] ; } function sqlQuery ( $query ) { $resource = mysql_query ( $query ) ; if ( ! $resource ) die ( " : $query <br> " . mysql_error ( ) ) ; echo "<b> :</b> $query <br>" ; return $resource ; } function sqlSet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) cacheSet ( $table , uniqid ( time ( ) , true ) , 24 * 3600 ) ; return sqlQuery ( $query ) ; } function sqlGet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) $appendix .= cacheGet ( $table ) ; $appendix = "/*" . md5 ( $appendix ) . "*/" ; $query = $query . $appendix ; $cache_key = md5 ( $query ) ; $result = cacheGet ( $cache_key ) ; if ( $result !== false ) { echo "<b> :</b> $query <br>" ; return $result ; } else echo "<b> :</b> $query <br>" ; $resource = sqlQuery ( $query ) ; $result = array ( ) ; while ( $row = mysql_fetch_assoc ( $resource ) ) { $result [ ] = $row ; } cacheSet ( $cache_key , $result , 3600 ) ; return $result ; } ?> <h2>. </h2> <h3> 2 </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; // "select * from <<$mysql_table1>> where id=1", ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3> </h3> <? sqlSet ( "delete from << $mysql_table2 >> where 1=0" ) ; ?> <h3> </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3>: , . </h3>
<? header ( 'Content-type: text/html; charset=UTF-8' ) ; $mysql_host = 'localhost' ; $mysql_username = 'root' ; $mysql_password = '12345' ; $mysql_database = 'test' ; // , $mysql_table1 = 'table1' ; $mysql_table2 = 'table2' ; $memcache_host = 'localhost' ; $memcache_port = 11211 ; $mysql = mysql_connect ( $mysql_host , $mysql_username , $mysql_password ) ; if ( ! $mysql ) die ( " MySQL: $mysql_username @ $mysql_host / $mysql_password " ) ; if ( ! mysql_select_db ( $mysql_database ) ) die ( " : $mysql_database " ) ; $memcache = new Memcache ; if ( ! $memcache -> pconnect ( $memcache_host , $memcache_port ) ) die ( "Memcached : $memcache_host : $memcache_port " ) ; function cacheGet ( $key ) { global $memcache ; return $memcache -> get ( $key ) ; } function cacheSet ( $key , $data , $delay ) { global $memcache ; return $memcache -> set ( $key , $data , 0 , $delay ) ; } function sqlExtractTables ( & $query ) { preg_match_all ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , $query , $tables ) ; if ( ! $tables [ 1 ] ) die ( " , '<<table_name>>': $query " ) ; $query = preg_replace ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , "\ \1 " , $query ) ; return $tables [ 1 ] ; } function sqlQuery ( $query ) { $resource = mysql_query ( $query ) ; if ( ! $resource ) die ( " : $query <br> " . mysql_error ( ) ) ; echo "<b> :</b> $query <br>" ; return $resource ; } function sqlSet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) cacheSet ( $table , uniqid ( time ( ) , true ) , 24 * 3600 ) ; return sqlQuery ( $query ) ; } function sqlGet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) $appendix .= cacheGet ( $table ) ; $appendix = "/*" . md5 ( $appendix ) . "*/" ; $query = $query . $appendix ; $cache_key = md5 ( $query ) ; $result = cacheGet ( $cache_key ) ; if ( $result !== false ) { echo "<b> :</b> $query <br>" ; return $result ; } else echo "<b> :</b> $query <br>" ; $resource = sqlQuery ( $query ) ; $result = array ( ) ; while ( $row = mysql_fetch_assoc ( $resource ) ) { $result [ ] = $row ; } cacheSet ( $cache_key , $result , 3600 ) ; return $result ; } ?> <h2>. </h2> <h3> 2 </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; // "select * from <<$mysql_table1>> where id=1", ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3> </h3> <? sqlSet ( "delete from << $mysql_table2 >> where 1=0" ) ; ?> <h3> </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3>: , . </h3>
<? header ( 'Content-type: text/html; charset=UTF-8' ) ; $mysql_host = 'localhost' ; $mysql_username = 'root' ; $mysql_password = '12345' ; $mysql_database = 'test' ; // , $mysql_table1 = 'table1' ; $mysql_table2 = 'table2' ; $memcache_host = 'localhost' ; $memcache_port = 11211 ; $mysql = mysql_connect ( $mysql_host , $mysql_username , $mysql_password ) ; if ( ! $mysql ) die ( " MySQL: $mysql_username @ $mysql_host / $mysql_password " ) ; if ( ! mysql_select_db ( $mysql_database ) ) die ( " : $mysql_database " ) ; $memcache = new Memcache ; if ( ! $memcache -> pconnect ( $memcache_host , $memcache_port ) ) die ( "Memcached : $memcache_host : $memcache_port " ) ; function cacheGet ( $key ) { global $memcache ; return $memcache -> get ( $key ) ; } function cacheSet ( $key , $data , $delay ) { global $memcache ; return $memcache -> set ( $key , $data , 0 , $delay ) ; } function sqlExtractTables ( & $query ) { preg_match_all ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , $query , $tables ) ; if ( ! $tables [ 1 ] ) die ( " , '<<table_name>>': $query " ) ; $query = preg_replace ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , "\ \1 " , $query ) ; return $tables [ 1 ] ; } function sqlQuery ( $query ) { $resource = mysql_query ( $query ) ; if ( ! $resource ) die ( " : $query <br> " . mysql_error ( ) ) ; echo "<b> :</b> $query <br>" ; return $resource ; } function sqlSet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) cacheSet ( $table , uniqid ( time ( ) , true ) , 24 * 3600 ) ; return sqlQuery ( $query ) ; } function sqlGet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) $appendix .= cacheGet ( $table ) ; $appendix = "/*" . md5 ( $appendix ) . "*/" ; $query = $query . $appendix ; $cache_key = md5 ( $query ) ; $result = cacheGet ( $cache_key ) ; if ( $result !== false ) { echo "<b> :</b> $query <br>" ; return $result ; } else echo "<b> :</b> $query <br>" ; $resource = sqlQuery ( $query ) ; $result = array ( ) ; while ( $row = mysql_fetch_assoc ( $resource ) ) { $result [ ] = $row ; } cacheSet ( $cache_key , $result , 3600 ) ; return $result ; } ?> <h2>. </h2> <h3> 2 </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; // "select * from <<$mysql_table1>> where id=1", ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3> </h3> <? sqlSet ( "delete from << $mysql_table2 >> where 1=0" ) ; ?> <h3> </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3>: , . </h3>
<? header ( 'Content-type: text/html; charset=UTF-8' ) ; $mysql_host = 'localhost' ; $mysql_username = 'root' ; $mysql_password = '12345' ; $mysql_database = 'test' ; // , $mysql_table1 = 'table1' ; $mysql_table2 = 'table2' ; $memcache_host = 'localhost' ; $memcache_port = 11211 ; $mysql = mysql_connect ( $mysql_host , $mysql_username , $mysql_password ) ; if ( ! $mysql ) die ( " MySQL: $mysql_username @ $mysql_host / $mysql_password " ) ; if ( ! mysql_select_db ( $mysql_database ) ) die ( " : $mysql_database " ) ; $memcache = new Memcache ; if ( ! $memcache -> pconnect ( $memcache_host , $memcache_port ) ) die ( "Memcached : $memcache_host : $memcache_port " ) ; function cacheGet ( $key ) { global $memcache ; return $memcache -> get ( $key ) ; } function cacheSet ( $key , $data , $delay ) { global $memcache ; return $memcache -> set ( $key , $data , 0 , $delay ) ; } function sqlExtractTables ( & $query ) { preg_match_all ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , $query , $tables ) ; if ( ! $tables [ 1 ] ) die ( " , '<<table_name>>': $query " ) ; $query = preg_replace ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , "\ \1 " , $query ) ; return $tables [ 1 ] ; } function sqlQuery ( $query ) { $resource = mysql_query ( $query ) ; if ( ! $resource ) die ( " : $query <br> " . mysql_error ( ) ) ; echo "<b> :</b> $query <br>" ; return $resource ; } function sqlSet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) cacheSet ( $table , uniqid ( time ( ) , true ) , 24 * 3600 ) ; return sqlQuery ( $query ) ; } function sqlGet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) $appendix .= cacheGet ( $table ) ; $appendix = "/*" . md5 ( $appendix ) . "*/" ; $query = $query . $appendix ; $cache_key = md5 ( $query ) ; $result = cacheGet ( $cache_key ) ; if ( $result !== false ) { echo "<b> :</b> $query <br>" ; return $result ; } else echo "<b> :</b> $query <br>" ; $resource = sqlQuery ( $query ) ; $result = array ( ) ; while ( $row = mysql_fetch_assoc ( $resource ) ) { $result [ ] = $row ; } cacheSet ( $cache_key , $result , 3600 ) ; return $result ; } ?> <h2>. </h2> <h3> 2 </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; // "select * from <<$mysql_table1>> where id=1", ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3> </h3> <? sqlSet ( "delete from << $mysql_table2 >> where 1=0" ) ; ?> <h3> </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3>: , . </h3>
<? header ( 'Content-type: text/html; charset=UTF-8' ) ; $mysql_host = 'localhost' ; $mysql_username = 'root' ; $mysql_password = '12345' ; $mysql_database = 'test' ; // , $mysql_table1 = 'table1' ; $mysql_table2 = 'table2' ; $memcache_host = 'localhost' ; $memcache_port = 11211 ; $mysql = mysql_connect ( $mysql_host , $mysql_username , $mysql_password ) ; if ( ! $mysql ) die ( " MySQL: $mysql_username @ $mysql_host / $mysql_password " ) ; if ( ! mysql_select_db ( $mysql_database ) ) die ( " : $mysql_database " ) ; $memcache = new Memcache ; if ( ! $memcache -> pconnect ( $memcache_host , $memcache_port ) ) die ( "Memcached : $memcache_host : $memcache_port " ) ; function cacheGet ( $key ) { global $memcache ; return $memcache -> get ( $key ) ; } function cacheSet ( $key , $data , $delay ) { global $memcache ; return $memcache -> set ( $key , $data , 0 , $delay ) ; } function sqlExtractTables ( & $query ) { preg_match_all ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , $query , $tables ) ; if ( ! $tables [ 1 ] ) die ( " , '<<table_name>>': $query " ) ; $query = preg_replace ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , "\ \1 " , $query ) ; return $tables [ 1 ] ; } function sqlQuery ( $query ) { $resource = mysql_query ( $query ) ; if ( ! $resource ) die ( " : $query <br> " . mysql_error ( ) ) ; echo "<b> :</b> $query <br>" ; return $resource ; } function sqlSet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) cacheSet ( $table , uniqid ( time ( ) , true ) , 24 * 3600 ) ; return sqlQuery ( $query ) ; } function sqlGet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) $appendix .= cacheGet ( $table ) ; $appendix = "/*" . md5 ( $appendix ) . "*/" ; $query = $query . $appendix ; $cache_key = md5 ( $query ) ; $result = cacheGet ( $cache_key ) ; if ( $result !== false ) { echo "<b> :</b> $query <br>" ; return $result ; } else echo "<b> :</b> $query <br>" ; $resource = sqlQuery ( $query ) ; $result = array ( ) ; while ( $row = mysql_fetch_assoc ( $resource ) ) { $result [ ] = $row ; } cacheSet ( $cache_key , $result , 3600 ) ; return $result ; } ?> <h2>. </h2> <h3> 2 </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; // "select * from <<$mysql_table1>> where id=1", ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3> </h3> <? sqlSet ( "delete from << $mysql_table2 >> where 1=0" ) ; ?> <h3> </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3>: , . </h3>
<? header ( 'Content-type: text/html; charset=UTF-8' ) ; $mysql_host = 'localhost' ; $mysql_username = 'root' ; $mysql_password = '12345' ; $mysql_database = 'test' ; // , $mysql_table1 = 'table1' ; $mysql_table2 = 'table2' ; $memcache_host = 'localhost' ; $memcache_port = 11211 ; $mysql = mysql_connect ( $mysql_host , $mysql_username , $mysql_password ) ; if ( ! $mysql ) die ( " MySQL: $mysql_username @ $mysql_host / $mysql_password " ) ; if ( ! mysql_select_db ( $mysql_database ) ) die ( " : $mysql_database " ) ; $memcache = new Memcache ; if ( ! $memcache -> pconnect ( $memcache_host , $memcache_port ) ) die ( "Memcached : $memcache_host : $memcache_port " ) ; function cacheGet ( $key ) { global $memcache ; return $memcache -> get ( $key ) ; } function cacheSet ( $key , $data , $delay ) { global $memcache ; return $memcache -> set ( $key , $data , 0 , $delay ) ; } function sqlExtractTables ( & $query ) { preg_match_all ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , $query , $tables ) ; if ( ! $tables [ 1 ] ) die ( " , '<<table_name>>': $query " ) ; $query = preg_replace ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , "\ \1 " , $query ) ; return $tables [ 1 ] ; } function sqlQuery ( $query ) { $resource = mysql_query ( $query ) ; if ( ! $resource ) die ( " : $query <br> " . mysql_error ( ) ) ; echo "<b> :</b> $query <br>" ; return $resource ; } function sqlSet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) cacheSet ( $table , uniqid ( time ( ) , true ) , 24 * 3600 ) ; return sqlQuery ( $query ) ; } function sqlGet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) $appendix .= cacheGet ( $table ) ; $appendix = "/*" . md5 ( $appendix ) . "*/" ; $query = $query . $appendix ; $cache_key = md5 ( $query ) ; $result = cacheGet ( $cache_key ) ; if ( $result !== false ) { echo "<b> :</b> $query <br>" ; return $result ; } else echo "<b> :</b> $query <br>" ; $resource = sqlQuery ( $query ) ; $result = array ( ) ; while ( $row = mysql_fetch_assoc ( $resource ) ) { $result [ ] = $row ; } cacheSet ( $cache_key , $result , 3600 ) ; return $result ; } ?> <h2>. </h2> <h3> 2 </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; // "select * from <<$mysql_table1>> where id=1", ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3> </h3> <? sqlSet ( "delete from << $mysql_table2 >> where 1=0" ) ; ?> <h3> </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3>: , . </h3>
<? header ( 'Content-type: text/html; charset=UTF-8' ) ; $mysql_host = 'localhost' ; $mysql_username = 'root' ; $mysql_password = '12345' ; $mysql_database = 'test' ; // , $mysql_table1 = 'table1' ; $mysql_table2 = 'table2' ; $memcache_host = 'localhost' ; $memcache_port = 11211 ; $mysql = mysql_connect ( $mysql_host , $mysql_username , $mysql_password ) ; if ( ! $mysql ) die ( " MySQL: $mysql_username @ $mysql_host / $mysql_password " ) ; if ( ! mysql_select_db ( $mysql_database ) ) die ( " : $mysql_database " ) ; $memcache = new Memcache ; if ( ! $memcache -> pconnect ( $memcache_host , $memcache_port ) ) die ( "Memcached : $memcache_host : $memcache_port " ) ; function cacheGet ( $key ) { global $memcache ; return $memcache -> get ( $key ) ; } function cacheSet ( $key , $data , $delay ) { global $memcache ; return $memcache -> set ( $key , $data , 0 , $delay ) ; } function sqlExtractTables ( & $query ) { preg_match_all ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , $query , $tables ) ; if ( ! $tables [ 1 ] ) die ( " , '<<table_name>>': $query " ) ; $query = preg_replace ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , "\ \1 " , $query ) ; return $tables [ 1 ] ; } function sqlQuery ( $query ) { $resource = mysql_query ( $query ) ; if ( ! $resource ) die ( " : $query <br> " . mysql_error ( ) ) ; echo "<b> :</b> $query <br>" ; return $resource ; } function sqlSet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) cacheSet ( $table , uniqid ( time ( ) , true ) , 24 * 3600 ) ; return sqlQuery ( $query ) ; } function sqlGet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) $appendix .= cacheGet ( $table ) ; $appendix = "/*" . md5 ( $appendix ) . "*/" ; $query = $query . $appendix ; $cache_key = md5 ( $query ) ; $result = cacheGet ( $cache_key ) ; if ( $result !== false ) { echo "<b> :</b> $query <br>" ; return $result ; } else echo "<b> :</b> $query <br>" ; $resource = sqlQuery ( $query ) ; $result = array ( ) ; while ( $row = mysql_fetch_assoc ( $resource ) ) { $result [ ] = $row ; } cacheSet ( $cache_key , $result , 3600 ) ; return $result ; } ?> <h2>. </h2> <h3> 2 </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; // "select * from <<$mysql_table1>> where id=1", ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3> </h3> <? sqlSet ( "delete from << $mysql_table2 >> where 1=0" ) ; ?> <h3> </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3>: , . </h3>
<? header ( 'Content-type: text/html; charset=UTF-8' ) ; $mysql_host = 'localhost' ; $mysql_username = 'root' ; $mysql_password = '12345' ; $mysql_database = 'test' ; // , $mysql_table1 = 'table1' ; $mysql_table2 = 'table2' ; $memcache_host = 'localhost' ; $memcache_port = 11211 ; $mysql = mysql_connect ( $mysql_host , $mysql_username , $mysql_password ) ; if ( ! $mysql ) die ( " MySQL: $mysql_username @ $mysql_host / $mysql_password " ) ; if ( ! mysql_select_db ( $mysql_database ) ) die ( " : $mysql_database " ) ; $memcache = new Memcache ; if ( ! $memcache -> pconnect ( $memcache_host , $memcache_port ) ) die ( "Memcached : $memcache_host : $memcache_port " ) ; function cacheGet ( $key ) { global $memcache ; return $memcache -> get ( $key ) ; } function cacheSet ( $key , $data , $delay ) { global $memcache ; return $memcache -> set ( $key , $data , 0 , $delay ) ; } function sqlExtractTables ( & $query ) { preg_match_all ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , $query , $tables ) ; if ( ! $tables [ 1 ] ) die ( " , '<<table_name>>': $query " ) ; $query = preg_replace ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , "\ \1 " , $query ) ; return $tables [ 1 ] ; } function sqlQuery ( $query ) { $resource = mysql_query ( $query ) ; if ( ! $resource ) die ( " : $query <br> " . mysql_error ( ) ) ; echo "<b> :</b> $query <br>" ; return $resource ; } function sqlSet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) cacheSet ( $table , uniqid ( time ( ) , true ) , 24 * 3600 ) ; return sqlQuery ( $query ) ; } function sqlGet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) $appendix .= cacheGet ( $table ) ; $appendix = "/*" . md5 ( $appendix ) . "*/" ; $query = $query . $appendix ; $cache_key = md5 ( $query ) ; $result = cacheGet ( $cache_key ) ; if ( $result !== false ) { echo "<b> :</b> $query <br>" ; return $result ; } else echo "<b> :</b> $query <br>" ; $resource = sqlQuery ( $query ) ; $result = array ( ) ; while ( $row = mysql_fetch_assoc ( $resource ) ) { $result [ ] = $row ; } cacheSet ( $cache_key , $result , 3600 ) ; return $result ; } ?> <h2>. </h2> <h3> 2 </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; // "select * from <<$mysql_table1>> where id=1", ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3> </h3> <? sqlSet ( "delete from << $mysql_table2 >> where 1=0" ) ; ?> <h3> </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3>: , . </h3>
<? header ( 'Content-type: text/html; charset=UTF-8' ) ; $mysql_host = 'localhost' ; $mysql_username = 'root' ; $mysql_password = '12345' ; $mysql_database = 'test' ; // , $mysql_table1 = 'table1' ; $mysql_table2 = 'table2' ; $memcache_host = 'localhost' ; $memcache_port = 11211 ; $mysql = mysql_connect ( $mysql_host , $mysql_username , $mysql_password ) ; if ( ! $mysql ) die ( " MySQL: $mysql_username @ $mysql_host / $mysql_password " ) ; if ( ! mysql_select_db ( $mysql_database ) ) die ( " : $mysql_database " ) ; $memcache = new Memcache ; if ( ! $memcache -> pconnect ( $memcache_host , $memcache_port ) ) die ( "Memcached : $memcache_host : $memcache_port " ) ; function cacheGet ( $key ) { global $memcache ; return $memcache -> get ( $key ) ; } function cacheSet ( $key , $data , $delay ) { global $memcache ; return $memcache -> set ( $key , $data , 0 , $delay ) ; } function sqlExtractTables ( & $query ) { preg_match_all ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , $query , $tables ) ; if ( ! $tables [ 1 ] ) die ( " , '<<table_name>>': $query " ) ; $query = preg_replace ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , "\ \1 " , $query ) ; return $tables [ 1 ] ; } function sqlQuery ( $query ) { $resource = mysql_query ( $query ) ; if ( ! $resource ) die ( " : $query <br> " . mysql_error ( ) ) ; echo "<b> :</b> $query <br>" ; return $resource ; } function sqlSet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) cacheSet ( $table , uniqid ( time ( ) , true ) , 24 * 3600 ) ; return sqlQuery ( $query ) ; } function sqlGet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) $appendix .= cacheGet ( $table ) ; $appendix = "/*" . md5 ( $appendix ) . "*/" ; $query = $query . $appendix ; $cache_key = md5 ( $query ) ; $result = cacheGet ( $cache_key ) ; if ( $result !== false ) { echo "<b> :</b> $query <br>" ; return $result ; } else echo "<b> :</b> $query <br>" ; $resource = sqlQuery ( $query ) ; $result = array ( ) ; while ( $row = mysql_fetch_assoc ( $resource ) ) { $result [ ] = $row ; } cacheSet ( $cache_key , $result , 3600 ) ; return $result ; } ?> <h2>. </h2> <h3> 2 </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; // "select * from <<$mysql_table1>> where id=1", ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3> </h3> <? sqlSet ( "delete from << $mysql_table2 >> where 1=0" ) ; ?> <h3> </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3>: , . </h3>
<? header ( 'Content-type: text/html; charset=UTF-8' ) ; $mysql_host = 'localhost' ; $mysql_username = 'root' ; $mysql_password = '12345' ; $mysql_database = 'test' ; // , $mysql_table1 = 'table1' ; $mysql_table2 = 'table2' ; $memcache_host = 'localhost' ; $memcache_port = 11211 ; $mysql = mysql_connect ( $mysql_host , $mysql_username , $mysql_password ) ; if ( ! $mysql ) die ( " MySQL: $mysql_username @ $mysql_host / $mysql_password " ) ; if ( ! mysql_select_db ( $mysql_database ) ) die ( " : $mysql_database " ) ; $memcache = new Memcache ; if ( ! $memcache -> pconnect ( $memcache_host , $memcache_port ) ) die ( "Memcached : $memcache_host : $memcache_port " ) ; function cacheGet ( $key ) { global $memcache ; return $memcache -> get ( $key ) ; } function cacheSet ( $key , $data , $delay ) { global $memcache ; return $memcache -> set ( $key , $data , 0 , $delay ) ; } function sqlExtractTables ( & $query ) { preg_match_all ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , $query , $tables ) ; if ( ! $tables [ 1 ] ) die ( " , '<<table_name>>': $query " ) ; $query = preg_replace ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , "\ \1 " , $query ) ; return $tables [ 1 ] ; } function sqlQuery ( $query ) { $resource = mysql_query ( $query ) ; if ( ! $resource ) die ( " : $query <br> " . mysql_error ( ) ) ; echo "<b> :</b> $query <br>" ; return $resource ; } function sqlSet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) cacheSet ( $table , uniqid ( time ( ) , true ) , 24 * 3600 ) ; return sqlQuery ( $query ) ; } function sqlGet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) $appendix .= cacheGet ( $table ) ; $appendix = "/*" . md5 ( $appendix ) . "*/" ; $query = $query . $appendix ; $cache_key = md5 ( $query ) ; $result = cacheGet ( $cache_key ) ; if ( $result !== false ) { echo "<b> :</b> $query <br>" ; return $result ; } else echo "<b> :</b> $query <br>" ; $resource = sqlQuery ( $query ) ; $result = array ( ) ; while ( $row = mysql_fetch_assoc ( $resource ) ) { $result [ ] = $row ; } cacheSet ( $cache_key , $result , 3600 ) ; return $result ; } ?> <h2>. </h2> <h3> 2 </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; // "select * from <<$mysql_table1>> where id=1", ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3> </h3> <? sqlSet ( "delete from << $mysql_table2 >> where 1=0" ) ; ?> <h3> </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3>: , . </h3>
<? header ( 'Content-type: text/html; charset=UTF-8' ) ; $mysql_host = 'localhost' ; $mysql_username = 'root' ; $mysql_password = '12345' ; $mysql_database = 'test' ; // , $mysql_table1 = 'table1' ; $mysql_table2 = 'table2' ; $memcache_host = 'localhost' ; $memcache_port = 11211 ; $mysql = mysql_connect ( $mysql_host , $mysql_username , $mysql_password ) ; if ( ! $mysql ) die ( " MySQL: $mysql_username @ $mysql_host / $mysql_password " ) ; if ( ! mysql_select_db ( $mysql_database ) ) die ( " : $mysql_database " ) ; $memcache = new Memcache ; if ( ! $memcache -> pconnect ( $memcache_host , $memcache_port ) ) die ( "Memcached : $memcache_host : $memcache_port " ) ; function cacheGet ( $key ) { global $memcache ; return $memcache -> get ( $key ) ; } function cacheSet ( $key , $data , $delay ) { global $memcache ; return $memcache -> set ( $key , $data , 0 , $delay ) ; } function sqlExtractTables ( & $query ) { preg_match_all ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , $query , $tables ) ; if ( ! $tables [ 1 ] ) die ( " , '<<table_name>>': $query " ) ; $query = preg_replace ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , "\ \1 " , $query ) ; return $tables [ 1 ] ; } function sqlQuery ( $query ) { $resource = mysql_query ( $query ) ; if ( ! $resource ) die ( " : $query <br> " . mysql_error ( ) ) ; echo "<b> :</b> $query <br>" ; return $resource ; } function sqlSet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) cacheSet ( $table , uniqid ( time ( ) , true ) , 24 * 3600 ) ; return sqlQuery ( $query ) ; } function sqlGet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) $appendix .= cacheGet ( $table ) ; $appendix = "/*" . md5 ( $appendix ) . "*/" ; $query = $query . $appendix ; $cache_key = md5 ( $query ) ; $result = cacheGet ( $cache_key ) ; if ( $result !== false ) { echo "<b> :</b> $query <br>" ; return $result ; } else echo "<b> :</b> $query <br>" ; $resource = sqlQuery ( $query ) ; $result = array ( ) ; while ( $row = mysql_fetch_assoc ( $resource ) ) { $result [ ] = $row ; } cacheSet ( $cache_key , $result , 3600 ) ; return $result ; } ?> <h2>. </h2> <h3> 2 </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; // "select * from <<$mysql_table1>> where id=1", ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3> </h3> <? sqlSet ( "delete from << $mysql_table2 >> where 1=0" ) ; ?> <h3> </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3>: , . </h3>
<? header ( 'Content-type: text/html; charset=UTF-8' ) ; $mysql_host = 'localhost' ; $mysql_username = 'root' ; $mysql_password = '12345' ; $mysql_database = 'test' ; // , $mysql_table1 = 'table1' ; $mysql_table2 = 'table2' ; $memcache_host = 'localhost' ; $memcache_port = 11211 ; $mysql = mysql_connect ( $mysql_host , $mysql_username , $mysql_password ) ; if ( ! $mysql ) die ( " MySQL: $mysql_username @ $mysql_host / $mysql_password " ) ; if ( ! mysql_select_db ( $mysql_database ) ) die ( " : $mysql_database " ) ; $memcache = new Memcache ; if ( ! $memcache -> pconnect ( $memcache_host , $memcache_port ) ) die ( "Memcached : $memcache_host : $memcache_port " ) ; function cacheGet ( $key ) { global $memcache ; return $memcache -> get ( $key ) ; } function cacheSet ( $key , $data , $delay ) { global $memcache ; return $memcache -> set ( $key , $data , 0 , $delay ) ; } function sqlExtractTables ( & $query ) { preg_match_all ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , $query , $tables ) ; if ( ! $tables [ 1 ] ) die ( " , '<<table_name>>': $query " ) ; $query = preg_replace ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , "\ \1 " , $query ) ; return $tables [ 1 ] ; } function sqlQuery ( $query ) { $resource = mysql_query ( $query ) ; if ( ! $resource ) die ( " : $query <br> " . mysql_error ( ) ) ; echo "<b> :</b> $query <br>" ; return $resource ; } function sqlSet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) cacheSet ( $table , uniqid ( time ( ) , true ) , 24 * 3600 ) ; return sqlQuery ( $query ) ; } function sqlGet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) $appendix .= cacheGet ( $table ) ; $appendix = "/*" . md5 ( $appendix ) . "*/" ; $query = $query . $appendix ; $cache_key = md5 ( $query ) ; $result = cacheGet ( $cache_key ) ; if ( $result !== false ) { echo "<b> :</b> $query <br>" ; return $result ; } else echo "<b> :</b> $query <br>" ; $resource = sqlQuery ( $query ) ; $result = array ( ) ; while ( $row = mysql_fetch_assoc ( $resource ) ) { $result [ ] = $row ; } cacheSet ( $cache_key , $result , 3600 ) ; return $result ; } ?> <h2>. </h2> <h3> 2 </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; // "select * from <<$mysql_table1>> where id=1", ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3> </h3> <? sqlSet ( "delete from << $mysql_table2 >> where 1=0" ) ; ?> <h3> </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3>: , . </h3>
<? header ( 'Content-type: text/html; charset=UTF-8' ) ; $mysql_host = 'localhost' ; $mysql_username = 'root' ; $mysql_password = '12345' ; $mysql_database = 'test' ; // , $mysql_table1 = 'table1' ; $mysql_table2 = 'table2' ; $memcache_host = 'localhost' ; $memcache_port = 11211 ; $mysql = mysql_connect ( $mysql_host , $mysql_username , $mysql_password ) ; if ( ! $mysql ) die ( " MySQL: $mysql_username @ $mysql_host / $mysql_password " ) ; if ( ! mysql_select_db ( $mysql_database ) ) die ( " : $mysql_database " ) ; $memcache = new Memcache ; if ( ! $memcache -> pconnect ( $memcache_host , $memcache_port ) ) die ( "Memcached : $memcache_host : $memcache_port " ) ; function cacheGet ( $key ) { global $memcache ; return $memcache -> get ( $key ) ; } function cacheSet ( $key , $data , $delay ) { global $memcache ; return $memcache -> set ( $key , $data , 0 , $delay ) ; } function sqlExtractTables ( & $query ) { preg_match_all ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , $query , $tables ) ; if ( ! $tables [ 1 ] ) die ( " , '<<table_name>>': $query " ) ; $query = preg_replace ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , "\ \1 " , $query ) ; return $tables [ 1 ] ; } function sqlQuery ( $query ) { $resource = mysql_query ( $query ) ; if ( ! $resource ) die ( " : $query <br> " . mysql_error ( ) ) ; echo "<b> :</b> $query <br>" ; return $resource ; } function sqlSet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) cacheSet ( $table , uniqid ( time ( ) , true ) , 24 * 3600 ) ; return sqlQuery ( $query ) ; } function sqlGet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) $appendix .= cacheGet ( $table ) ; $appendix = "/*" . md5 ( $appendix ) . "*/" ; $query = $query . $appendix ; $cache_key = md5 ( $query ) ; $result = cacheGet ( $cache_key ) ; if ( $result !== false ) { echo "<b> :</b> $query <br>" ; return $result ; } else echo "<b> :</b> $query <br>" ; $resource = sqlQuery ( $query ) ; $result = array ( ) ; while ( $row = mysql_fetch_assoc ( $resource ) ) { $result [ ] = $row ; } cacheSet ( $cache_key , $result , 3600 ) ; return $result ; } ?> <h2>. </h2> <h3> 2 </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; // "select * from <<$mysql_table1>> where id=1", ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3> </h3> <? sqlSet ( "delete from << $mysql_table2 >> where 1=0" ) ; ?> <h3> </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3>: , . </h3>
<? header ( 'Content-type: text/html; charset=UTF-8' ) ; $mysql_host = 'localhost' ; $mysql_username = 'root' ; $mysql_password = '12345' ; $mysql_database = 'test' ; // , $mysql_table1 = 'table1' ; $mysql_table2 = 'table2' ; $memcache_host = 'localhost' ; $memcache_port = 11211 ; $mysql = mysql_connect ( $mysql_host , $mysql_username , $mysql_password ) ; if ( ! $mysql ) die ( " MySQL: $mysql_username @ $mysql_host / $mysql_password " ) ; if ( ! mysql_select_db ( $mysql_database ) ) die ( " : $mysql_database " ) ; $memcache = new Memcache ; if ( ! $memcache -> pconnect ( $memcache_host , $memcache_port ) ) die ( "Memcached : $memcache_host : $memcache_port " ) ; function cacheGet ( $key ) { global $memcache ; return $memcache -> get ( $key ) ; } function cacheSet ( $key , $data , $delay ) { global $memcache ; return $memcache -> set ( $key , $data , 0 , $delay ) ; } function sqlExtractTables ( & $query ) { preg_match_all ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , $query , $tables ) ; if ( ! $tables [ 1 ] ) die ( " , '<<table_name>>': $query " ) ; $query = preg_replace ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , "\ \1 " , $query ) ; return $tables [ 1 ] ; } function sqlQuery ( $query ) { $resource = mysql_query ( $query ) ; if ( ! $resource ) die ( " : $query <br> " . mysql_error ( ) ) ; echo "<b> :</b> $query <br>" ; return $resource ; } function sqlSet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) cacheSet ( $table , uniqid ( time ( ) , true ) , 24 * 3600 ) ; return sqlQuery ( $query ) ; } function sqlGet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) $appendix .= cacheGet ( $table ) ; $appendix = "/*" . md5 ( $appendix ) . "*/" ; $query = $query . $appendix ; $cache_key = md5 ( $query ) ; $result = cacheGet ( $cache_key ) ; if ( $result !== false ) { echo "<b> :</b> $query <br>" ; return $result ; } else echo "<b> :</b> $query <br>" ; $resource = sqlQuery ( $query ) ; $result = array ( ) ; while ( $row = mysql_fetch_assoc ( $resource ) ) { $result [ ] = $row ; } cacheSet ( $cache_key , $result , 3600 ) ; return $result ; } ?> <h2>. </h2> <h3> 2 </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; // "select * from <<$mysql_table1>> where id=1", ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3> </h3> <? sqlSet ( "delete from << $mysql_table2 >> where 1=0" ) ; ?> <h3> </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3>: , . </h3>
<? header ( 'Content-type: text/html; charset=UTF-8' ) ; $mysql_host = 'localhost' ; $mysql_username = 'root' ; $mysql_password = '12345' ; $mysql_database = 'test' ; // , $mysql_table1 = 'table1' ; $mysql_table2 = 'table2' ; $memcache_host = 'localhost' ; $memcache_port = 11211 ; $mysql = mysql_connect ( $mysql_host , $mysql_username , $mysql_password ) ; if ( ! $mysql ) die ( " MySQL: $mysql_username @ $mysql_host / $mysql_password " ) ; if ( ! mysql_select_db ( $mysql_database ) ) die ( " : $mysql_database " ) ; $memcache = new Memcache ; if ( ! $memcache -> pconnect ( $memcache_host , $memcache_port ) ) die ( "Memcached : $memcache_host : $memcache_port " ) ; function cacheGet ( $key ) { global $memcache ; return $memcache -> get ( $key ) ; } function cacheSet ( $key , $data , $delay ) { global $memcache ; return $memcache -> set ( $key , $data , 0 , $delay ) ; } function sqlExtractTables ( & $query ) { preg_match_all ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , $query , $tables ) ; if ( ! $tables [ 1 ] ) die ( " , '<<table_name>>': $query " ) ; $query = preg_replace ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , "\ \1 " , $query ) ; return $tables [ 1 ] ; } function sqlQuery ( $query ) { $resource = mysql_query ( $query ) ; if ( ! $resource ) die ( " : $query <br> " . mysql_error ( ) ) ; echo "<b> :</b> $query <br>" ; return $resource ; } function sqlSet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) cacheSet ( $table , uniqid ( time ( ) , true ) , 24 * 3600 ) ; return sqlQuery ( $query ) ; } function sqlGet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) $appendix .= cacheGet ( $table ) ; $appendix = "/*" . md5 ( $appendix ) . "*/" ; $query = $query . $appendix ; $cache_key = md5 ( $query ) ; $result = cacheGet ( $cache_key ) ; if ( $result !== false ) { echo "<b> :</b> $query <br>" ; return $result ; } else echo "<b> :</b> $query <br>" ; $resource = sqlQuery ( $query ) ; $result = array ( ) ; while ( $row = mysql_fetch_assoc ( $resource ) ) { $result [ ] = $row ; } cacheSet ( $cache_key , $result , 3600 ) ; return $result ; } ?> <h2>. </h2> <h3> 2 </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; // "select * from <<$mysql_table1>> where id=1", ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3> </h3> <? sqlSet ( "delete from << $mysql_table2 >> where 1=0" ) ; ?> <h3> </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3>: , . </h3>
<? header ( 'Content-type: text/html; charset=UTF-8' ) ; $mysql_host = 'localhost' ; $mysql_username = 'root' ; $mysql_password = '12345' ; $mysql_database = 'test' ; // , $mysql_table1 = 'table1' ; $mysql_table2 = 'table2' ; $memcache_host = 'localhost' ; $memcache_port = 11211 ; $mysql = mysql_connect ( $mysql_host , $mysql_username , $mysql_password ) ; if ( ! $mysql ) die ( " MySQL: $mysql_username @ $mysql_host / $mysql_password " ) ; if ( ! mysql_select_db ( $mysql_database ) ) die ( " : $mysql_database " ) ; $memcache = new Memcache ; if ( ! $memcache -> pconnect ( $memcache_host , $memcache_port ) ) die ( "Memcached : $memcache_host : $memcache_port " ) ; function cacheGet ( $key ) { global $memcache ; return $memcache -> get ( $key ) ; } function cacheSet ( $key , $data , $delay ) { global $memcache ; return $memcache -> set ( $key , $data , 0 , $delay ) ; } function sqlExtractTables ( & $query ) { preg_match_all ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , $query , $tables ) ; if ( ! $tables [ 1 ] ) die ( " , '<<table_name>>': $query " ) ; $query = preg_replace ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , "\ \1 " , $query ) ; return $tables [ 1 ] ; } function sqlQuery ( $query ) { $resource = mysql_query ( $query ) ; if ( ! $resource ) die ( " : $query <br> " . mysql_error ( ) ) ; echo "<b> :</b> $query <br>" ; return $resource ; } function sqlSet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) cacheSet ( $table , uniqid ( time ( ) , true ) , 24 * 3600 ) ; return sqlQuery ( $query ) ; } function sqlGet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) $appendix .= cacheGet ( $table ) ; $appendix = "/*" . md5 ( $appendix ) . "*/" ; $query = $query . $appendix ; $cache_key = md5 ( $query ) ; $result = cacheGet ( $cache_key ) ; if ( $result !== false ) { echo "<b> :</b> $query <br>" ; return $result ; } else echo "<b> :</b> $query <br>" ; $resource = sqlQuery ( $query ) ; $result = array ( ) ; while ( $row = mysql_fetch_assoc ( $resource ) ) { $result [ ] = $row ; } cacheSet ( $cache_key , $result , 3600 ) ; return $result ; } ?> <h2>. </h2> <h3> 2 </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; // "select * from <<$mysql_table1>> where id=1", ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3> </h3> <? sqlSet ( "delete from << $mysql_table2 >> where 1=0" ) ; ?> <h3> </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3>: , . </h3>
<? header ( 'Content-type: text/html; charset=UTF-8' ) ; $mysql_host = 'localhost' ; $mysql_username = 'root' ; $mysql_password = '12345' ; $mysql_database = 'test' ; // , $mysql_table1 = 'table1' ; $mysql_table2 = 'table2' ; $memcache_host = 'localhost' ; $memcache_port = 11211 ; $mysql = mysql_connect ( $mysql_host , $mysql_username , $mysql_password ) ; if ( ! $mysql ) die ( " MySQL: $mysql_username @ $mysql_host / $mysql_password " ) ; if ( ! mysql_select_db ( $mysql_database ) ) die ( " : $mysql_database " ) ; $memcache = new Memcache ; if ( ! $memcache -> pconnect ( $memcache_host , $memcache_port ) ) die ( "Memcached : $memcache_host : $memcache_port " ) ; function cacheGet ( $key ) { global $memcache ; return $memcache -> get ( $key ) ; } function cacheSet ( $key , $data , $delay ) { global $memcache ; return $memcache -> set ( $key , $data , 0 , $delay ) ; } function sqlExtractTables ( & $query ) { preg_match_all ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , $query , $tables ) ; if ( ! $tables [ 1 ] ) die ( " , '<<table_name>>': $query " ) ; $query = preg_replace ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , "\ \1 " , $query ) ; return $tables [ 1 ] ; } function sqlQuery ( $query ) { $resource = mysql_query ( $query ) ; if ( ! $resource ) die ( " : $query <br> " . mysql_error ( ) ) ; echo "<b> :</b> $query <br>" ; return $resource ; } function sqlSet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) cacheSet ( $table , uniqid ( time ( ) , true ) , 24 * 3600 ) ; return sqlQuery ( $query ) ; } function sqlGet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) $appendix .= cacheGet ( $table ) ; $appendix = "/*" . md5 ( $appendix ) . "*/" ; $query = $query . $appendix ; $cache_key = md5 ( $query ) ; $result = cacheGet ( $cache_key ) ; if ( $result !== false ) { echo "<b> :</b> $query <br>" ; return $result ; } else echo "<b> :</b> $query <br>" ; $resource = sqlQuery ( $query ) ; $result = array ( ) ; while ( $row = mysql_fetch_assoc ( $resource ) ) { $result [ ] = $row ; } cacheSet ( $cache_key , $result , 3600 ) ; return $result ; } ?> <h2>. </h2> <h3> 2 </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; // "select * from <<$mysql_table1>> where id=1", ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3> </h3> <? sqlSet ( "delete from << $mysql_table2 >> where 1=0" ) ; ?> <h3> </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3>: , . </h3>
<? header ( 'Content-type: text/html; charset=UTF-8' ) ; $mysql_host = 'localhost' ; $mysql_username = 'root' ; $mysql_password = '12345' ; $mysql_database = 'test' ; // , $mysql_table1 = 'table1' ; $mysql_table2 = 'table2' ; $memcache_host = 'localhost' ; $memcache_port = 11211 ; $mysql = mysql_connect ( $mysql_host , $mysql_username , $mysql_password ) ; if ( ! $mysql ) die ( " MySQL: $mysql_username @ $mysql_host / $mysql_password " ) ; if ( ! mysql_select_db ( $mysql_database ) ) die ( " : $mysql_database " ) ; $memcache = new Memcache ; if ( ! $memcache -> pconnect ( $memcache_host , $memcache_port ) ) die ( "Memcached : $memcache_host : $memcache_port " ) ; function cacheGet ( $key ) { global $memcache ; return $memcache -> get ( $key ) ; } function cacheSet ( $key , $data , $delay ) { global $memcache ; return $memcache -> set ( $key , $data , 0 , $delay ) ; } function sqlExtractTables ( & $query ) { preg_match_all ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , $query , $tables ) ; if ( ! $tables [ 1 ] ) die ( " , '<<table_name>>': $query " ) ; $query = preg_replace ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , "\ \1 " , $query ) ; return $tables [ 1 ] ; } function sqlQuery ( $query ) { $resource = mysql_query ( $query ) ; if ( ! $resource ) die ( " : $query <br> " . mysql_error ( ) ) ; echo "<b> :</b> $query <br>" ; return $resource ; } function sqlSet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) cacheSet ( $table , uniqid ( time ( ) , true ) , 24 * 3600 ) ; return sqlQuery ( $query ) ; } function sqlGet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) $appendix .= cacheGet ( $table ) ; $appendix = "/*" . md5 ( $appendix ) . "*/" ; $query = $query . $appendix ; $cache_key = md5 ( $query ) ; $result = cacheGet ( $cache_key ) ; if ( $result !== false ) { echo "<b> :</b> $query <br>" ; return $result ; } else echo "<b> :</b> $query <br>" ; $resource = sqlQuery ( $query ) ; $result = array ( ) ; while ( $row = mysql_fetch_assoc ( $resource ) ) { $result [ ] = $row ; } cacheSet ( $cache_key , $result , 3600 ) ; return $result ; } ?> <h2>. </h2> <h3> 2 </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; // "select * from <<$mysql_table1>> where id=1", ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3> </h3> <? sqlSet ( "delete from << $mysql_table2 >> where 1=0" ) ; ?> <h3> </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3>: , . </h3>
<? header ( 'Content-type: text/html; charset=UTF-8' ) ; $mysql_host = 'localhost' ; $mysql_username = 'root' ; $mysql_password = '12345' ; $mysql_database = 'test' ; // , $mysql_table1 = 'table1' ; $mysql_table2 = 'table2' ; $memcache_host = 'localhost' ; $memcache_port = 11211 ; $mysql = mysql_connect ( $mysql_host , $mysql_username , $mysql_password ) ; if ( ! $mysql ) die ( " MySQL: $mysql_username @ $mysql_host / $mysql_password " ) ; if ( ! mysql_select_db ( $mysql_database ) ) die ( " : $mysql_database " ) ; $memcache = new Memcache ; if ( ! $memcache -> pconnect ( $memcache_host , $memcache_port ) ) die ( "Memcached : $memcache_host : $memcache_port " ) ; function cacheGet ( $key ) { global $memcache ; return $memcache -> get ( $key ) ; } function cacheSet ( $key , $data , $delay ) { global $memcache ; return $memcache -> set ( $key , $data , 0 , $delay ) ; } function sqlExtractTables ( & $query ) { preg_match_all ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , $query , $tables ) ; if ( ! $tables [ 1 ] ) die ( " , '<<table_name>>': $query " ) ; $query = preg_replace ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , "\ \1 " , $query ) ; return $tables [ 1 ] ; } function sqlQuery ( $query ) { $resource = mysql_query ( $query ) ; if ( ! $resource ) die ( " : $query <br> " . mysql_error ( ) ) ; echo "<b> :</b> $query <br>" ; return $resource ; } function sqlSet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) cacheSet ( $table , uniqid ( time ( ) , true ) , 24 * 3600 ) ; return sqlQuery ( $query ) ; } function sqlGet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) $appendix .= cacheGet ( $table ) ; $appendix = "/*" . md5 ( $appendix ) . "*/" ; $query = $query . $appendix ; $cache_key = md5 ( $query ) ; $result = cacheGet ( $cache_key ) ; if ( $result !== false ) { echo "<b> :</b> $query <br>" ; return $result ; } else echo "<b> :</b> $query <br>" ; $resource = sqlQuery ( $query ) ; $result = array ( ) ; while ( $row = mysql_fetch_assoc ( $resource ) ) { $result [ ] = $row ; } cacheSet ( $cache_key , $result , 3600 ) ; return $result ; } ?> <h2>. </h2> <h3> 2 </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; // "select * from <<$mysql_table1>> where id=1", ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3> </h3> <? sqlSet ( "delete from << $mysql_table2 >> where 1=0" ) ; ?> <h3> </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3>: , . </h3>
<? header ( 'Content-type: text/html; charset=UTF-8' ) ; $mysql_host = 'localhost' ; $mysql_username = 'root' ; $mysql_password = '12345' ; $mysql_database = 'test' ; // , $mysql_table1 = 'table1' ; $mysql_table2 = 'table2' ; $memcache_host = 'localhost' ; $memcache_port = 11211 ; $mysql = mysql_connect ( $mysql_host , $mysql_username , $mysql_password ) ; if ( ! $mysql ) die ( " MySQL: $mysql_username @ $mysql_host / $mysql_password " ) ; if ( ! mysql_select_db ( $mysql_database ) ) die ( " : $mysql_database " ) ; $memcache = new Memcache ; if ( ! $memcache -> pconnect ( $memcache_host , $memcache_port ) ) die ( "Memcached : $memcache_host : $memcache_port " ) ; function cacheGet ( $key ) { global $memcache ; return $memcache -> get ( $key ) ; } function cacheSet ( $key , $data , $delay ) { global $memcache ; return $memcache -> set ( $key , $data , 0 , $delay ) ; } function sqlExtractTables ( & $query ) { preg_match_all ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , $query , $tables ) ; if ( ! $tables [ 1 ] ) die ( " , '<<table_name>>': $query " ) ; $query = preg_replace ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , "\ \1 " , $query ) ; return $tables [ 1 ] ; } function sqlQuery ( $query ) { $resource = mysql_query ( $query ) ; if ( ! $resource ) die ( " : $query <br> " . mysql_error ( ) ) ; echo "<b> :</b> $query <br>" ; return $resource ; } function sqlSet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) cacheSet ( $table , uniqid ( time ( ) , true ) , 24 * 3600 ) ; return sqlQuery ( $query ) ; } function sqlGet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) $appendix .= cacheGet ( $table ) ; $appendix = "/*" . md5 ( $appendix ) . "*/" ; $query = $query . $appendix ; $cache_key = md5 ( $query ) ; $result = cacheGet ( $cache_key ) ; if ( $result !== false ) { echo "<b> :</b> $query <br>" ; return $result ; } else echo "<b> :</b> $query <br>" ; $resource = sqlQuery ( $query ) ; $result = array ( ) ; while ( $row = mysql_fetch_assoc ( $resource ) ) { $result [ ] = $row ; } cacheSet ( $cache_key , $result , 3600 ) ; return $result ; } ?> <h2>. </h2> <h3> 2 </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; // "select * from <<$mysql_table1>> where id=1", ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3> </h3> <? sqlSet ( "delete from << $mysql_table2 >> where 1=0" ) ; ?> <h3> </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3>: , . </h3>
<? header ( 'Content-type: text/html; charset=UTF-8' ) ; $mysql_host = 'localhost' ; $mysql_username = 'root' ; $mysql_password = '12345' ; $mysql_database = 'test' ; // , $mysql_table1 = 'table1' ; $mysql_table2 = 'table2' ; $memcache_host = 'localhost' ; $memcache_port = 11211 ; $mysql = mysql_connect ( $mysql_host , $mysql_username , $mysql_password ) ; if ( ! $mysql ) die ( " MySQL: $mysql_username @ $mysql_host / $mysql_password " ) ; if ( ! mysql_select_db ( $mysql_database ) ) die ( " : $mysql_database " ) ; $memcache = new Memcache ; if ( ! $memcache -> pconnect ( $memcache_host , $memcache_port ) ) die ( "Memcached : $memcache_host : $memcache_port " ) ; function cacheGet ( $key ) { global $memcache ; return $memcache -> get ( $key ) ; } function cacheSet ( $key , $data , $delay ) { global $memcache ; return $memcache -> set ( $key , $data , 0 , $delay ) ; } function sqlExtractTables ( & $query ) { preg_match_all ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , $query , $tables ) ; if ( ! $tables [ 1 ] ) die ( " , '<<table_name>>': $query " ) ; $query = preg_replace ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , "\ \1 " , $query ) ; return $tables [ 1 ] ; } function sqlQuery ( $query ) { $resource = mysql_query ( $query ) ; if ( ! $resource ) die ( " : $query <br> " . mysql_error ( ) ) ; echo "<b> :</b> $query <br>" ; return $resource ; } function sqlSet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) cacheSet ( $table , uniqid ( time ( ) , true ) , 24 * 3600 ) ; return sqlQuery ( $query ) ; } function sqlGet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) $appendix .= cacheGet ( $table ) ; $appendix = "/*" . md5 ( $appendix ) . "*/" ; $query = $query . $appendix ; $cache_key = md5 ( $query ) ; $result = cacheGet ( $cache_key ) ; if ( $result !== false ) { echo "<b> :</b> $query <br>" ; return $result ; } else echo "<b> :</b> $query <br>" ; $resource = sqlQuery ( $query ) ; $result = array ( ) ; while ( $row = mysql_fetch_assoc ( $resource ) ) { $result [ ] = $row ; } cacheSet ( $cache_key , $result , 3600 ) ; return $result ; } ?> <h2>. </h2> <h3> 2 </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; // "select * from <<$mysql_table1>> where id=1", ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3> </h3> <? sqlSet ( "delete from << $mysql_table2 >> where 1=0" ) ; ?> <h3> </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3>: , . </h3>
<? header ( 'Content-type: text/html; charset=UTF-8' ) ; $mysql_host = 'localhost' ; $mysql_username = 'root' ; $mysql_password = '12345' ; $mysql_database = 'test' ; // , $mysql_table1 = 'table1' ; $mysql_table2 = 'table2' ; $memcache_host = 'localhost' ; $memcache_port = 11211 ; $mysql = mysql_connect ( $mysql_host , $mysql_username , $mysql_password ) ; if ( ! $mysql ) die ( " MySQL: $mysql_username @ $mysql_host / $mysql_password " ) ; if ( ! mysql_select_db ( $mysql_database ) ) die ( " : $mysql_database " ) ; $memcache = new Memcache ; if ( ! $memcache -> pconnect ( $memcache_host , $memcache_port ) ) die ( "Memcached : $memcache_host : $memcache_port " ) ; function cacheGet ( $key ) { global $memcache ; return $memcache -> get ( $key ) ; } function cacheSet ( $key , $data , $delay ) { global $memcache ; return $memcache -> set ( $key , $data , 0 , $delay ) ; } function sqlExtractTables ( & $query ) { preg_match_all ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , $query , $tables ) ; if ( ! $tables [ 1 ] ) die ( " , '<<table_name>>': $query " ) ; $query = preg_replace ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , "\ \1 " , $query ) ; return $tables [ 1 ] ; } function sqlQuery ( $query ) { $resource = mysql_query ( $query ) ; if ( ! $resource ) die ( " : $query <br> " . mysql_error ( ) ) ; echo "<b> :</b> $query <br>" ; return $resource ; } function sqlSet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) cacheSet ( $table , uniqid ( time ( ) , true ) , 24 * 3600 ) ; return sqlQuery ( $query ) ; } function sqlGet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) $appendix .= cacheGet ( $table ) ; $appendix = "/*" . md5 ( $appendix ) . "*/" ; $query = $query . $appendix ; $cache_key = md5 ( $query ) ; $result = cacheGet ( $cache_key ) ; if ( $result !== false ) { echo "<b> :</b> $query <br>" ; return $result ; } else echo "<b> :</b> $query <br>" ; $resource = sqlQuery ( $query ) ; $result = array ( ) ; while ( $row = mysql_fetch_assoc ( $resource ) ) { $result [ ] = $row ; } cacheSet ( $cache_key , $result , 3600 ) ; return $result ; } ?> <h2>. </h2> <h3> 2 </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; // "select * from <<$mysql_table1>> where id=1", ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3> </h3> <? sqlSet ( "delete from << $mysql_table2 >> where 1=0" ) ; ?> <h3> </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3>: , . </h3>
<? header ( 'Content-type: text/html; charset=UTF-8' ) ; $mysql_host = 'localhost' ; $mysql_username = 'root' ; $mysql_password = '12345' ; $mysql_database = 'test' ; // , $mysql_table1 = 'table1' ; $mysql_table2 = 'table2' ; $memcache_host = 'localhost' ; $memcache_port = 11211 ; $mysql = mysql_connect ( $mysql_host , $mysql_username , $mysql_password ) ; if ( ! $mysql ) die ( " MySQL: $mysql_username @ $mysql_host / $mysql_password " ) ; if ( ! mysql_select_db ( $mysql_database ) ) die ( " : $mysql_database " ) ; $memcache = new Memcache ; if ( ! $memcache -> pconnect ( $memcache_host , $memcache_port ) ) die ( "Memcached : $memcache_host : $memcache_port " ) ; function cacheGet ( $key ) { global $memcache ; return $memcache -> get ( $key ) ; } function cacheSet ( $key , $data , $delay ) { global $memcache ; return $memcache -> set ( $key , $data , 0 , $delay ) ; } function sqlExtractTables ( & $query ) { preg_match_all ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , $query , $tables ) ; if ( ! $tables [ 1 ] ) die ( " , '<<table_name>>': $query " ) ; $query = preg_replace ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , "\ \1 " , $query ) ; return $tables [ 1 ] ; } function sqlQuery ( $query ) { $resource = mysql_query ( $query ) ; if ( ! $resource ) die ( " : $query <br> " . mysql_error ( ) ) ; echo "<b> :</b> $query <br>" ; return $resource ; } function sqlSet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) cacheSet ( $table , uniqid ( time ( ) , true ) , 24 * 3600 ) ; return sqlQuery ( $query ) ; } function sqlGet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) $appendix .= cacheGet ( $table ) ; $appendix = "/*" . md5 ( $appendix ) . "*/" ; $query = $query . $appendix ; $cache_key = md5 ( $query ) ; $result = cacheGet ( $cache_key ) ; if ( $result !== false ) { echo "<b> :</b> $query <br>" ; return $result ; } else echo "<b> :</b> $query <br>" ; $resource = sqlQuery ( $query ) ; $result = array ( ) ; while ( $row = mysql_fetch_assoc ( $resource ) ) { $result [ ] = $row ; } cacheSet ( $cache_key , $result , 3600 ) ; return $result ; } ?> <h2>. </h2> <h3> 2 </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; // "select * from <<$mysql_table1>> where id=1", ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3> </h3> <? sqlSet ( "delete from << $mysql_table2 >> where 1=0" ) ; ?> <h3> </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3>: , . </h3>
<? header ( 'Content-type: text/html; charset=UTF-8' ) ; $mysql_host = 'localhost' ; $mysql_username = 'root' ; $mysql_password = '12345' ; $mysql_database = 'test' ; // , $mysql_table1 = 'table1' ; $mysql_table2 = 'table2' ; $memcache_host = 'localhost' ; $memcache_port = 11211 ; $mysql = mysql_connect ( $mysql_host , $mysql_username , $mysql_password ) ; if ( ! $mysql ) die ( " MySQL: $mysql_username @ $mysql_host / $mysql_password " ) ; if ( ! mysql_select_db ( $mysql_database ) ) die ( " : $mysql_database " ) ; $memcache = new Memcache ; if ( ! $memcache -> pconnect ( $memcache_host , $memcache_port ) ) die ( "Memcached : $memcache_host : $memcache_port " ) ; function cacheGet ( $key ) { global $memcache ; return $memcache -> get ( $key ) ; } function cacheSet ( $key , $data , $delay ) { global $memcache ; return $memcache -> set ( $key , $data , 0 , $delay ) ; } function sqlExtractTables ( & $query ) { preg_match_all ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , $query , $tables ) ; if ( ! $tables [ 1 ] ) die ( " , '<<table_name>>': $query " ) ; $query = preg_replace ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , "\ \1 " , $query ) ; return $tables [ 1 ] ; } function sqlQuery ( $query ) { $resource = mysql_query ( $query ) ; if ( ! $resource ) die ( " : $query <br> " . mysql_error ( ) ) ; echo "<b> :</b> $query <br>" ; return $resource ; } function sqlSet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) cacheSet ( $table , uniqid ( time ( ) , true ) , 24 * 3600 ) ; return sqlQuery ( $query ) ; } function sqlGet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) $appendix .= cacheGet ( $table ) ; $appendix = "/*" . md5 ( $appendix ) . "*/" ; $query = $query . $appendix ; $cache_key = md5 ( $query ) ; $result = cacheGet ( $cache_key ) ; if ( $result !== false ) { echo "<b> :</b> $query <br>" ; return $result ; } else echo "<b> :</b> $query <br>" ; $resource = sqlQuery ( $query ) ; $result = array ( ) ; while ( $row = mysql_fetch_assoc ( $resource ) ) { $result [ ] = $row ; } cacheSet ( $cache_key , $result , 3600 ) ; return $result ; } ?> <h2>. </h2> <h3> 2 </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; // "select * from <<$mysql_table1>> where id=1", ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3> </h3> <? sqlSet ( "delete from << $mysql_table2 >> where 1=0" ) ; ?> <h3> </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3>: , . </h3>
<? header ( 'Content-type: text/html; charset=UTF-8' ) ; $mysql_host = 'localhost' ; $mysql_username = 'root' ; $mysql_password = '12345' ; $mysql_database = 'test' ; // , $mysql_table1 = 'table1' ; $mysql_table2 = 'table2' ; $memcache_host = 'localhost' ; $memcache_port = 11211 ; $mysql = mysql_connect ( $mysql_host , $mysql_username , $mysql_password ) ; if ( ! $mysql ) die ( " MySQL: $mysql_username @ $mysql_host / $mysql_password " ) ; if ( ! mysql_select_db ( $mysql_database ) ) die ( " : $mysql_database " ) ; $memcache = new Memcache ; if ( ! $memcache -> pconnect ( $memcache_host , $memcache_port ) ) die ( "Memcached : $memcache_host : $memcache_port " ) ; function cacheGet ( $key ) { global $memcache ; return $memcache -> get ( $key ) ; } function cacheSet ( $key , $data , $delay ) { global $memcache ; return $memcache -> set ( $key , $data , 0 , $delay ) ; } function sqlExtractTables ( & $query ) { preg_match_all ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , $query , $tables ) ; if ( ! $tables [ 1 ] ) die ( " , '<<table_name>>': $query " ) ; $query = preg_replace ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , "\ \1 " , $query ) ; return $tables [ 1 ] ; } function sqlQuery ( $query ) { $resource = mysql_query ( $query ) ; if ( ! $resource ) die ( " : $query <br> " . mysql_error ( ) ) ; echo "<b> :</b> $query <br>" ; return $resource ; } function sqlSet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) cacheSet ( $table , uniqid ( time ( ) , true ) , 24 * 3600 ) ; return sqlQuery ( $query ) ; } function sqlGet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) $appendix .= cacheGet ( $table ) ; $appendix = "/*" . md5 ( $appendix ) . "*/" ; $query = $query . $appendix ; $cache_key = md5 ( $query ) ; $result = cacheGet ( $cache_key ) ; if ( $result !== false ) { echo "<b> :</b> $query <br>" ; return $result ; } else echo "<b> :</b> $query <br>" ; $resource = sqlQuery ( $query ) ; $result = array ( ) ; while ( $row = mysql_fetch_assoc ( $resource ) ) { $result [ ] = $row ; } cacheSet ( $cache_key , $result , 3600 ) ; return $result ; } ?> <h2>. </h2> <h3> 2 </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; // "select * from <<$mysql_table1>> where id=1", ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3> </h3> <? sqlSet ( "delete from << $mysql_table2 >> where 1=0" ) ; ?> <h3> </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3>: , . </h3>
<? header ( 'Content-type: text/html; charset=UTF-8' ) ; $mysql_host = 'localhost' ; $mysql_username = 'root' ; $mysql_password = '12345' ; $mysql_database = 'test' ; // , $mysql_table1 = 'table1' ; $mysql_table2 = 'table2' ; $memcache_host = 'localhost' ; $memcache_port = 11211 ; $mysql = mysql_connect ( $mysql_host , $mysql_username , $mysql_password ) ; if ( ! $mysql ) die ( " MySQL: $mysql_username @ $mysql_host / $mysql_password " ) ; if ( ! mysql_select_db ( $mysql_database ) ) die ( " : $mysql_database " ) ; $memcache = new Memcache ; if ( ! $memcache -> pconnect ( $memcache_host , $memcache_port ) ) die ( "Memcached : $memcache_host : $memcache_port " ) ; function cacheGet ( $key ) { global $memcache ; return $memcache -> get ( $key ) ; } function cacheSet ( $key , $data , $delay ) { global $memcache ; return $memcache -> set ( $key , $data , 0 , $delay ) ; } function sqlExtractTables ( & $query ) { preg_match_all ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , $query , $tables ) ; if ( ! $tables [ 1 ] ) die ( " , '<<table_name>>': $query " ) ; $query = preg_replace ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , "\ \1 " , $query ) ; return $tables [ 1 ] ; } function sqlQuery ( $query ) { $resource = mysql_query ( $query ) ; if ( ! $resource ) die ( " : $query <br> " . mysql_error ( ) ) ; echo "<b> :</b> $query <br>" ; return $resource ; } function sqlSet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) cacheSet ( $table , uniqid ( time ( ) , true ) , 24 * 3600 ) ; return sqlQuery ( $query ) ; } function sqlGet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) $appendix .= cacheGet ( $table ) ; $appendix = "/*" . md5 ( $appendix ) . "*/" ; $query = $query . $appendix ; $cache_key = md5 ( $query ) ; $result = cacheGet ( $cache_key ) ; if ( $result !== false ) { echo "<b> :</b> $query <br>" ; return $result ; } else echo "<b> :</b> $query <br>" ; $resource = sqlQuery ( $query ) ; $result = array ( ) ; while ( $row = mysql_fetch_assoc ( $resource ) ) { $result [ ] = $row ; } cacheSet ( $cache_key , $result , 3600 ) ; return $result ; } ?> <h2>. </h2> <h3> 2 </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; // "select * from <<$mysql_table1>> where id=1", ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3> </h3> <? sqlSet ( "delete from << $mysql_table2 >> where 1=0" ) ; ?> <h3> </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3>: , . </h3>
<? header ( 'Content-type: text/html; charset=UTF-8' ) ; $mysql_host = 'localhost' ; $mysql_username = 'root' ; $mysql_password = '12345' ; $mysql_database = 'test' ; // , $mysql_table1 = 'table1' ; $mysql_table2 = 'table2' ; $memcache_host = 'localhost' ; $memcache_port = 11211 ; $mysql = mysql_connect ( $mysql_host , $mysql_username , $mysql_password ) ; if ( ! $mysql ) die ( " MySQL: $mysql_username @ $mysql_host / $mysql_password " ) ; if ( ! mysql_select_db ( $mysql_database ) ) die ( " : $mysql_database " ) ; $memcache = new Memcache ; if ( ! $memcache -> pconnect ( $memcache_host , $memcache_port ) ) die ( "Memcached : $memcache_host : $memcache_port " ) ; function cacheGet ( $key ) { global $memcache ; return $memcache -> get ( $key ) ; } function cacheSet ( $key , $data , $delay ) { global $memcache ; return $memcache -> set ( $key , $data , 0 , $delay ) ; } function sqlExtractTables ( & $query ) { preg_match_all ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , $query , $tables ) ; if ( ! $tables [ 1 ] ) die ( " , '<<table_name>>': $query " ) ; $query = preg_replace ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , "\ \1 " , $query ) ; return $tables [ 1 ] ; } function sqlQuery ( $query ) { $resource = mysql_query ( $query ) ; if ( ! $resource ) die ( " : $query <br> " . mysql_error ( ) ) ; echo "<b> :</b> $query <br>" ; return $resource ; } function sqlSet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) cacheSet ( $table , uniqid ( time ( ) , true ) , 24 * 3600 ) ; return sqlQuery ( $query ) ; } function sqlGet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) $appendix .= cacheGet ( $table ) ; $appendix = "/*" . md5 ( $appendix ) . "*/" ; $query = $query . $appendix ; $cache_key = md5 ( $query ) ; $result = cacheGet ( $cache_key ) ; if ( $result !== false ) { echo "<b> :</b> $query <br>" ; return $result ; } else echo "<b> :</b> $query <br>" ; $resource = sqlQuery ( $query ) ; $result = array ( ) ; while ( $row = mysql_fetch_assoc ( $resource ) ) { $result [ ] = $row ; } cacheSet ( $cache_key , $result , 3600 ) ; return $result ; } ?> <h2>. </h2> <h3> 2 </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; // "select * from <<$mysql_table1>> where id=1", ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3> </h3> <? sqlSet ( "delete from << $mysql_table2 >> where 1=0" ) ; ?> <h3> </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3>: , . </h3>
<? header ( 'Content-type: text/html; charset=UTF-8' ) ; $mysql_host = 'localhost' ; $mysql_username = 'root' ; $mysql_password = '12345' ; $mysql_database = 'test' ; // , $mysql_table1 = 'table1' ; $mysql_table2 = 'table2' ; $memcache_host = 'localhost' ; $memcache_port = 11211 ; $mysql = mysql_connect ( $mysql_host , $mysql_username , $mysql_password ) ; if ( ! $mysql ) die ( " MySQL: $mysql_username @ $mysql_host / $mysql_password " ) ; if ( ! mysql_select_db ( $mysql_database ) ) die ( " : $mysql_database " ) ; $memcache = new Memcache ; if ( ! $memcache -> pconnect ( $memcache_host , $memcache_port ) ) die ( "Memcached : $memcache_host : $memcache_port " ) ; function cacheGet ( $key ) { global $memcache ; return $memcache -> get ( $key ) ; } function cacheSet ( $key , $data , $delay ) { global $memcache ; return $memcache -> set ( $key , $data , 0 , $delay ) ; } function sqlExtractTables ( & $query ) { preg_match_all ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , $query , $tables ) ; if ( ! $tables [ 1 ] ) die ( " , '<<table_name>>': $query " ) ; $query = preg_replace ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , "\ \1 " , $query ) ; return $tables [ 1 ] ; } function sqlQuery ( $query ) { $resource = mysql_query ( $query ) ; if ( ! $resource ) die ( " : $query <br> " . mysql_error ( ) ) ; echo "<b> :</b> $query <br>" ; return $resource ; } function sqlSet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) cacheSet ( $table , uniqid ( time ( ) , true ) , 24 * 3600 ) ; return sqlQuery ( $query ) ; } function sqlGet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) $appendix .= cacheGet ( $table ) ; $appendix = "/*" . md5 ( $appendix ) . "*/" ; $query = $query . $appendix ; $cache_key = md5 ( $query ) ; $result = cacheGet ( $cache_key ) ; if ( $result !== false ) { echo "<b> :</b> $query <br>" ; return $result ; } else echo "<b> :</b> $query <br>" ; $resource = sqlQuery ( $query ) ; $result = array ( ) ; while ( $row = mysql_fetch_assoc ( $resource ) ) { $result [ ] = $row ; } cacheSet ( $cache_key , $result , 3600 ) ; return $result ; } ?> <h2>. </h2> <h3> 2 </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; // "select * from <<$mysql_table1>> where id=1", ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3> </h3> <? sqlSet ( "delete from << $mysql_table2 >> where 1=0" ) ; ?> <h3> </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3>: , . </h3>
<? header ( 'Content-type: text/html; charset=UTF-8' ) ; $mysql_host = 'localhost' ; $mysql_username = 'root' ; $mysql_password = '12345' ; $mysql_database = 'test' ; // , $mysql_table1 = 'table1' ; $mysql_table2 = 'table2' ; $memcache_host = 'localhost' ; $memcache_port = 11211 ; $mysql = mysql_connect ( $mysql_host , $mysql_username , $mysql_password ) ; if ( ! $mysql ) die ( " MySQL: $mysql_username @ $mysql_host / $mysql_password " ) ; if ( ! mysql_select_db ( $mysql_database ) ) die ( " : $mysql_database " ) ; $memcache = new Memcache ; if ( ! $memcache -> pconnect ( $memcache_host , $memcache_port ) ) die ( "Memcached : $memcache_host : $memcache_port " ) ; function cacheGet ( $key ) { global $memcache ; return $memcache -> get ( $key ) ; } function cacheSet ( $key , $data , $delay ) { global $memcache ; return $memcache -> set ( $key , $data , 0 , $delay ) ; } function sqlExtractTables ( & $query ) { preg_match_all ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , $query , $tables ) ; if ( ! $tables [ 1 ] ) die ( " , '<<table_name>>': $query " ) ; $query = preg_replace ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , "\ \1 " , $query ) ; return $tables [ 1 ] ; } function sqlQuery ( $query ) { $resource = mysql_query ( $query ) ; if ( ! $resource ) die ( " : $query <br> " . mysql_error ( ) ) ; echo "<b> :</b> $query <br>" ; return $resource ; } function sqlSet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) cacheSet ( $table , uniqid ( time ( ) , true ) , 24 * 3600 ) ; return sqlQuery ( $query ) ; } function sqlGet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) $appendix .= cacheGet ( $table ) ; $appendix = "/*" . md5 ( $appendix ) . "*/" ; $query = $query . $appendix ; $cache_key = md5 ( $query ) ; $result = cacheGet ( $cache_key ) ; if ( $result !== false ) { echo "<b> :</b> $query <br>" ; return $result ; } else echo "<b> :</b> $query <br>" ; $resource = sqlQuery ( $query ) ; $result = array ( ) ; while ( $row = mysql_fetch_assoc ( $resource ) ) { $result [ ] = $row ; } cacheSet ( $cache_key , $result , 3600 ) ; return $result ; } ?> <h2>. </h2> <h3> 2 </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; // "select * from <<$mysql_table1>> where id=1", ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3> </h3> <? sqlSet ( "delete from << $mysql_table2 >> where 1=0" ) ; ?> <h3> </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3>: , . </h3>
<? header ( 'Content-type: text/html; charset=UTF-8' ) ; $mysql_host = 'localhost' ; $mysql_username = 'root' ; $mysql_password = '12345' ; $mysql_database = 'test' ; // , $mysql_table1 = 'table1' ; $mysql_table2 = 'table2' ; $memcache_host = 'localhost' ; $memcache_port = 11211 ; $mysql = mysql_connect ( $mysql_host , $mysql_username , $mysql_password ) ; if ( ! $mysql ) die ( " MySQL: $mysql_username @ $mysql_host / $mysql_password " ) ; if ( ! mysql_select_db ( $mysql_database ) ) die ( " : $mysql_database " ) ; $memcache = new Memcache ; if ( ! $memcache -> pconnect ( $memcache_host , $memcache_port ) ) die ( "Memcached : $memcache_host : $memcache_port " ) ; function cacheGet ( $key ) { global $memcache ; return $memcache -> get ( $key ) ; } function cacheSet ( $key , $data , $delay ) { global $memcache ; return $memcache -> set ( $key , $data , 0 , $delay ) ; } function sqlExtractTables ( & $query ) { preg_match_all ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , $query , $tables ) ; if ( ! $tables [ 1 ] ) die ( " , '<<table_name>>': $query " ) ; $query = preg_replace ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , "\ \1 " , $query ) ; return $tables [ 1 ] ; } function sqlQuery ( $query ) { $resource = mysql_query ( $query ) ; if ( ! $resource ) die ( " : $query <br> " . mysql_error ( ) ) ; echo "<b> :</b> $query <br>" ; return $resource ; } function sqlSet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) cacheSet ( $table , uniqid ( time ( ) , true ) , 24 * 3600 ) ; return sqlQuery ( $query ) ; } function sqlGet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) $appendix .= cacheGet ( $table ) ; $appendix = "/*" . md5 ( $appendix ) . "*/" ; $query = $query . $appendix ; $cache_key = md5 ( $query ) ; $result = cacheGet ( $cache_key ) ; if ( $result !== false ) { echo "<b> :</b> $query <br>" ; return $result ; } else echo "<b> :</b> $query <br>" ; $resource = sqlQuery ( $query ) ; $result = array ( ) ; while ( $row = mysql_fetch_assoc ( $resource ) ) { $result [ ] = $row ; } cacheSet ( $cache_key , $result , 3600 ) ; return $result ; } ?> <h2>. </h2> <h3> 2 </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; // "select * from <<$mysql_table1>> where id=1", ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3> </h3> <? sqlSet ( "delete from << $mysql_table2 >> where 1=0" ) ; ?> <h3> </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3>: , . </h3>
<? header ( 'Content-type: text/html; charset=UTF-8' ) ; $mysql_host = 'localhost' ; $mysql_username = 'root' ; $mysql_password = '12345' ; $mysql_database = 'test' ; // , $mysql_table1 = 'table1' ; $mysql_table2 = 'table2' ; $memcache_host = 'localhost' ; $memcache_port = 11211 ; $mysql = mysql_connect ( $mysql_host , $mysql_username , $mysql_password ) ; if ( ! $mysql ) die ( " MySQL: $mysql_username @ $mysql_host / $mysql_password " ) ; if ( ! mysql_select_db ( $mysql_database ) ) die ( " : $mysql_database " ) ; $memcache = new Memcache ; if ( ! $memcache -> pconnect ( $memcache_host , $memcache_port ) ) die ( "Memcached : $memcache_host : $memcache_port " ) ; function cacheGet ( $key ) { global $memcache ; return $memcache -> get ( $key ) ; } function cacheSet ( $key , $data , $delay ) { global $memcache ; return $memcache -> set ( $key , $data , 0 , $delay ) ; } function sqlExtractTables ( & $query ) { preg_match_all ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , $query , $tables ) ; if ( ! $tables [ 1 ] ) die ( " , '<<table_name>>': $query " ) ; $query = preg_replace ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , "\ \1 " , $query ) ; return $tables [ 1 ] ; } function sqlQuery ( $query ) { $resource = mysql_query ( $query ) ; if ( ! $resource ) die ( " : $query <br> " . mysql_error ( ) ) ; echo "<b> :</b> $query <br>" ; return $resource ; } function sqlSet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) cacheSet ( $table , uniqid ( time ( ) , true ) , 24 * 3600 ) ; return sqlQuery ( $query ) ; } function sqlGet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) $appendix .= cacheGet ( $table ) ; $appendix = "/*" . md5 ( $appendix ) . "*/" ; $query = $query . $appendix ; $cache_key = md5 ( $query ) ; $result = cacheGet ( $cache_key ) ; if ( $result !== false ) { echo "<b> :</b> $query <br>" ; return $result ; } else echo "<b> :</b> $query <br>" ; $resource = sqlQuery ( $query ) ; $result = array ( ) ; while ( $row = mysql_fetch_assoc ( $resource ) ) { $result [ ] = $row ; } cacheSet ( $cache_key , $result , 3600 ) ; return $result ; } ?> <h2>. </h2> <h3> 2 </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; // "select * from <<$mysql_table1>> where id=1", ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3> </h3> <? sqlSet ( "delete from << $mysql_table2 >> where 1=0" ) ; ?> <h3> </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3>: , . </h3>
<? header ( 'Content-type: text/html; charset=UTF-8' ) ; $mysql_host = 'localhost' ; $mysql_username = 'root' ; $mysql_password = '12345' ; $mysql_database = 'test' ; // , $mysql_table1 = 'table1' ; $mysql_table2 = 'table2' ; $memcache_host = 'localhost' ; $memcache_port = 11211 ; $mysql = mysql_connect ( $mysql_host , $mysql_username , $mysql_password ) ; if ( ! $mysql ) die ( " MySQL: $mysql_username @ $mysql_host / $mysql_password " ) ; if ( ! mysql_select_db ( $mysql_database ) ) die ( " : $mysql_database " ) ; $memcache = new Memcache ; if ( ! $memcache -> pconnect ( $memcache_host , $memcache_port ) ) die ( "Memcached : $memcache_host : $memcache_port " ) ; function cacheGet ( $key ) { global $memcache ; return $memcache -> get ( $key ) ; } function cacheSet ( $key , $data , $delay ) { global $memcache ; return $memcache -> set ( $key , $data , 0 , $delay ) ; } function sqlExtractTables ( & $query ) { preg_match_all ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , $query , $tables ) ; if ( ! $tables [ 1 ] ) die ( " , '<<table_name>>': $query " ) ; $query = preg_replace ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , "\ \1 " , $query ) ; return $tables [ 1 ] ; } function sqlQuery ( $query ) { $resource = mysql_query ( $query ) ; if ( ! $resource ) die ( " : $query <br> " . mysql_error ( ) ) ; echo "<b> :</b> $query <br>" ; return $resource ; } function sqlSet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) cacheSet ( $table , uniqid ( time ( ) , true ) , 24 * 3600 ) ; return sqlQuery ( $query ) ; } function sqlGet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) $appendix .= cacheGet ( $table ) ; $appendix = "/*" . md5 ( $appendix ) . "*/" ; $query = $query . $appendix ; $cache_key = md5 ( $query ) ; $result = cacheGet ( $cache_key ) ; if ( $result !== false ) { echo "<b> :</b> $query <br>" ; return $result ; } else echo "<b> :</b> $query <br>" ; $resource = sqlQuery ( $query ) ; $result = array ( ) ; while ( $row = mysql_fetch_assoc ( $resource ) ) { $result [ ] = $row ; } cacheSet ( $cache_key , $result , 3600 ) ; return $result ; } ?> <h2>. </h2> <h3> 2 </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; // "select * from <<$mysql_table1>> where id=1", ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3> </h3> <? sqlSet ( "delete from << $mysql_table2 >> where 1=0" ) ; ?> <h3> </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3>: , . </h3>
<? header ( 'Content-type: text/html; charset=UTF-8' ) ; $mysql_host = 'localhost' ; $mysql_username = 'root' ; $mysql_password = '12345' ; $mysql_database = 'test' ; // , $mysql_table1 = 'table1' ; $mysql_table2 = 'table2' ; $memcache_host = 'localhost' ; $memcache_port = 11211 ; $mysql = mysql_connect ( $mysql_host , $mysql_username , $mysql_password ) ; if ( ! $mysql ) die ( " MySQL: $mysql_username @ $mysql_host / $mysql_password " ) ; if ( ! mysql_select_db ( $mysql_database ) ) die ( " : $mysql_database " ) ; $memcache = new Memcache ; if ( ! $memcache -> pconnect ( $memcache_host , $memcache_port ) ) die ( "Memcached : $memcache_host : $memcache_port " ) ; function cacheGet ( $key ) { global $memcache ; return $memcache -> get ( $key ) ; } function cacheSet ( $key , $data , $delay ) { global $memcache ; return $memcache -> set ( $key , $data , 0 , $delay ) ; } function sqlExtractTables ( & $query ) { preg_match_all ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , $query , $tables ) ; if ( ! $tables [ 1 ] ) die ( " , '<<table_name>>': $query " ) ; $query = preg_replace ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , "\ \1 " , $query ) ; return $tables [ 1 ] ; } function sqlQuery ( $query ) { $resource = mysql_query ( $query ) ; if ( ! $resource ) die ( " : $query <br> " . mysql_error ( ) ) ; echo "<b> :</b> $query <br>" ; return $resource ; } function sqlSet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) cacheSet ( $table , uniqid ( time ( ) , true ) , 24 * 3600 ) ; return sqlQuery ( $query ) ; } function sqlGet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) $appendix .= cacheGet ( $table ) ; $appendix = "/*" . md5 ( $appendix ) . "*/" ; $query = $query . $appendix ; $cache_key = md5 ( $query ) ; $result = cacheGet ( $cache_key ) ; if ( $result !== false ) { echo "<b> :</b> $query <br>" ; return $result ; } else echo "<b> :</b> $query <br>" ; $resource = sqlQuery ( $query ) ; $result = array ( ) ; while ( $row = mysql_fetch_assoc ( $resource ) ) { $result [ ] = $row ; } cacheSet ( $cache_key , $result , 3600 ) ; return $result ; } ?> <h2>. </h2> <h3> 2 </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; // "select * from <<$mysql_table1>> where id=1", ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3> </h3> <? sqlSet ( "delete from << $mysql_table2 >> where 1=0" ) ; ?> <h3> </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3>: , . </h3>
<? header ( 'Content-type: text/html; charset=UTF-8' ) ; $mysql_host = 'localhost' ; $mysql_username = 'root' ; $mysql_password = '12345' ; $mysql_database = 'test' ; // , $mysql_table1 = 'table1' ; $mysql_table2 = 'table2' ; $memcache_host = 'localhost' ; $memcache_port = 11211 ; $mysql = mysql_connect ( $mysql_host , $mysql_username , $mysql_password ) ; if ( ! $mysql ) die ( " MySQL: $mysql_username @ $mysql_host / $mysql_password " ) ; if ( ! mysql_select_db ( $mysql_database ) ) die ( " : $mysql_database " ) ; $memcache = new Memcache ; if ( ! $memcache -> pconnect ( $memcache_host , $memcache_port ) ) die ( "Memcached : $memcache_host : $memcache_port " ) ; function cacheGet ( $key ) { global $memcache ; return $memcache -> get ( $key ) ; } function cacheSet ( $key , $data , $delay ) { global $memcache ; return $memcache -> set ( $key , $data , 0 , $delay ) ; } function sqlExtractTables ( & $query ) { preg_match_all ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , $query , $tables ) ; if ( ! $tables [ 1 ] ) die ( " , '<<table_name>>': $query " ) ; $query = preg_replace ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , "\ \1 " , $query ) ; return $tables [ 1 ] ; } function sqlQuery ( $query ) { $resource = mysql_query ( $query ) ; if ( ! $resource ) die ( " : $query <br> " . mysql_error ( ) ) ; echo "<b> :</b> $query <br>" ; return $resource ; } function sqlSet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) cacheSet ( $table , uniqid ( time ( ) , true ) , 24 * 3600 ) ; return sqlQuery ( $query ) ; } function sqlGet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) $appendix .= cacheGet ( $table ) ; $appendix = "/*" . md5 ( $appendix ) . "*/" ; $query = $query . $appendix ; $cache_key = md5 ( $query ) ; $result = cacheGet ( $cache_key ) ; if ( $result !== false ) { echo "<b> :</b> $query <br>" ; return $result ; } else echo "<b> :</b> $query <br>" ; $resource = sqlQuery ( $query ) ; $result = array ( ) ; while ( $row = mysql_fetch_assoc ( $resource ) ) { $result [ ] = $row ; } cacheSet ( $cache_key , $result , 3600 ) ; return $result ; } ?> <h2>. </h2> <h3> 2 </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; // "select * from <<$mysql_table1>> where id=1", ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3> </h3> <? sqlSet ( "delete from << $mysql_table2 >> where 1=0" ) ; ?> <h3> </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3>: , . </h3>
<? header ( 'Content-type: text/html; charset=UTF-8' ) ; $mysql_host = 'localhost' ; $mysql_username = 'root' ; $mysql_password = '12345' ; $mysql_database = 'test' ; // , $mysql_table1 = 'table1' ; $mysql_table2 = 'table2' ; $memcache_host = 'localhost' ; $memcache_port = 11211 ; $mysql = mysql_connect ( $mysql_host , $mysql_username , $mysql_password ) ; if ( ! $mysql ) die ( " MySQL: $mysql_username @ $mysql_host / $mysql_password " ) ; if ( ! mysql_select_db ( $mysql_database ) ) die ( " : $mysql_database " ) ; $memcache = new Memcache ; if ( ! $memcache -> pconnect ( $memcache_host , $memcache_port ) ) die ( "Memcached : $memcache_host : $memcache_port " ) ; function cacheGet ( $key ) { global $memcache ; return $memcache -> get ( $key ) ; } function cacheSet ( $key , $data , $delay ) { global $memcache ; return $memcache -> set ( $key , $data , 0 , $delay ) ; } function sqlExtractTables ( & $query ) { preg_match_all ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , $query , $tables ) ; if ( ! $tables [ 1 ] ) die ( " , '<<table_name>>': $query " ) ; $query = preg_replace ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , "\ \1 " , $query ) ; return $tables [ 1 ] ; } function sqlQuery ( $query ) { $resource = mysql_query ( $query ) ; if ( ! $resource ) die ( " : $query <br> " . mysql_error ( ) ) ; echo "<b> :</b> $query <br>" ; return $resource ; } function sqlSet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) cacheSet ( $table , uniqid ( time ( ) , true ) , 24 * 3600 ) ; return sqlQuery ( $query ) ; } function sqlGet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) $appendix .= cacheGet ( $table ) ; $appendix = "/*" . md5 ( $appendix ) . "*/" ; $query = $query . $appendix ; $cache_key = md5 ( $query ) ; $result = cacheGet ( $cache_key ) ; if ( $result !== false ) { echo "<b> :</b> $query <br>" ; return $result ; } else echo "<b> :</b> $query <br>" ; $resource = sqlQuery ( $query ) ; $result = array ( ) ; while ( $row = mysql_fetch_assoc ( $resource ) ) { $result [ ] = $row ; } cacheSet ( $cache_key , $result , 3600 ) ; return $result ; } ?> <h2>. </h2> <h3> 2 </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; // "select * from <<$mysql_table1>> where id=1", ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3> </h3> <? sqlSet ( "delete from << $mysql_table2 >> where 1=0" ) ; ?> <h3> </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3>: , . </h3>
<? header ( 'Content-type: text/html; charset=UTF-8' ) ; $mysql_host = 'localhost' ; $mysql_username = 'root' ; $mysql_password = '12345' ; $mysql_database = 'test' ; // , $mysql_table1 = 'table1' ; $mysql_table2 = 'table2' ; $memcache_host = 'localhost' ; $memcache_port = 11211 ; $mysql = mysql_connect ( $mysql_host , $mysql_username , $mysql_password ) ; if ( ! $mysql ) die ( " MySQL: $mysql_username @ $mysql_host / $mysql_password " ) ; if ( ! mysql_select_db ( $mysql_database ) ) die ( " : $mysql_database " ) ; $memcache = new Memcache ; if ( ! $memcache -> pconnect ( $memcache_host , $memcache_port ) ) die ( "Memcached : $memcache_host : $memcache_port " ) ; function cacheGet ( $key ) { global $memcache ; return $memcache -> get ( $key ) ; } function cacheSet ( $key , $data , $delay ) { global $memcache ; return $memcache -> set ( $key , $data , 0 , $delay ) ; } function sqlExtractTables ( & $query ) { preg_match_all ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , $query , $tables ) ; if ( ! $tables [ 1 ] ) die ( " , '<<table_name>>': $query " ) ; $query = preg_replace ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , "\ \1 " , $query ) ; return $tables [ 1 ] ; } function sqlQuery ( $query ) { $resource = mysql_query ( $query ) ; if ( ! $resource ) die ( " : $query <br> " . mysql_error ( ) ) ; echo "<b> :</b> $query <br>" ; return $resource ; } function sqlSet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) cacheSet ( $table , uniqid ( time ( ) , true ) , 24 * 3600 ) ; return sqlQuery ( $query ) ; } function sqlGet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) $appendix .= cacheGet ( $table ) ; $appendix = "/*" . md5 ( $appendix ) . "*/" ; $query = $query . $appendix ; $cache_key = md5 ( $query ) ; $result = cacheGet ( $cache_key ) ; if ( $result !== false ) { echo "<b> :</b> $query <br>" ; return $result ; } else echo "<b> :</b> $query <br>" ; $resource = sqlQuery ( $query ) ; $result = array ( ) ; while ( $row = mysql_fetch_assoc ( $resource ) ) { $result [ ] = $row ; } cacheSet ( $cache_key , $result , 3600 ) ; return $result ; } ?> <h2>. </h2> <h3> 2 </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; // "select * from <<$mysql_table1>> where id=1", ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3> </h3> <? sqlSet ( "delete from << $mysql_table2 >> where 1=0" ) ; ?> <h3> </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3>: , . </h3>
<? header ( 'Content-type: text/html; charset=UTF-8' ) ; $mysql_host = 'localhost' ; $mysql_username = 'root' ; $mysql_password = '12345' ; $mysql_database = 'test' ; // , $mysql_table1 = 'table1' ; $mysql_table2 = 'table2' ; $memcache_host = 'localhost' ; $memcache_port = 11211 ; $mysql = mysql_connect ( $mysql_host , $mysql_username , $mysql_password ) ; if ( ! $mysql ) die ( " MySQL: $mysql_username @ $mysql_host / $mysql_password " ) ; if ( ! mysql_select_db ( $mysql_database ) ) die ( " : $mysql_database " ) ; $memcache = new Memcache ; if ( ! $memcache -> pconnect ( $memcache_host , $memcache_port ) ) die ( "Memcached : $memcache_host : $memcache_port " ) ; function cacheGet ( $key ) { global $memcache ; return $memcache -> get ( $key ) ; } function cacheSet ( $key , $data , $delay ) { global $memcache ; return $memcache -> set ( $key , $data , 0 , $delay ) ; } function sqlExtractTables ( & $query ) { preg_match_all ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , $query , $tables ) ; if ( ! $tables [ 1 ] ) die ( " , '<<table_name>>': $query " ) ; $query = preg_replace ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , "\ \1 " , $query ) ; return $tables [ 1 ] ; } function sqlQuery ( $query ) { $resource = mysql_query ( $query ) ; if ( ! $resource ) die ( " : $query <br> " . mysql_error ( ) ) ; echo "<b> :</b> $query <br>" ; return $resource ; } function sqlSet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) cacheSet ( $table , uniqid ( time ( ) , true ) , 24 * 3600 ) ; return sqlQuery ( $query ) ; } function sqlGet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) $appendix .= cacheGet ( $table ) ; $appendix = "/*" . md5 ( $appendix ) . "*/" ; $query = $query . $appendix ; $cache_key = md5 ( $query ) ; $result = cacheGet ( $cache_key ) ; if ( $result !== false ) { echo "<b> :</b> $query <br>" ; return $result ; } else echo "<b> :</b> $query <br>" ; $resource = sqlQuery ( $query ) ; $result = array ( ) ; while ( $row = mysql_fetch_assoc ( $resource ) ) { $result [ ] = $row ; } cacheSet ( $cache_key , $result , 3600 ) ; return $result ; } ?> <h2>. </h2> <h3> 2 </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; // "select * from <<$mysql_table1>> where id=1", ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3> </h3> <? sqlSet ( "delete from << $mysql_table2 >> where 1=0" ) ; ?> <h3> </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3>: , . </h3>
<? header ( 'Content-type: text/html; charset=UTF-8' ) ; $mysql_host = 'localhost' ; $mysql_username = 'root' ; $mysql_password = '12345' ; $mysql_database = 'test' ; // , $mysql_table1 = 'table1' ; $mysql_table2 = 'table2' ; $memcache_host = 'localhost' ; $memcache_port = 11211 ; $mysql = mysql_connect ( $mysql_host , $mysql_username , $mysql_password ) ; if ( ! $mysql ) die ( " MySQL: $mysql_username @ $mysql_host / $mysql_password " ) ; if ( ! mysql_select_db ( $mysql_database ) ) die ( " : $mysql_database " ) ; $memcache = new Memcache ; if ( ! $memcache -> pconnect ( $memcache_host , $memcache_port ) ) die ( "Memcached : $memcache_host : $memcache_port " ) ; function cacheGet ( $key ) { global $memcache ; return $memcache -> get ( $key ) ; } function cacheSet ( $key , $data , $delay ) { global $memcache ; return $memcache -> set ( $key , $data , 0 , $delay ) ; } function sqlExtractTables ( & $query ) { preg_match_all ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , $query , $tables ) ; if ( ! $tables [ 1 ] ) die ( " , '<<table_name>>': $query " ) ; $query = preg_replace ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , "\ \1 " , $query ) ; return $tables [ 1 ] ; } function sqlQuery ( $query ) { $resource = mysql_query ( $query ) ; if ( ! $resource ) die ( " : $query <br> " . mysql_error ( ) ) ; echo "<b> :</b> $query <br>" ; return $resource ; } function sqlSet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) cacheSet ( $table , uniqid ( time ( ) , true ) , 24 * 3600 ) ; return sqlQuery ( $query ) ; } function sqlGet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) $appendix .= cacheGet ( $table ) ; $appendix = "/*" . md5 ( $appendix ) . "*/" ; $query = $query . $appendix ; $cache_key = md5 ( $query ) ; $result = cacheGet ( $cache_key ) ; if ( $result !== false ) { echo "<b> :</b> $query <br>" ; return $result ; } else echo "<b> :</b> $query <br>" ; $resource = sqlQuery ( $query ) ; $result = array ( ) ; while ( $row = mysql_fetch_assoc ( $resource ) ) { $result [ ] = $row ; } cacheSet ( $cache_key , $result , 3600 ) ; return $result ; } ?> <h2>. </h2> <h3> 2 </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; // "select * from <<$mysql_table1>> where id=1", ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3> </h3> <? sqlSet ( "delete from << $mysql_table2 >> where 1=0" ) ; ?> <h3> </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3>: , . </h3>
<? header ( 'Content-type: text/html; charset=UTF-8' ) ; $mysql_host = 'localhost' ; $mysql_username = 'root' ; $mysql_password = '12345' ; $mysql_database = 'test' ; // , $mysql_table1 = 'table1' ; $mysql_table2 = 'table2' ; $memcache_host = 'localhost' ; $memcache_port = 11211 ; $mysql = mysql_connect ( $mysql_host , $mysql_username , $mysql_password ) ; if ( ! $mysql ) die ( " MySQL: $mysql_username @ $mysql_host / $mysql_password " ) ; if ( ! mysql_select_db ( $mysql_database ) ) die ( " : $mysql_database " ) ; $memcache = new Memcache ; if ( ! $memcache -> pconnect ( $memcache_host , $memcache_port ) ) die ( "Memcached : $memcache_host : $memcache_port " ) ; function cacheGet ( $key ) { global $memcache ; return $memcache -> get ( $key ) ; } function cacheSet ( $key , $data , $delay ) { global $memcache ; return $memcache -> set ( $key , $data , 0 , $delay ) ; } function sqlExtractTables ( & $query ) { preg_match_all ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , $query , $tables ) ; if ( ! $tables [ 1 ] ) die ( " , '<<table_name>>': $query " ) ; $query = preg_replace ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , "\ \1 " , $query ) ; return $tables [ 1 ] ; } function sqlQuery ( $query ) { $resource = mysql_query ( $query ) ; if ( ! $resource ) die ( " : $query <br> " . mysql_error ( ) ) ; echo "<b> :</b> $query <br>" ; return $resource ; } function sqlSet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) cacheSet ( $table , uniqid ( time ( ) , true ) , 24 * 3600 ) ; return sqlQuery ( $query ) ; } function sqlGet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) $appendix .= cacheGet ( $table ) ; $appendix = "/*" . md5 ( $appendix ) . "*/" ; $query = $query . $appendix ; $cache_key = md5 ( $query ) ; $result = cacheGet ( $cache_key ) ; if ( $result !== false ) { echo "<b> :</b> $query <br>" ; return $result ; } else echo "<b> :</b> $query <br>" ; $resource = sqlQuery ( $query ) ; $result = array ( ) ; while ( $row = mysql_fetch_assoc ( $resource ) ) { $result [ ] = $row ; } cacheSet ( $cache_key , $result , 3600 ) ; return $result ; } ?> <h2>. </h2> <h3> 2 </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; // "select * from <<$mysql_table1>> where id=1", ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3> </h3> <? sqlSet ( "delete from << $mysql_table2 >> where 1=0" ) ; ?> <h3> </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3>: , . </h3>
<? header ( 'Content-type: text/html; charset=UTF-8' ) ; $mysql_host = 'localhost' ; $mysql_username = 'root' ; $mysql_password = '12345' ; $mysql_database = 'test' ; // , $mysql_table1 = 'table1' ; $mysql_table2 = 'table2' ; $memcache_host = 'localhost' ; $memcache_port = 11211 ; $mysql = mysql_connect ( $mysql_host , $mysql_username , $mysql_password ) ; if ( ! $mysql ) die ( " MySQL: $mysql_username @ $mysql_host / $mysql_password " ) ; if ( ! mysql_select_db ( $mysql_database ) ) die ( " : $mysql_database " ) ; $memcache = new Memcache ; if ( ! $memcache -> pconnect ( $memcache_host , $memcache_port ) ) die ( "Memcached : $memcache_host : $memcache_port " ) ; function cacheGet ( $key ) { global $memcache ; return $memcache -> get ( $key ) ; } function cacheSet ( $key , $data , $delay ) { global $memcache ; return $memcache -> set ( $key , $data , 0 , $delay ) ; } function sqlExtractTables ( & $query ) { preg_match_all ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , $query , $tables ) ; if ( ! $tables [ 1 ] ) die ( " , '<<table_name>>': $query " ) ; $query = preg_replace ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , "\ \1 " , $query ) ; return $tables [ 1 ] ; } function sqlQuery ( $query ) { $resource = mysql_query ( $query ) ; if ( ! $resource ) die ( " : $query <br> " . mysql_error ( ) ) ; echo "<b> :</b> $query <br>" ; return $resource ; } function sqlSet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) cacheSet ( $table , uniqid ( time ( ) , true ) , 24 * 3600 ) ; return sqlQuery ( $query ) ; } function sqlGet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) $appendix .= cacheGet ( $table ) ; $appendix = "/*" . md5 ( $appendix ) . "*/" ; $query = $query . $appendix ; $cache_key = md5 ( $query ) ; $result = cacheGet ( $cache_key ) ; if ( $result !== false ) { echo "<b> :</b> $query <br>" ; return $result ; } else echo "<b> :</b> $query <br>" ; $resource = sqlQuery ( $query ) ; $result = array ( ) ; while ( $row = mysql_fetch_assoc ( $resource ) ) { $result [ ] = $row ; } cacheSet ( $cache_key , $result , 3600 ) ; return $result ; } ?> <h2>. </h2> <h3> 2 </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; // "select * from <<$mysql_table1>> where id=1", ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3> </h3> <? sqlSet ( "delete from << $mysql_table2 >> where 1=0" ) ; ?> <h3> </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3>: , . </h3>
<? header ( 'Content-type: text/html; charset=UTF-8' ) ; $mysql_host = 'localhost' ; $mysql_username = 'root' ; $mysql_password = '12345' ; $mysql_database = 'test' ; // , $mysql_table1 = 'table1' ; $mysql_table2 = 'table2' ; $memcache_host = 'localhost' ; $memcache_port = 11211 ; $mysql = mysql_connect ( $mysql_host , $mysql_username , $mysql_password ) ; if ( ! $mysql ) die ( " MySQL: $mysql_username @ $mysql_host / $mysql_password " ) ; if ( ! mysql_select_db ( $mysql_database ) ) die ( " : $mysql_database " ) ; $memcache = new Memcache ; if ( ! $memcache -> pconnect ( $memcache_host , $memcache_port ) ) die ( "Memcached : $memcache_host : $memcache_port " ) ; function cacheGet ( $key ) { global $memcache ; return $memcache -> get ( $key ) ; } function cacheSet ( $key , $data , $delay ) { global $memcache ; return $memcache -> set ( $key , $data , 0 , $delay ) ; } function sqlExtractTables ( & $query ) { preg_match_all ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , $query , $tables ) ; if ( ! $tables [ 1 ] ) die ( " , '<<table_name>>': $query " ) ; $query = preg_replace ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , "\ \1 " , $query ) ; return $tables [ 1 ] ; } function sqlQuery ( $query ) { $resource = mysql_query ( $query ) ; if ( ! $resource ) die ( " : $query <br> " . mysql_error ( ) ) ; echo "<b> :</b> $query <br>" ; return $resource ; } function sqlSet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) cacheSet ( $table , uniqid ( time ( ) , true ) , 24 * 3600 ) ; return sqlQuery ( $query ) ; } function sqlGet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) $appendix .= cacheGet ( $table ) ; $appendix = "/*" . md5 ( $appendix ) . "*/" ; $query = $query . $appendix ; $cache_key = md5 ( $query ) ; $result = cacheGet ( $cache_key ) ; if ( $result !== false ) { echo "<b> :</b> $query <br>" ; return $result ; } else echo "<b> :</b> $query <br>" ; $resource = sqlQuery ( $query ) ; $result = array ( ) ; while ( $row = mysql_fetch_assoc ( $resource ) ) { $result [ ] = $row ; } cacheSet ( $cache_key , $result , 3600 ) ; return $result ; } ?> <h2>. </h2> <h3> 2 </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; // "select * from <<$mysql_table1>> where id=1", ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3> </h3> <? sqlSet ( "delete from << $mysql_table2 >> where 1=0" ) ; ?> <h3> </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3>: , . </h3>
<? header ( 'Content-type: text/html; charset=UTF-8' ) ; $mysql_host = 'localhost' ; $mysql_username = 'root' ; $mysql_password = '12345' ; $mysql_database = 'test' ; // , $mysql_table1 = 'table1' ; $mysql_table2 = 'table2' ; $memcache_host = 'localhost' ; $memcache_port = 11211 ; $mysql = mysql_connect ( $mysql_host , $mysql_username , $mysql_password ) ; if ( ! $mysql ) die ( " MySQL: $mysql_username @ $mysql_host / $mysql_password " ) ; if ( ! mysql_select_db ( $mysql_database ) ) die ( " : $mysql_database " ) ; $memcache = new Memcache ; if ( ! $memcache -> pconnect ( $memcache_host , $memcache_port ) ) die ( "Memcached : $memcache_host : $memcache_port " ) ; function cacheGet ( $key ) { global $memcache ; return $memcache -> get ( $key ) ; } function cacheSet ( $key , $data , $delay ) { global $memcache ; return $memcache -> set ( $key , $data , 0 , $delay ) ; } function sqlExtractTables ( & $query ) { preg_match_all ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , $query , $tables ) ; if ( ! $tables [ 1 ] ) die ( " , '<<table_name>>': $query " ) ; $query = preg_replace ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , "\ \1 " , $query ) ; return $tables [ 1 ] ; } function sqlQuery ( $query ) { $resource = mysql_query ( $query ) ; if ( ! $resource ) die ( " : $query <br> " . mysql_error ( ) ) ; echo "<b> :</b> $query <br>" ; return $resource ; } function sqlSet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) cacheSet ( $table , uniqid ( time ( ) , true ) , 24 * 3600 ) ; return sqlQuery ( $query ) ; } function sqlGet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) $appendix .= cacheGet ( $table ) ; $appendix = "/*" . md5 ( $appendix ) . "*/" ; $query = $query . $appendix ; $cache_key = md5 ( $query ) ; $result = cacheGet ( $cache_key ) ; if ( $result !== false ) { echo "<b> :</b> $query <br>" ; return $result ; } else echo "<b> :</b> $query <br>" ; $resource = sqlQuery ( $query ) ; $result = array ( ) ; while ( $row = mysql_fetch_assoc ( $resource ) ) { $result [ ] = $row ; } cacheSet ( $cache_key , $result , 3600 ) ; return $result ; } ?> <h2>. </h2> <h3> 2 </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; // "select * from <<$mysql_table1>> where id=1", ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3> </h3> <? sqlSet ( "delete from << $mysql_table2 >> where 1=0" ) ; ?> <h3> </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3>: , . </h3>
<? header ( 'Content-type: text/html; charset=UTF-8' ) ; $mysql_host = 'localhost' ; $mysql_username = 'root' ; $mysql_password = '12345' ; $mysql_database = 'test' ; // , $mysql_table1 = 'table1' ; $mysql_table2 = 'table2' ; $memcache_host = 'localhost' ; $memcache_port = 11211 ; $mysql = mysql_connect ( $mysql_host , $mysql_username , $mysql_password ) ; if ( ! $mysql ) die ( " MySQL: $mysql_username @ $mysql_host / $mysql_password " ) ; if ( ! mysql_select_db ( $mysql_database ) ) die ( " : $mysql_database " ) ; $memcache = new Memcache ; if ( ! $memcache -> pconnect ( $memcache_host , $memcache_port ) ) die ( "Memcached : $memcache_host : $memcache_port " ) ; function cacheGet ( $key ) { global $memcache ; return $memcache -> get ( $key ) ; } function cacheSet ( $key , $data , $delay ) { global $memcache ; return $memcache -> set ( $key , $data , 0 , $delay ) ; } function sqlExtractTables ( & $query ) { preg_match_all ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , $query , $tables ) ; if ( ! $tables [ 1 ] ) die ( " , '<<table_name>>': $query " ) ; $query = preg_replace ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , "\ \1 " , $query ) ; return $tables [ 1 ] ; } function sqlQuery ( $query ) { $resource = mysql_query ( $query ) ; if ( ! $resource ) die ( " : $query <br> " . mysql_error ( ) ) ; echo "<b> :</b> $query <br>" ; return $resource ; } function sqlSet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) cacheSet ( $table , uniqid ( time ( ) , true ) , 24 * 3600 ) ; return sqlQuery ( $query ) ; } function sqlGet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) $appendix .= cacheGet ( $table ) ; $appendix = "/*" . md5 ( $appendix ) . "*/" ; $query = $query . $appendix ; $cache_key = md5 ( $query ) ; $result = cacheGet ( $cache_key ) ; if ( $result !== false ) { echo "<b> :</b> $query <br>" ; return $result ; } else echo "<b> :</b> $query <br>" ; $resource = sqlQuery ( $query ) ; $result = array ( ) ; while ( $row = mysql_fetch_assoc ( $resource ) ) { $result [ ] = $row ; } cacheSet ( $cache_key , $result , 3600 ) ; return $result ; } ?> <h2>. </h2> <h3> 2 </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; // "select * from <<$mysql_table1>> where id=1", ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3> </h3> <? sqlSet ( "delete from << $mysql_table2 >> where 1=0" ) ; ?> <h3> </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3>: , . </h3>
<? header ( 'Content-type: text/html; charset=UTF-8' ) ; $mysql_host = 'localhost' ; $mysql_username = 'root' ; $mysql_password = '12345' ; $mysql_database = 'test' ; // , $mysql_table1 = 'table1' ; $mysql_table2 = 'table2' ; $memcache_host = 'localhost' ; $memcache_port = 11211 ; $mysql = mysql_connect ( $mysql_host , $mysql_username , $mysql_password ) ; if ( ! $mysql ) die ( " MySQL: $mysql_username @ $mysql_host / $mysql_password " ) ; if ( ! mysql_select_db ( $mysql_database ) ) die ( " : $mysql_database " ) ; $memcache = new Memcache ; if ( ! $memcache -> pconnect ( $memcache_host , $memcache_port ) ) die ( "Memcached : $memcache_host : $memcache_port " ) ; function cacheGet ( $key ) { global $memcache ; return $memcache -> get ( $key ) ; } function cacheSet ( $key , $data , $delay ) { global $memcache ; return $memcache -> set ( $key , $data , 0 , $delay ) ; } function sqlExtractTables ( & $query ) { preg_match_all ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , $query , $tables ) ; if ( ! $tables [ 1 ] ) die ( " , '<<table_name>>': $query " ) ; $query = preg_replace ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , "\ \1 " , $query ) ; return $tables [ 1 ] ; } function sqlQuery ( $query ) { $resource = mysql_query ( $query ) ; if ( ! $resource ) die ( " : $query <br> " . mysql_error ( ) ) ; echo "<b> :</b> $query <br>" ; return $resource ; } function sqlSet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) cacheSet ( $table , uniqid ( time ( ) , true ) , 24 * 3600 ) ; return sqlQuery ( $query ) ; } function sqlGet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) $appendix .= cacheGet ( $table ) ; $appendix = "/*" . md5 ( $appendix ) . "*/" ; $query = $query . $appendix ; $cache_key = md5 ( $query ) ; $result = cacheGet ( $cache_key ) ; if ( $result !== false ) { echo "<b> :</b> $query <br>" ; return $result ; } else echo "<b> :</b> $query <br>" ; $resource = sqlQuery ( $query ) ; $result = array ( ) ; while ( $row = mysql_fetch_assoc ( $resource ) ) { $result [ ] = $row ; } cacheSet ( $cache_key , $result , 3600 ) ; return $result ; } ?> <h2>. </h2> <h3> 2 </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; // "select * from <<$mysql_table1>> where id=1", ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3> </h3> <? sqlSet ( "delete from << $mysql_table2 >> where 1=0" ) ; ?> <h3> </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3>: , . </h3>
<? header ( 'Content-type: text/html; charset=UTF-8' ) ; $mysql_host = 'localhost' ; $mysql_username = 'root' ; $mysql_password = '12345' ; $mysql_database = 'test' ; // , $mysql_table1 = 'table1' ; $mysql_table2 = 'table2' ; $memcache_host = 'localhost' ; $memcache_port = 11211 ; $mysql = mysql_connect ( $mysql_host , $mysql_username , $mysql_password ) ; if ( ! $mysql ) die ( " MySQL: $mysql_username @ $mysql_host / $mysql_password " ) ; if ( ! mysql_select_db ( $mysql_database ) ) die ( " : $mysql_database " ) ; $memcache = new Memcache ; if ( ! $memcache -> pconnect ( $memcache_host , $memcache_port ) ) die ( "Memcached : $memcache_host : $memcache_port " ) ; function cacheGet ( $key ) { global $memcache ; return $memcache -> get ( $key ) ; } function cacheSet ( $key , $data , $delay ) { global $memcache ; return $memcache -> set ( $key , $data , 0 , $delay ) ; } function sqlExtractTables ( & $query ) { preg_match_all ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , $query , $tables ) ; if ( ! $tables [ 1 ] ) die ( " , '<<table_name>>': $query " ) ; $query = preg_replace ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , "\ \1 " , $query ) ; return $tables [ 1 ] ; } function sqlQuery ( $query ) { $resource = mysql_query ( $query ) ; if ( ! $resource ) die ( " : $query <br> " . mysql_error ( ) ) ; echo "<b> :</b> $query <br>" ; return $resource ; } function sqlSet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) cacheSet ( $table , uniqid ( time ( ) , true ) , 24 * 3600 ) ; return sqlQuery ( $query ) ; } function sqlGet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) $appendix .= cacheGet ( $table ) ; $appendix = "/*" . md5 ( $appendix ) . "*/" ; $query = $query . $appendix ; $cache_key = md5 ( $query ) ; $result = cacheGet ( $cache_key ) ; if ( $result !== false ) { echo "<b> :</b> $query <br>" ; return $result ; } else echo "<b> :</b> $query <br>" ; $resource = sqlQuery ( $query ) ; $result = array ( ) ; while ( $row = mysql_fetch_assoc ( $resource ) ) { $result [ ] = $row ; } cacheSet ( $cache_key , $result , 3600 ) ; return $result ; } ?> <h2>. </h2> <h3> 2 </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; // "select * from <<$mysql_table1>> where id=1", ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3> </h3> <? sqlSet ( "delete from << $mysql_table2 >> where 1=0" ) ; ?> <h3> </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3>: , . </h3>
<? header ( 'Content-type: text/html; charset=UTF-8' ) ; $mysql_host = 'localhost' ; $mysql_username = 'root' ; $mysql_password = '12345' ; $mysql_database = 'test' ; // , $mysql_table1 = 'table1' ; $mysql_table2 = 'table2' ; $memcache_host = 'localhost' ; $memcache_port = 11211 ; $mysql = mysql_connect ( $mysql_host , $mysql_username , $mysql_password ) ; if ( ! $mysql ) die ( " MySQL: $mysql_username @ $mysql_host / $mysql_password " ) ; if ( ! mysql_select_db ( $mysql_database ) ) die ( " : $mysql_database " ) ; $memcache = new Memcache ; if ( ! $memcache -> pconnect ( $memcache_host , $memcache_port ) ) die ( "Memcached : $memcache_host : $memcache_port " ) ; function cacheGet ( $key ) { global $memcache ; return $memcache -> get ( $key ) ; } function cacheSet ( $key , $data , $delay ) { global $memcache ; return $memcache -> set ( $key , $data , 0 , $delay ) ; } function sqlExtractTables ( & $query ) { preg_match_all ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , $query , $tables ) ; if ( ! $tables [ 1 ] ) die ( " , '<<table_name>>': $query " ) ; $query = preg_replace ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , "\ \1 " , $query ) ; return $tables [ 1 ] ; } function sqlQuery ( $query ) { $resource = mysql_query ( $query ) ; if ( ! $resource ) die ( " : $query <br> " . mysql_error ( ) ) ; echo "<b> :</b> $query <br>" ; return $resource ; } function sqlSet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) cacheSet ( $table , uniqid ( time ( ) , true ) , 24 * 3600 ) ; return sqlQuery ( $query ) ; } function sqlGet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) $appendix .= cacheGet ( $table ) ; $appendix = "/*" . md5 ( $appendix ) . "*/" ; $query = $query . $appendix ; $cache_key = md5 ( $query ) ; $result = cacheGet ( $cache_key ) ; if ( $result !== false ) { echo "<b> :</b> $query <br>" ; return $result ; } else echo "<b> :</b> $query <br>" ; $resource = sqlQuery ( $query ) ; $result = array ( ) ; while ( $row = mysql_fetch_assoc ( $resource ) ) { $result [ ] = $row ; } cacheSet ( $cache_key , $result , 3600 ) ; return $result ; } ?> <h2>. </h2> <h3> 2 </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; // "select * from <<$mysql_table1>> where id=1", ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3> </h3> <? sqlSet ( "delete from << $mysql_table2 >> where 1=0" ) ; ?> <h3> </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3>: , . </h3>
<? header ( 'Content-type: text/html; charset=UTF-8' ) ; $mysql_host = 'localhost' ; $mysql_username = 'root' ; $mysql_password = '12345' ; $mysql_database = 'test' ; // , $mysql_table1 = 'table1' ; $mysql_table2 = 'table2' ; $memcache_host = 'localhost' ; $memcache_port = 11211 ; $mysql = mysql_connect ( $mysql_host , $mysql_username , $mysql_password ) ; if ( ! $mysql ) die ( " MySQL: $mysql_username @ $mysql_host / $mysql_password " ) ; if ( ! mysql_select_db ( $mysql_database ) ) die ( " : $mysql_database " ) ; $memcache = new Memcache ; if ( ! $memcache -> pconnect ( $memcache_host , $memcache_port ) ) die ( "Memcached : $memcache_host : $memcache_port " ) ; function cacheGet ( $key ) { global $memcache ; return $memcache -> get ( $key ) ; } function cacheSet ( $key , $data , $delay ) { global $memcache ; return $memcache -> set ( $key , $data , 0 , $delay ) ; } function sqlExtractTables ( & $query ) { preg_match_all ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , $query , $tables ) ; if ( ! $tables [ 1 ] ) die ( " , '<<table_name>>': $query " ) ; $query = preg_replace ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , "\ \1 " , $query ) ; return $tables [ 1 ] ; } function sqlQuery ( $query ) { $resource = mysql_query ( $query ) ; if ( ! $resource ) die ( " : $query <br> " . mysql_error ( ) ) ; echo "<b> :</b> $query <br>" ; return $resource ; } function sqlSet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) cacheSet ( $table , uniqid ( time ( ) , true ) , 24 * 3600 ) ; return sqlQuery ( $query ) ; } function sqlGet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) $appendix .= cacheGet ( $table ) ; $appendix = "/*" . md5 ( $appendix ) . "*/" ; $query = $query . $appendix ; $cache_key = md5 ( $query ) ; $result = cacheGet ( $cache_key ) ; if ( $result !== false ) { echo "<b> :</b> $query <br>" ; return $result ; } else echo "<b> :</b> $query <br>" ; $resource = sqlQuery ( $query ) ; $result = array ( ) ; while ( $row = mysql_fetch_assoc ( $resource ) ) { $result [ ] = $row ; } cacheSet ( $cache_key , $result , 3600 ) ; return $result ; } ?> <h2>. </h2> <h3> 2 </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; // "select * from <<$mysql_table1>> where id=1", ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3> </h3> <? sqlSet ( "delete from << $mysql_table2 >> where 1=0" ) ; ?> <h3> </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3>: , . </h3>
<? header ( 'Content-type: text/html; charset=UTF-8' ) ; $mysql_host = 'localhost' ; $mysql_username = 'root' ; $mysql_password = '12345' ; $mysql_database = 'test' ; // , $mysql_table1 = 'table1' ; $mysql_table2 = 'table2' ; $memcache_host = 'localhost' ; $memcache_port = 11211 ; $mysql = mysql_connect ( $mysql_host , $mysql_username , $mysql_password ) ; if ( ! $mysql ) die ( " MySQL: $mysql_username @ $mysql_host / $mysql_password " ) ; if ( ! mysql_select_db ( $mysql_database ) ) die ( " : $mysql_database " ) ; $memcache = new Memcache ; if ( ! $memcache -> pconnect ( $memcache_host , $memcache_port ) ) die ( "Memcached : $memcache_host : $memcache_port " ) ; function cacheGet ( $key ) { global $memcache ; return $memcache -> get ( $key ) ; } function cacheSet ( $key , $data , $delay ) { global $memcache ; return $memcache -> set ( $key , $data , 0 , $delay ) ; } function sqlExtractTables ( & $query ) { preg_match_all ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , $query , $tables ) ; if ( ! $tables [ 1 ] ) die ( " , '<<table_name>>': $query " ) ; $query = preg_replace ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , "\ \1 " , $query ) ; return $tables [ 1 ] ; } function sqlQuery ( $query ) { $resource = mysql_query ( $query ) ; if ( ! $resource ) die ( " : $query <br> " . mysql_error ( ) ) ; echo "<b> :</b> $query <br>" ; return $resource ; } function sqlSet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) cacheSet ( $table , uniqid ( time ( ) , true ) , 24 * 3600 ) ; return sqlQuery ( $query ) ; } function sqlGet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) $appendix .= cacheGet ( $table ) ; $appendix = "/*" . md5 ( $appendix ) . "*/" ; $query = $query . $appendix ; $cache_key = md5 ( $query ) ; $result = cacheGet ( $cache_key ) ; if ( $result !== false ) { echo "<b> :</b> $query <br>" ; return $result ; } else echo "<b> :</b> $query <br>" ; $resource = sqlQuery ( $query ) ; $result = array ( ) ; while ( $row = mysql_fetch_assoc ( $resource ) ) { $result [ ] = $row ; } cacheSet ( $cache_key , $result , 3600 ) ; return $result ; } ?> <h2>. </h2> <h3> 2 </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; // "select * from <<$mysql_table1>> where id=1", ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3> </h3> <? sqlSet ( "delete from << $mysql_table2 >> where 1=0" ) ; ?> <h3> </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3>: , . </h3>
<? header ( 'Content-type: text/html; charset=UTF-8' ) ; $mysql_host = 'localhost' ; $mysql_username = 'root' ; $mysql_password = '12345' ; $mysql_database = 'test' ; // , $mysql_table1 = 'table1' ; $mysql_table2 = 'table2' ; $memcache_host = 'localhost' ; $memcache_port = 11211 ; $mysql = mysql_connect ( $mysql_host , $mysql_username , $mysql_password ) ; if ( ! $mysql ) die ( " MySQL: $mysql_username @ $mysql_host / $mysql_password " ) ; if ( ! mysql_select_db ( $mysql_database ) ) die ( " : $mysql_database " ) ; $memcache = new Memcache ; if ( ! $memcache -> pconnect ( $memcache_host , $memcache_port ) ) die ( "Memcached : $memcache_host : $memcache_port " ) ; function cacheGet ( $key ) { global $memcache ; return $memcache -> get ( $key ) ; } function cacheSet ( $key , $data , $delay ) { global $memcache ; return $memcache -> set ( $key , $data , 0 , $delay ) ; } function sqlExtractTables ( & $query ) { preg_match_all ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , $query , $tables ) ; if ( ! $tables [ 1 ] ) die ( " , '<<table_name>>': $query " ) ; $query = preg_replace ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , "\ \1 " , $query ) ; return $tables [ 1 ] ; } function sqlQuery ( $query ) { $resource = mysql_query ( $query ) ; if ( ! $resource ) die ( " : $query <br> " . mysql_error ( ) ) ; echo "<b> :</b> $query <br>" ; return $resource ; } function sqlSet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) cacheSet ( $table , uniqid ( time ( ) , true ) , 24 * 3600 ) ; return sqlQuery ( $query ) ; } function sqlGet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) $appendix .= cacheGet ( $table ) ; $appendix = "/*" . md5 ( $appendix ) . "*/" ; $query = $query . $appendix ; $cache_key = md5 ( $query ) ; $result = cacheGet ( $cache_key ) ; if ( $result !== false ) { echo "<b> :</b> $query <br>" ; return $result ; } else echo "<b> :</b> $query <br>" ; $resource = sqlQuery ( $query ) ; $result = array ( ) ; while ( $row = mysql_fetch_assoc ( $resource ) ) { $result [ ] = $row ; } cacheSet ( $cache_key , $result , 3600 ) ; return $result ; } ?> <h2>. </h2> <h3> 2 </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; // "select * from <<$mysql_table1>> where id=1", ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3> </h3> <? sqlSet ( "delete from << $mysql_table2 >> where 1=0" ) ; ?> <h3> </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3>: , . </h3>
<? header ( 'Content-type: text/html; charset=UTF-8' ) ; $mysql_host = 'localhost' ; $mysql_username = 'root' ; $mysql_password = '12345' ; $mysql_database = 'test' ; // , $mysql_table1 = 'table1' ; $mysql_table2 = 'table2' ; $memcache_host = 'localhost' ; $memcache_port = 11211 ; $mysql = mysql_connect ( $mysql_host , $mysql_username , $mysql_password ) ; if ( ! $mysql ) die ( " MySQL: $mysql_username @ $mysql_host / $mysql_password " ) ; if ( ! mysql_select_db ( $mysql_database ) ) die ( " : $mysql_database " ) ; $memcache = new Memcache ; if ( ! $memcache -> pconnect ( $memcache_host , $memcache_port ) ) die ( "Memcached : $memcache_host : $memcache_port " ) ; function cacheGet ( $key ) { global $memcache ; return $memcache -> get ( $key ) ; } function cacheSet ( $key , $data , $delay ) { global $memcache ; return $memcache -> set ( $key , $data , 0 , $delay ) ; } function sqlExtractTables ( & $query ) { preg_match_all ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , $query , $tables ) ; if ( ! $tables [ 1 ] ) die ( " , '<<table_name>>': $query " ) ; $query = preg_replace ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , "\ \1 " , $query ) ; return $tables [ 1 ] ; } function sqlQuery ( $query ) { $resource = mysql_query ( $query ) ; if ( ! $resource ) die ( " : $query <br> " . mysql_error ( ) ) ; echo "<b> :</b> $query <br>" ; return $resource ; } function sqlSet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) cacheSet ( $table , uniqid ( time ( ) , true ) , 24 * 3600 ) ; return sqlQuery ( $query ) ; } function sqlGet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) $appendix .= cacheGet ( $table ) ; $appendix = "/*" . md5 ( $appendix ) . "*/" ; $query = $query . $appendix ; $cache_key = md5 ( $query ) ; $result = cacheGet ( $cache_key ) ; if ( $result !== false ) { echo "<b> :</b> $query <br>" ; return $result ; } else echo "<b> :</b> $query <br>" ; $resource = sqlQuery ( $query ) ; $result = array ( ) ; while ( $row = mysql_fetch_assoc ( $resource ) ) { $result [ ] = $row ; } cacheSet ( $cache_key , $result , 3600 ) ; return $result ; } ?> <h2>. </h2> <h3> 2 </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; // "select * from <<$mysql_table1>> where id=1", ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3> </h3> <? sqlSet ( "delete from << $mysql_table2 >> where 1=0" ) ; ?> <h3> </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3>: , . </h3>
<? header ( 'Content-type: text/html; charset=UTF-8' ) ; $mysql_host = 'localhost' ; $mysql_username = 'root' ; $mysql_password = '12345' ; $mysql_database = 'test' ; // , $mysql_table1 = 'table1' ; $mysql_table2 = 'table2' ; $memcache_host = 'localhost' ; $memcache_port = 11211 ; $mysql = mysql_connect ( $mysql_host , $mysql_username , $mysql_password ) ; if ( ! $mysql ) die ( " MySQL: $mysql_username @ $mysql_host / $mysql_password " ) ; if ( ! mysql_select_db ( $mysql_database ) ) die ( " : $mysql_database " ) ; $memcache = new Memcache ; if ( ! $memcache -> pconnect ( $memcache_host , $memcache_port ) ) die ( "Memcached : $memcache_host : $memcache_port " ) ; function cacheGet ( $key ) { global $memcache ; return $memcache -> get ( $key ) ; } function cacheSet ( $key , $data , $delay ) { global $memcache ; return $memcache -> set ( $key , $data , 0 , $delay ) ; } function sqlExtractTables ( & $query ) { preg_match_all ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , $query , $tables ) ; if ( ! $tables [ 1 ] ) die ( " , '<<table_name>>': $query " ) ; $query = preg_replace ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , "\ \1 " , $query ) ; return $tables [ 1 ] ; } function sqlQuery ( $query ) { $resource = mysql_query ( $query ) ; if ( ! $resource ) die ( " : $query <br> " . mysql_error ( ) ) ; echo "<b> :</b> $query <br>" ; return $resource ; } function sqlSet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) cacheSet ( $table , uniqid ( time ( ) , true ) , 24 * 3600 ) ; return sqlQuery ( $query ) ; } function sqlGet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) $appendix .= cacheGet ( $table ) ; $appendix = "/*" . md5 ( $appendix ) . "*/" ; $query = $query . $appendix ; $cache_key = md5 ( $query ) ; $result = cacheGet ( $cache_key ) ; if ( $result !== false ) { echo "<b> :</b> $query <br>" ; return $result ; } else echo "<b> :</b> $query <br>" ; $resource = sqlQuery ( $query ) ; $result = array ( ) ; while ( $row = mysql_fetch_assoc ( $resource ) ) { $result [ ] = $row ; } cacheSet ( $cache_key , $result , 3600 ) ; return $result ; } ?> <h2>. </h2> <h3> 2 </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; // "select * from <<$mysql_table1>> where id=1", ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3> </h3> <? sqlSet ( "delete from << $mysql_table2 >> where 1=0" ) ; ?> <h3> </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3>: , . </h3>
<? header ( 'Content-type: text/html; charset=UTF-8' ) ; $mysql_host = 'localhost' ; $mysql_username = 'root' ; $mysql_password = '12345' ; $mysql_database = 'test' ; // , $mysql_table1 = 'table1' ; $mysql_table2 = 'table2' ; $memcache_host = 'localhost' ; $memcache_port = 11211 ; $mysql = mysql_connect ( $mysql_host , $mysql_username , $mysql_password ) ; if ( ! $mysql ) die ( " MySQL: $mysql_username @ $mysql_host / $mysql_password " ) ; if ( ! mysql_select_db ( $mysql_database ) ) die ( " : $mysql_database " ) ; $memcache = new Memcache ; if ( ! $memcache -> pconnect ( $memcache_host , $memcache_port ) ) die ( "Memcached : $memcache_host : $memcache_port " ) ; function cacheGet ( $key ) { global $memcache ; return $memcache -> get ( $key ) ; } function cacheSet ( $key , $data , $delay ) { global $memcache ; return $memcache -> set ( $key , $data , 0 , $delay ) ; } function sqlExtractTables ( & $query ) { preg_match_all ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , $query , $tables ) ; if ( ! $tables [ 1 ] ) die ( " , '<<table_name>>': $query " ) ; $query = preg_replace ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , "\ \1 " , $query ) ; return $tables [ 1 ] ; } function sqlQuery ( $query ) { $resource = mysql_query ( $query ) ; if ( ! $resource ) die ( " : $query <br> " . mysql_error ( ) ) ; echo "<b> :</b> $query <br>" ; return $resource ; } function sqlSet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) cacheSet ( $table , uniqid ( time ( ) , true ) , 24 * 3600 ) ; return sqlQuery ( $query ) ; } function sqlGet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) $appendix .= cacheGet ( $table ) ; $appendix = "/*" . md5 ( $appendix ) . "*/" ; $query = $query . $appendix ; $cache_key = md5 ( $query ) ; $result = cacheGet ( $cache_key ) ; if ( $result !== false ) { echo "<b> :</b> $query <br>" ; return $result ; } else echo "<b> :</b> $query <br>" ; $resource = sqlQuery ( $query ) ; $result = array ( ) ; while ( $row = mysql_fetch_assoc ( $resource ) ) { $result [ ] = $row ; } cacheSet ( $cache_key , $result , 3600 ) ; return $result ; } ?> <h2>. </h2> <h3> 2 </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; // "select * from <<$mysql_table1>> where id=1", ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3> </h3> <? sqlSet ( "delete from << $mysql_table2 >> where 1=0" ) ; ?> <h3> </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3>: , . </h3>
<? header ( 'Content-type: text/html; charset=UTF-8' ) ; $mysql_host = 'localhost' ; $mysql_username = 'root' ; $mysql_password = '12345' ; $mysql_database = 'test' ; // , $mysql_table1 = 'table1' ; $mysql_table2 = 'table2' ; $memcache_host = 'localhost' ; $memcache_port = 11211 ; $mysql = mysql_connect ( $mysql_host , $mysql_username , $mysql_password ) ; if ( ! $mysql ) die ( " MySQL: $mysql_username @ $mysql_host / $mysql_password " ) ; if ( ! mysql_select_db ( $mysql_database ) ) die ( " : $mysql_database " ) ; $memcache = new Memcache ; if ( ! $memcache -> pconnect ( $memcache_host , $memcache_port ) ) die ( "Memcached : $memcache_host : $memcache_port " ) ; function cacheGet ( $key ) { global $memcache ; return $memcache -> get ( $key ) ; } function cacheSet ( $key , $data , $delay ) { global $memcache ; return $memcache -> set ( $key , $data , 0 , $delay ) ; } function sqlExtractTables ( & $query ) { preg_match_all ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , $query , $tables ) ; if ( ! $tables [ 1 ] ) die ( " , '<<table_name>>': $query " ) ; $query = preg_replace ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , "\ \1 " , $query ) ; return $tables [ 1 ] ; } function sqlQuery ( $query ) { $resource = mysql_query ( $query ) ; if ( ! $resource ) die ( " : $query <br> " . mysql_error ( ) ) ; echo "<b> :</b> $query <br>" ; return $resource ; } function sqlSet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) cacheSet ( $table , uniqid ( time ( ) , true ) , 24 * 3600 ) ; return sqlQuery ( $query ) ; } function sqlGet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) $appendix .= cacheGet ( $table ) ; $appendix = "/*" . md5 ( $appendix ) . "*/" ; $query = $query . $appendix ; $cache_key = md5 ( $query ) ; $result = cacheGet ( $cache_key ) ; if ( $result !== false ) { echo "<b> :</b> $query <br>" ; return $result ; } else echo "<b> :</b> $query <br>" ; $resource = sqlQuery ( $query ) ; $result = array ( ) ; while ( $row = mysql_fetch_assoc ( $resource ) ) { $result [ ] = $row ; } cacheSet ( $cache_key , $result , 3600 ) ; return $result ; } ?> <h2>. </h2> <h3> 2 </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; // "select * from <<$mysql_table1>> where id=1", ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3> </h3> <? sqlSet ( "delete from << $mysql_table2 >> where 1=0" ) ; ?> <h3> </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3>: , . </h3>
<? header ( 'Content-type: text/html; charset=UTF-8' ) ; $mysql_host = 'localhost' ; $mysql_username = 'root' ; $mysql_password = '12345' ; $mysql_database = 'test' ; // , $mysql_table1 = 'table1' ; $mysql_table2 = 'table2' ; $memcache_host = 'localhost' ; $memcache_port = 11211 ; $mysql = mysql_connect ( $mysql_host , $mysql_username , $mysql_password ) ; if ( ! $mysql ) die ( " MySQL: $mysql_username @ $mysql_host / $mysql_password " ) ; if ( ! mysql_select_db ( $mysql_database ) ) die ( " : $mysql_database " ) ; $memcache = new Memcache ; if ( ! $memcache -> pconnect ( $memcache_host , $memcache_port ) ) die ( "Memcached : $memcache_host : $memcache_port " ) ; function cacheGet ( $key ) { global $memcache ; return $memcache -> get ( $key ) ; } function cacheSet ( $key , $data , $delay ) { global $memcache ; return $memcache -> set ( $key , $data , 0 , $delay ) ; } function sqlExtractTables ( & $query ) { preg_match_all ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , $query , $tables ) ; if ( ! $tables [ 1 ] ) die ( " , '<<table_name>>': $query " ) ; $query = preg_replace ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , "\ \1 " , $query ) ; return $tables [ 1 ] ; } function sqlQuery ( $query ) { $resource = mysql_query ( $query ) ; if ( ! $resource ) die ( " : $query <br> " . mysql_error ( ) ) ; echo "<b> :</b> $query <br>" ; return $resource ; } function sqlSet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) cacheSet ( $table , uniqid ( time ( ) , true ) , 24 * 3600 ) ; return sqlQuery ( $query ) ; } function sqlGet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) $appendix .= cacheGet ( $table ) ; $appendix = "/*" . md5 ( $appendix ) . "*/" ; $query = $query . $appendix ; $cache_key = md5 ( $query ) ; $result = cacheGet ( $cache_key ) ; if ( $result !== false ) { echo "<b> :</b> $query <br>" ; return $result ; } else echo "<b> :</b> $query <br>" ; $resource = sqlQuery ( $query ) ; $result = array ( ) ; while ( $row = mysql_fetch_assoc ( $resource ) ) { $result [ ] = $row ; } cacheSet ( $cache_key , $result , 3600 ) ; return $result ; } ?> <h2>. </h2> <h3> 2 </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; // "select * from <<$mysql_table1>> where id=1", ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3> </h3> <? sqlSet ( "delete from << $mysql_table2 >> where 1=0" ) ; ?> <h3> </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3>: , . </h3>
<? header ( 'Content-type: text/html; charset=UTF-8' ) ; $mysql_host = 'localhost' ; $mysql_username = 'root' ; $mysql_password = '12345' ; $mysql_database = 'test' ; // , $mysql_table1 = 'table1' ; $mysql_table2 = 'table2' ; $memcache_host = 'localhost' ; $memcache_port = 11211 ; $mysql = mysql_connect ( $mysql_host , $mysql_username , $mysql_password ) ; if ( ! $mysql ) die ( " MySQL: $mysql_username @ $mysql_host / $mysql_password " ) ; if ( ! mysql_select_db ( $mysql_database ) ) die ( " : $mysql_database " ) ; $memcache = new Memcache ; if ( ! $memcache -> pconnect ( $memcache_host , $memcache_port ) ) die ( "Memcached : $memcache_host : $memcache_port " ) ; function cacheGet ( $key ) { global $memcache ; return $memcache -> get ( $key ) ; } function cacheSet ( $key , $data , $delay ) { global $memcache ; return $memcache -> set ( $key , $data , 0 , $delay ) ; } function sqlExtractTables ( & $query ) { preg_match_all ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , $query , $tables ) ; if ( ! $tables [ 1 ] ) die ( " , '<<table_name>>': $query " ) ; $query = preg_replace ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , "\ \1 " , $query ) ; return $tables [ 1 ] ; } function sqlQuery ( $query ) { $resource = mysql_query ( $query ) ; if ( ! $resource ) die ( " : $query <br> " . mysql_error ( ) ) ; echo "<b> :</b> $query <br>" ; return $resource ; } function sqlSet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) cacheSet ( $table , uniqid ( time ( ) , true ) , 24 * 3600 ) ; return sqlQuery ( $query ) ; } function sqlGet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) $appendix .= cacheGet ( $table ) ; $appendix = "/*" . md5 ( $appendix ) . "*/" ; $query = $query . $appendix ; $cache_key = md5 ( $query ) ; $result = cacheGet ( $cache_key ) ; if ( $result !== false ) { echo "<b> :</b> $query <br>" ; return $result ; } else echo "<b> :</b> $query <br>" ; $resource = sqlQuery ( $query ) ; $result = array ( ) ; while ( $row = mysql_fetch_assoc ( $resource ) ) { $result [ ] = $row ; } cacheSet ( $cache_key , $result , 3600 ) ; return $result ; } ?> <h2>. </h2> <h3> 2 </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; // "select * from <<$mysql_table1>> where id=1", ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3> </h3> <? sqlSet ( "delete from << $mysql_table2 >> where 1=0" ) ; ?> <h3> </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3>: , . </h3>
<? header ( 'Content-type: text/html; charset=UTF-8' ) ; $mysql_host = 'localhost' ; $mysql_username = 'root' ; $mysql_password = '12345' ; $mysql_database = 'test' ; // , $mysql_table1 = 'table1' ; $mysql_table2 = 'table2' ; $memcache_host = 'localhost' ; $memcache_port = 11211 ; $mysql = mysql_connect ( $mysql_host , $mysql_username , $mysql_password ) ; if ( ! $mysql ) die ( " MySQL: $mysql_username @ $mysql_host / $mysql_password " ) ; if ( ! mysql_select_db ( $mysql_database ) ) die ( " : $mysql_database " ) ; $memcache = new Memcache ; if ( ! $memcache -> pconnect ( $memcache_host , $memcache_port ) ) die ( "Memcached : $memcache_host : $memcache_port " ) ; function cacheGet ( $key ) { global $memcache ; return $memcache -> get ( $key ) ; } function cacheSet ( $key , $data , $delay ) { global $memcache ; return $memcache -> set ( $key , $data , 0 , $delay ) ; } function sqlExtractTables ( & $query ) { preg_match_all ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , $query , $tables ) ; if ( ! $tables [ 1 ] ) die ( " , '<<table_name>>': $query " ) ; $query = preg_replace ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , "\ \1 " , $query ) ; return $tables [ 1 ] ; } function sqlQuery ( $query ) { $resource = mysql_query ( $query ) ; if ( ! $resource ) die ( " : $query <br> " . mysql_error ( ) ) ; echo "<b> :</b> $query <br>" ; return $resource ; } function sqlSet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) cacheSet ( $table , uniqid ( time ( ) , true ) , 24 * 3600 ) ; return sqlQuery ( $query ) ; } function sqlGet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) $appendix .= cacheGet ( $table ) ; $appendix = "/*" . md5 ( $appendix ) . "*/" ; $query = $query . $appendix ; $cache_key = md5 ( $query ) ; $result = cacheGet ( $cache_key ) ; if ( $result !== false ) { echo "<b> :</b> $query <br>" ; return $result ; } else echo "<b> :</b> $query <br>" ; $resource = sqlQuery ( $query ) ; $result = array ( ) ; while ( $row = mysql_fetch_assoc ( $resource ) ) { $result [ ] = $row ; } cacheSet ( $cache_key , $result , 3600 ) ; return $result ; } ?> <h2>. </h2> <h3> 2 </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; // "select * from <<$mysql_table1>> where id=1", ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3> </h3> <? sqlSet ( "delete from << $mysql_table2 >> where 1=0" ) ; ?> <h3> </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3>: , . </h3>
<? header ( 'Content-type: text/html; charset=UTF-8' ) ; $mysql_host = 'localhost' ; $mysql_username = 'root' ; $mysql_password = '12345' ; $mysql_database = 'test' ; // , $mysql_table1 = 'table1' ; $mysql_table2 = 'table2' ; $memcache_host = 'localhost' ; $memcache_port = 11211 ; $mysql = mysql_connect ( $mysql_host , $mysql_username , $mysql_password ) ; if ( ! $mysql ) die ( " MySQL: $mysql_username @ $mysql_host / $mysql_password " ) ; if ( ! mysql_select_db ( $mysql_database ) ) die ( " : $mysql_database " ) ; $memcache = new Memcache ; if ( ! $memcache -> pconnect ( $memcache_host , $memcache_port ) ) die ( "Memcached : $memcache_host : $memcache_port " ) ; function cacheGet ( $key ) { global $memcache ; return $memcache -> get ( $key ) ; } function cacheSet ( $key , $data , $delay ) { global $memcache ; return $memcache -> set ( $key , $data , 0 , $delay ) ; } function sqlExtractTables ( & $query ) { preg_match_all ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , $query , $tables ) ; if ( ! $tables [ 1 ] ) die ( " , '<<table_name>>': $query " ) ; $query = preg_replace ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , "\ \1 " , $query ) ; return $tables [ 1 ] ; } function sqlQuery ( $query ) { $resource = mysql_query ( $query ) ; if ( ! $resource ) die ( " : $query <br> " . mysql_error ( ) ) ; echo "<b> :</b> $query <br>" ; return $resource ; } function sqlSet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) cacheSet ( $table , uniqid ( time ( ) , true ) , 24 * 3600 ) ; return sqlQuery ( $query ) ; } function sqlGet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) $appendix .= cacheGet ( $table ) ; $appendix = "/*" . md5 ( $appendix ) . "*/" ; $query = $query . $appendix ; $cache_key = md5 ( $query ) ; $result = cacheGet ( $cache_key ) ; if ( $result !== false ) { echo "<b> :</b> $query <br>" ; return $result ; } else echo "<b> :</b> $query <br>" ; $resource = sqlQuery ( $query ) ; $result = array ( ) ; while ( $row = mysql_fetch_assoc ( $resource ) ) { $result [ ] = $row ; } cacheSet ( $cache_key , $result , 3600 ) ; return $result ; } ?> <h2>. </h2> <h3> 2 </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; // "select * from <<$mysql_table1>> where id=1", ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3> </h3> <? sqlSet ( "delete from << $mysql_table2 >> where 1=0" ) ; ?> <h3> </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3>: , . </h3>
<? header ( 'Content-type: text/html; charset=UTF-8' ) ; $mysql_host = 'localhost' ; $mysql_username = 'root' ; $mysql_password = '12345' ; $mysql_database = 'test' ; // , $mysql_table1 = 'table1' ; $mysql_table2 = 'table2' ; $memcache_host = 'localhost' ; $memcache_port = 11211 ; $mysql = mysql_connect ( $mysql_host , $mysql_username , $mysql_password ) ; if ( ! $mysql ) die ( " MySQL: $mysql_username @ $mysql_host / $mysql_password " ) ; if ( ! mysql_select_db ( $mysql_database ) ) die ( " : $mysql_database " ) ; $memcache = new Memcache ; if ( ! $memcache -> pconnect ( $memcache_host , $memcache_port ) ) die ( "Memcached : $memcache_host : $memcache_port " ) ; function cacheGet ( $key ) { global $memcache ; return $memcache -> get ( $key ) ; } function cacheSet ( $key , $data , $delay ) { global $memcache ; return $memcache -> set ( $key , $data , 0 , $delay ) ; } function sqlExtractTables ( & $query ) { preg_match_all ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , $query , $tables ) ; if ( ! $tables [ 1 ] ) die ( " , '<<table_name>>': $query " ) ; $query = preg_replace ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , "\ \1 " , $query ) ; return $tables [ 1 ] ; } function sqlQuery ( $query ) { $resource = mysql_query ( $query ) ; if ( ! $resource ) die ( " : $query <br> " . mysql_error ( ) ) ; echo "<b> :</b> $query <br>" ; return $resource ; } function sqlSet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) cacheSet ( $table , uniqid ( time ( ) , true ) , 24 * 3600 ) ; return sqlQuery ( $query ) ; } function sqlGet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) $appendix .= cacheGet ( $table ) ; $appendix = "/*" . md5 ( $appendix ) . "*/" ; $query = $query . $appendix ; $cache_key = md5 ( $query ) ; $result = cacheGet ( $cache_key ) ; if ( $result !== false ) { echo "<b> :</b> $query <br>" ; return $result ; } else echo "<b> :</b> $query <br>" ; $resource = sqlQuery ( $query ) ; $result = array ( ) ; while ( $row = mysql_fetch_assoc ( $resource ) ) { $result [ ] = $row ; } cacheSet ( $cache_key , $result , 3600 ) ; return $result ; } ?> <h2>. </h2> <h3> 2 </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; // "select * from <<$mysql_table1>> where id=1", ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3> </h3> <? sqlSet ( "delete from << $mysql_table2 >> where 1=0" ) ; ?> <h3> </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3>: , . </h3>
<? header ( 'Content-type: text/html; charset=UTF-8' ) ; $mysql_host = 'localhost' ; $mysql_username = 'root' ; $mysql_password = '12345' ; $mysql_database = 'test' ; // , $mysql_table1 = 'table1' ; $mysql_table2 = 'table2' ; $memcache_host = 'localhost' ; $memcache_port = 11211 ; $mysql = mysql_connect ( $mysql_host , $mysql_username , $mysql_password ) ; if ( ! $mysql ) die ( " MySQL: $mysql_username @ $mysql_host / $mysql_password " ) ; if ( ! mysql_select_db ( $mysql_database ) ) die ( " : $mysql_database " ) ; $memcache = new Memcache ; if ( ! $memcache -> pconnect ( $memcache_host , $memcache_port ) ) die ( "Memcached : $memcache_host : $memcache_port " ) ; function cacheGet ( $key ) { global $memcache ; return $memcache -> get ( $key ) ; } function cacheSet ( $key , $data , $delay ) { global $memcache ; return $memcache -> set ( $key , $data , 0 , $delay ) ; } function sqlExtractTables ( & $query ) { preg_match_all ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , $query , $tables ) ; if ( ! $tables [ 1 ] ) die ( " , '<<table_name>>': $query " ) ; $query = preg_replace ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , "\ \1 " , $query ) ; return $tables [ 1 ] ; } function sqlQuery ( $query ) { $resource = mysql_query ( $query ) ; if ( ! $resource ) die ( " : $query <br> " . mysql_error ( ) ) ; echo "<b> :</b> $query <br>" ; return $resource ; } function sqlSet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) cacheSet ( $table , uniqid ( time ( ) , true ) , 24 * 3600 ) ; return sqlQuery ( $query ) ; } function sqlGet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) $appendix .= cacheGet ( $table ) ; $appendix = "/*" . md5 ( $appendix ) . "*/" ; $query = $query . $appendix ; $cache_key = md5 ( $query ) ; $result = cacheGet ( $cache_key ) ; if ( $result !== false ) { echo "<b> :</b> $query <br>" ; return $result ; } else echo "<b> :</b> $query <br>" ; $resource = sqlQuery ( $query ) ; $result = array ( ) ; while ( $row = mysql_fetch_assoc ( $resource ) ) { $result [ ] = $row ; } cacheSet ( $cache_key , $result , 3600 ) ; return $result ; } ?> <h2>. </h2> <h3> 2 </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; // "select * from <<$mysql_table1>> where id=1", ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3> </h3> <? sqlSet ( "delete from << $mysql_table2 >> where 1=0" ) ; ?> <h3> </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3>: , . </h3>
<? header ( 'Content-type: text/html; charset=UTF-8' ) ; $mysql_host = 'localhost' ; $mysql_username = 'root' ; $mysql_password = '12345' ; $mysql_database = 'test' ; // , $mysql_table1 = 'table1' ; $mysql_table2 = 'table2' ; $memcache_host = 'localhost' ; $memcache_port = 11211 ; $mysql = mysql_connect ( $mysql_host , $mysql_username , $mysql_password ) ; if ( ! $mysql ) die ( " MySQL: $mysql_username @ $mysql_host / $mysql_password " ) ; if ( ! mysql_select_db ( $mysql_database ) ) die ( " : $mysql_database " ) ; $memcache = new Memcache ; if ( ! $memcache -> pconnect ( $memcache_host , $memcache_port ) ) die ( "Memcached : $memcache_host : $memcache_port " ) ; function cacheGet ( $key ) { global $memcache ; return $memcache -> get ( $key ) ; } function cacheSet ( $key , $data , $delay ) { global $memcache ; return $memcache -> set ( $key , $data , 0 , $delay ) ; } function sqlExtractTables ( & $query ) { preg_match_all ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , $query , $tables ) ; if ( ! $tables [ 1 ] ) die ( " , '<<table_name>>': $query " ) ; $query = preg_replace ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , "\ \1 " , $query ) ; return $tables [ 1 ] ; } function sqlQuery ( $query ) { $resource = mysql_query ( $query ) ; if ( ! $resource ) die ( " : $query <br> " . mysql_error ( ) ) ; echo "<b> :</b> $query <br>" ; return $resource ; } function sqlSet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) cacheSet ( $table , uniqid ( time ( ) , true ) , 24 * 3600 ) ; return sqlQuery ( $query ) ; } function sqlGet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) $appendix .= cacheGet ( $table ) ; $appendix = "/*" . md5 ( $appendix ) . "*/" ; $query = $query . $appendix ; $cache_key = md5 ( $query ) ; $result = cacheGet ( $cache_key ) ; if ( $result !== false ) { echo "<b> :</b> $query <br>" ; return $result ; } else echo "<b> :</b> $query <br>" ; $resource = sqlQuery ( $query ) ; $result = array ( ) ; while ( $row = mysql_fetch_assoc ( $resource ) ) { $result [ ] = $row ; } cacheSet ( $cache_key , $result , 3600 ) ; return $result ; } ?> <h2>. </h2> <h3> 2 </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; // "select * from <<$mysql_table1>> where id=1", ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3> </h3> <? sqlSet ( "delete from << $mysql_table2 >> where 1=0" ) ; ?> <h3> </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3>: , . </h3>
<? header ( 'Content-type: text/html; charset=UTF-8' ) ; $mysql_host = 'localhost' ; $mysql_username = 'root' ; $mysql_password = '12345' ; $mysql_database = 'test' ; // , $mysql_table1 = 'table1' ; $mysql_table2 = 'table2' ; $memcache_host = 'localhost' ; $memcache_port = 11211 ; $mysql = mysql_connect ( $mysql_host , $mysql_username , $mysql_password ) ; if ( ! $mysql ) die ( " MySQL: $mysql_username @ $mysql_host / $mysql_password " ) ; if ( ! mysql_select_db ( $mysql_database ) ) die ( " : $mysql_database " ) ; $memcache = new Memcache ; if ( ! $memcache -> pconnect ( $memcache_host , $memcache_port ) ) die ( "Memcached : $memcache_host : $memcache_port " ) ; function cacheGet ( $key ) { global $memcache ; return $memcache -> get ( $key ) ; } function cacheSet ( $key , $data , $delay ) { global $memcache ; return $memcache -> set ( $key , $data , 0 , $delay ) ; } function sqlExtractTables ( & $query ) { preg_match_all ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , $query , $tables ) ; if ( ! $tables [ 1 ] ) die ( " , '<<table_name>>': $query " ) ; $query = preg_replace ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , "\ \1 " , $query ) ; return $tables [ 1 ] ; } function sqlQuery ( $query ) { $resource = mysql_query ( $query ) ; if ( ! $resource ) die ( " : $query <br> " . mysql_error ( ) ) ; echo "<b> :</b> $query <br>" ; return $resource ; } function sqlSet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) cacheSet ( $table , uniqid ( time ( ) , true ) , 24 * 3600 ) ; return sqlQuery ( $query ) ; } function sqlGet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) $appendix .= cacheGet ( $table ) ; $appendix = "/*" . md5 ( $appendix ) . "*/" ; $query = $query . $appendix ; $cache_key = md5 ( $query ) ; $result = cacheGet ( $cache_key ) ; if ( $result !== false ) { echo "<b> :</b> $query <br>" ; return $result ; } else echo "<b> :</b> $query <br>" ; $resource = sqlQuery ( $query ) ; $result = array ( ) ; while ( $row = mysql_fetch_assoc ( $resource ) ) { $result [ ] = $row ; } cacheSet ( $cache_key , $result , 3600 ) ; return $result ; } ?> <h2>. </h2> <h3> 2 </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; // "select * from <<$mysql_table1>> where id=1", ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3> </h3> <? sqlSet ( "delete from << $mysql_table2 >> where 1=0" ) ; ?> <h3> </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3>: , . </h3>
<? header ( 'Content-type: text/html; charset=UTF-8' ) ; $mysql_host = 'localhost' ; $mysql_username = 'root' ; $mysql_password = '12345' ; $mysql_database = 'test' ; // , $mysql_table1 = 'table1' ; $mysql_table2 = 'table2' ; $memcache_host = 'localhost' ; $memcache_port = 11211 ; $mysql = mysql_connect ( $mysql_host , $mysql_username , $mysql_password ) ; if ( ! $mysql ) die ( " MySQL: $mysql_username @ $mysql_host / $mysql_password " ) ; if ( ! mysql_select_db ( $mysql_database ) ) die ( " : $mysql_database " ) ; $memcache = new Memcache ; if ( ! $memcache -> pconnect ( $memcache_host , $memcache_port ) ) die ( "Memcached : $memcache_host : $memcache_port " ) ; function cacheGet ( $key ) { global $memcache ; return $memcache -> get ( $key ) ; } function cacheSet ( $key , $data , $delay ) { global $memcache ; return $memcache -> set ( $key , $data , 0 , $delay ) ; } function sqlExtractTables ( & $query ) { preg_match_all ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , $query , $tables ) ; if ( ! $tables [ 1 ] ) die ( " , '<<table_name>>': $query " ) ; $query = preg_replace ( "/\\<\\<([A-Za-z0-9\\_]+)\\>\\>/" , "\ \1 " , $query ) ; return $tables [ 1 ] ; } function sqlQuery ( $query ) { $resource = mysql_query ( $query ) ; if ( ! $resource ) die ( " : $query <br> " . mysql_error ( ) ) ; echo "<b> :</b> $query <br>" ; return $resource ; } function sqlSet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) cacheSet ( $table , uniqid ( time ( ) , true ) , 24 * 3600 ) ; return sqlQuery ( $query ) ; } function sqlGet ( $query ) { $tables = sqlExtractTables ( $query ) ; foreach ( $tables as $table ) $appendix .= cacheGet ( $table ) ; $appendix = "/*" . md5 ( $appendix ) . "*/" ; $query = $query . $appendix ; $cache_key = md5 ( $query ) ; $result = cacheGet ( $cache_key ) ; if ( $result !== false ) { echo "<b> :</b> $query <br>" ; return $result ; } else echo "<b> :</b> $query <br>" ; $resource = sqlQuery ( $query ) ; $result = array ( ) ; while ( $row = mysql_fetch_assoc ( $resource ) ) { $result [ ] = $row ; } cacheSet ( $cache_key , $result , 3600 ) ; return $result ; } ?> <h2>. </h2> <h3> 2 </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; // "select * from <<$mysql_table1>> where id=1", ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3> </h3> <? sqlSet ( "delete from << $mysql_table2 >> where 1=0" ) ; ?> <h3> </h3> <? sqlGet ( "select * from << $mysql_table1 >> limit 1" ) ; ?> <br> <? sqlGet ( "select * from << $mysql_table2 >> limit 1" ) ; ?> <h3>: , . </h3>
Source: https://habr.com/ru/post/61736/
All Articles