それで、優しさの涙は過ぎ去りました。 以下は、Habrへの招待につながったトピックです。
Memcachedはデータのキャッシュに使用されます。 これは、データベースへの不必要な呼び出しを避けるために行われます。 Memcachedはクエリ結果を保存します。 これにより、サイトが高速化され、ページのレンダリングにかかる時間が短縮されます。
キャッシュには利点に加えて利点があります。 キャッシュの問題の1つは、その関連性です。 「読み取り専用」操作モードでは、問題はありません。 変更または頻繁に変更されるデータを処理している場合、キャッシュの効率は大幅に低下します。 データが頻繁に変更されるほど、キャッシュの効率は低下します。 通常、キャッシュは最初の変更後にフラッシュされます。 さらに、キャッシュされたすべてのデータはすぐにリセットされます。 リセット後、クエリはデータベースに送られ、キャッシュは新しい方法で補充されます。 別の変更がある場合、キャッシュは再度リセットされます。 memcachedのような良いことはサーバーのパフォーマンスに何の利点ももたらさず、メモリとプロセッサ時間の追加コストも伴うことがしばしばわかります。
この問題を解決する方法の1つは、キャッシュを独立した部分に論理的に分割することです。 キャッシュフラッシュが発生した場合は、変更された部分に対してのみ。
Memcachedバンドルでそのようなアプローチの1つ、データベースを考えてみましょう。
リクエストを論理的に分離すると、どのように何を共有し、どのくらいの頻度で更新するかという問題が生じます。 ここでは、リクエストの目的が異なり、どのリクエストをどのイベントで更新するかが明確ではないため、各リクエストにヒントを与える必要があります。 実装には多大な労力が必要です。私にとって、怠け者のプログラマとしては、これは面白くありません。
すべてのデータベースアクセステーブルを分離しましょう。
いくつかのテーブルにアクセスできるクエリがあるとします。 クエリを実行し、含まれるテーブルを分析し、テーブル内のデータが変更されたかどうかを確認します。 データが変更された場合、リクエストのキャッシュも更新されます。 それは少し複雑に聞こえます、質問が発生します-それをすべて行う方法ですが、最終的に実装は非常に簡単です。
概要に進みます。
*各テーブルには、テーブル内のデータが変更されるたびに変わるカウンターがあります。
*行を削除および挿入するとき、レコードが変更されるとき、これらのカウンターを増やします。
*クエリを実行する前に、影響を受けるテーブルのリストが取得されます。 これらの表から、カウンターの値を見つけます。 これらの値を1行にまとめて、リクエストにコメントとして追加します。
それがこのアプローチのすべての困難です。 新しいキャッシュポリシーに移行するには、コードを少し変更するだけです。 このアプローチを示す例を以下に示します。 この例は完全に独立しており、mysqlおよびmemcache拡張機能をサポートするPHPがある場合に実行できます。
このアプローチにより、データキャッシングの効率が向上します。 キャッシュをリセットすると、変更されたテーブルを参照するデータのみが削除されます。 より具体的には、「キャッシュをフラッシュする」という言葉は意味を失い、変更されたデータにアクセスできなくなり、キャッシュは同じリクエストの新しいキーで満たされ続けます。 キャッシュ全体が頻繁にフラッシュされる「ugい」テーブルがある場合、このようなテーブルは全体像を損なうことはありません。
この方法は実行可能であり、いずれかのサイト( http://www.skachatreferat.ru )でテストされました。 経験から、他のキャッシュ方法を無視すべきではないことが示されています。 5分に1回のリフレッシュレートで関連性が重要ではないデータの場合、特定の期間(この場合は5分)にキャッシュの有効期間を設定して最も単純なキャッシュを使用することをお勧めします。
記事へのアクセスを提供するhabrahabrを使用します。 ここで、各記事はテキストフィールドといくつかの属性のセットです。 テキストはめったに変更されませんが、記事の属性は頻繁に変更されます。 このため、記事のテキストのみをキャッシュに入れるのが理にかなっており、属性はテーブルから独立して選択されます。 その結果、データアクセスの速度は1桁向上します。
選択する列が少ないほど、パフォーマンスが向上します。 MySQLは、TEXTタイプ(記事のテキストを保存する)のカラムよりも桁違いに速い単純タイプのデータを持つカラムで動作します。 これらの機能を使用すると、パフォーマンスが大幅に向上します。
以下は、キャッシュをテーブルに分割する方法を示すスクリプトで、そのソースは約束されています。 このスクリプトは完全に独立しており、追加のモジュールは必要ありません。 スクリプトの最初にmysqlとmemcacheのデータを指定することを忘れないでください:
<? 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>
ソースはこちら: www.skachatreferat.ru/demo.txt