ホームページ バックエンド開発 PHPチュートリアル Infinite Return: Super Police PHP 無限キャッシュ クラス拡張

Infinite Return: Super Police PHP 無限キャッシュ クラス拡張

Jul 29, 2016 am 08:39 AM

コードをコピーします コードは次のとおりです:


/**
* 機能: カテゴリの使用量を減らすために条件に基づいてカテゴリ キャッシュを作成します
* 作成日: Thu May 31 15:55:11 CST 2007
* 最終更新日:
* 著者: sanshi */
classtreeCache
{
var $tableName = "index_category" //テーブル名
var $where = "1"; //where 条件
var $pidStr ="i_c_pid"; //pid
varのフィールド名 $tempCode = array(); //生成されたファイルの配列
var $pid = '0'; //pid
varの初期値 $db;
var $idStr="i_c_id"; //取得したデータID
var $title = "i_c_cn"; //名前フィールド
var $createArrayName = "treeCache" //作成された配列名
var $createFileName ="" ; //ファイルの名前を作成します
var $appendArr = array(); //追加の属性では、フィールド名がデータ内の名前に対応する必要があります
var $is_utf8 = false;
function set ($db)
{
$this->db = $db;
$this->tempCode[] = "//第 1 レベルの関数 getRootID をすべて取得します()
{
$sql = "SELECT {$this->idStr} FROM {$this->tableName} WHERE
{$this->pidStr}='{$this->pid}' AND { $this->where} ";
//exit($sql);
$result = $this->db->select($sql);
$temp = array();
foreach ($result $r として)
{
$temp[]=$r["{$this->idStr}"]
}
$this->tempCode[] = "${$this->createArrayName}[ 'root' ]='".implode(',',$temp)."';";
//print_r($temp);
return $temp;
}
//子 ID を取得
function getChildren($ pid)
{
$sql = "SELECT {$this->idStr} FROM {$this->tableName} WHERE
{$this->pidStr}='{$pid}' AND {$this-> ;where} ";
$result = $this->db->select($sql);
$temp = array();
foreach ($result as $r)
{
$temp[]=$ r[" {$this->idStr}"];
}
return $temp;
//夫の ID を取得
function getParent($cid)
{
$sql = "SELECT {$this-> pidStr} FROM {$this->tableName} WHERE
{$this->idStr}='{$cid}' AND {$this->where} ";
$result = $this->db- >select ($sql);
//print_r($result);exit();
return $result[0]["{$this->pidStr}"]
//上司の ID を取得
関数 getPidStr ($cid,$pidStr="")
{
$pid=$this->getParent($cid);
while ($pid!=$this-> pid && ! emptyempty($pid)) {
$temp[] = $pid;
}
//print_r($temp); ,', $temp);
}
//深度を取得する
function getDepth($cid,$ Depth=0)
{
$pid=$this->getParent($cid);
if ( $pid ! = $this->pid && !emptyempty($pid))
$ Depth = $this->getDepth($pid,$ Depth);
return $ Depth
}
// ファイルを作成します
関数 make()
{
if(empty($this->createFileName))
$this->createFileName = "{$this->createArrayName}.data.php";
$rootArr = $this-> ;getRootID() ;
$selectF = "{$this->idStr},{$this->title},{$this->pidStr}"; )
{
if(emptyempty($app)) 続行;
$selectF .=",{$app}"
}
$sql = "SELECT {$selectF} FROM {$this->tableName} WHERE
{$this->where}";
$result = $this->db->select($sql);
for ($i=0;$i {
// id 値
$this->tempCode[] =
"${$this->createArrayName}['{$result[$i][$this->idStr]}']['id ']=' {$result[$i]["{$this->idStr}"]}';";
//タイトル
$this->tempCode[] =
"${$this-> ;createArrayName}[ '{$result[$i][$this->idStr]}']['title']='{$result[$i]["{$this->title}"]} ';";
//親 ID
$this->tempCode[] =
"${$this->createArrayName}['{$result[$i][$this->idStr]}'] ['pid' ]='{$result[$i]["{$this->pidStr}"]}';";
//サブ ID
$this->tempCode[] =
"$ {$this-> ;createArrayName}['{$result[$i][$this->idStr]}']['cid']='".implode(',',$this->getChildren( $result[$i ]["$this->idStr"]))."';";
//ディレクトリの深さ
$this->tempCode[] =
"${$this->createArrayName} ['{$result [$i][$this->idStr]}']['深さ']='".$this->getDepth($result[$i]["$this->idStr "])." ';";
//親 ID の ID 文字列
$this->tempCode[] =
"${$this->createArrayName}['{$result[$i][ $this->idStr] }']['pstr']='".$this->getPidStr($result[$i]["$this->idStr"])."';";
//追加の属性を追加しました
foreach ($this->appendArr as $app)
{
if(emptyempty($app)) continue
$this->tempCode[] =
"${$this-> createArrayName}['{$ result[$i][$this->idStr]}']['{$app}']='{$result[$i]["{$app}"]}'; ";
}
}
$this->tempCode[] = "${$this->createArrayName} を返す;";
$this->tempCode[] = "?>";
//$content = implode("n",$this->tempCode);
//print_r($this->tempCode );
$content = implode("n",$this->tempCode);
//ファイルを作成します
$fio=Factory::getBaseClass('FileIO');
if($this->is_utf8) content = "xEFxBBxBF".$content;
$fio->writeFile($this->createFileName,$content);
return $content ;
}
}
//ロードされたファイルはデータベース接続用です
/データベースには select メソッドが必要です
/*
include_once(dirname(dirname(__FILE__))."/config/config.inc.php");
include_once(CLASSES_PATH."factryObject.class.php"); fatryObject::getDB('indexPush');
$c = new TreeCache($db);
//exit();
//include_once("treeCache.data") .php");
$treeCache=isset($treeCache) ? $treeCache : array();
$rootStr = isset($treeCache['root']) ? $treeCache['root'] : "";
echo parseTree($treeCache,$rootStr);
関数 parseTree($treeCache,$rootStr)
$tempStr = ""
foreach ($temp AS $cid); )
{
$info = $treeCache[$cid];
$cidStr = $info['cid']
$tempStr .= str_repeat('-',($info['深さ']-1); );
$tempStr.=$info['title'];
if(empty($info['pid']))
{
//追加の操作
}
$tempStr .= "
";
if(!empty($info['cid']))
$tempStr .=parseTree($treeCache,$info['cid']);
}
return $tempStr;
}
*/
? >
/**
* 機能: カテゴリの使用量を減らすために条件に基づいてカテゴリ キャッシュを作成します
* 作成日: Thu May 31 15:55:11 CST 2007
* 最終更新日:
* 著者: sanshi */
class TreeCache
{
var $tableName = "index_category" // テーブル名
var $where = "1"; pidStr = "i_c_pid"; //pid
varのフィールド名 $tempCode = array() //生成されたファイルの配列
var $pid = '0' //pid
varの初期値 $db;ハンドル
var $idStr="i_c_id"; //取得したデータ ID
var $title = "i_c_cn"; //名前フィールド
var $createArrayName = "treeCache" //作成された配列の名前
var $createFileName =" "; // ファイルの名前を作成します
var $appendArr = array(); // 追加の属性、フィールド名はデータ内の名前に対応する必要があります
var $is_utf8 = false;
{
}
function set($db)
{
$this->db = $db;
$this->tempCode[] = "}
//最初にすべてを取得します。レベル
function getRootID()
{
$sql = "SELECT {$this->idStr} FROM {$this->tableName} WHERE
{$this->pidStr}='{$this->pid }' AND {$this ->where} ";
//exit($sql);
$result = $this->db->select($sql);
$temp = array();
foreach ($result as $ r)
{
$temp[]=$r["{$this->idStr}"]
}
$this->tempCode[] = "${$this-> ;createArrayName}['root ']='".implode(',',$temp)."';";
//print_r($temp);
return $temp;
}
//子 ID を取得
function getChildren($pid)
{
$sql = "SELECT {$this->idStr} FROM {$this->tableName} WHERE
{$this->pidStr}='{$pid}' AND { $this->where } ";
$result = $this->db->select($sql);
$temp = array();
foreach ($result as $r)
{
$temp []=$r[ "{$this->idStr}"];
}
return $temp;
//夫の ID を取得
function getParent($cid)
{
$sql = "SELECT {$ this->pidStr} FROM {$this->tableName} WHERE
{$this->idStr}='{$cid}' AND {$this->where} ";
$result = $this- >db->select($sql);
//print_r($result);exit();
return $result[0]["{$this->pidStr}"]
//上司の ID を取得します
function getPidStr($cid,$pidStr="")
{
$pid=$this->getParent($cid);
$temp = array(); this->pid && !empty($pid)) {
$temp[] = $pid=$this->getParent($pid);
//print_r($temp); return implode(',' ,$temp);
//深さ
関数を取得します getDepth($cid,$ Depth=0)
{
$pid=$this->getParent($cid);深さ++;
if( $pid != $this->pid && !empty($pid))
$ Depth = $this->getDepth($pid,$ Depth); /ファイルの作成
function make( )
{
if(empty($this->createFileName))
$this->createFileName = "{$this->createArrayName}.data.php";
$rootArr = $this->getRootID( );
$selectF = "{$this->idStr},{$this->pidStr}"; appendArr as $app)
{
if(empty($app)) 続行;
$selectF .=",{$app}"
}
$sql = "SELECT {$selectF} FROM {$this-> tableName} WHERE
{$this ->where}";
$result = $this->db->select($sql);
for ($i=0;$i{
/ /id 値
$this->tempCode[] =
"${$this->createArrayName}['{$result[$i][$this->idStr]}']['id']='{$result[$i]["{$this->idStr}"]}';";
//标题
$this->tempCode[] =
"$ {$this->createArrayName}['{$result[$i][$this->idStr]}']['title']='{$result[$i]["{$this-> title}"]}';";
//父id
$this->tempCode[] =
"${$this->createArrayName}['{$result[$i][$this-> idStr]}']['pid']='{$result[$i]["{$this->pidStr}"]}';";
//子id
$this->tempCode[] =
"${$this->createArrayName}['{$result[$i][$this->idStr]}']['cid']='".implode(',',$this- >getChildren($result[$i]["$this->idStr"]))."';"
//目录深度
$this->tempCode[] =
"${$this- >createArrayName}['{$result[$i][$this->idStr]}']['深さ']='".$this->getDepth($result[$i]["$this ->idStr"])."';";
//父idのid串
$this->tempCode[] =
"${$this->createArrayName}['{$result[$i ][$this->idStr]}']['pstr']='".$this->getPidStr($result[$i]["$this->idStr"])."';" ;
//追加の追加プロパティ
foreach ($this->appendArr as $app)
if(empty($app)) continue
$this->tempCode[] =
" ->createArrayName}['{$result[$i][$this->idStr]}']['{$app}']='{$result[$i]["{$app}"] }';";
}
}
$this->tempCode[] = "${$this->createArrayName} を返します;";
$this->tempCode[] = "?>";
//$content = implode("n",$this->tempCode);
//print_r($this->tempCode);
$content = implode("n",$this->tempCode);
//建立文件
$fio=Factory::getBaseClass('FileIO');
if($this->is_utf8) $content = "xEFxBBxBF".$content;
$fio->writeFile($this->createFileName,$content);
$content を返す ;
}
}
//追加された文件は了のために、データ库接続
//データ库が必要です select メソッド
/*
include_once(dirname(dirname(__FILE__))."/config/config.inc.php");
include_once(CLASSES_PATH."factryObject.class.php");
$db =factryObject::getDB('indexPush');
$c = 新しいツリーキャッシュ($db);
$c->make();
//終了();
//做分析
include_once("treeCache.data.php");
$treeCache=isset($treeCache) ? $treeCache : array();
$rootStr = isset($treeCache['root']) ? $treeCache['root'] : "";
echo parseTree($treeCache,$rootStr);
関数 parseTree($treeCache,$rootStr)
{
$tempStr = "";
$temp =explode(',',$rootStr);
foreach ($temp AS $cid)
{
$info = $treeCache[$cid];
$cidStr = $info['cid'];
$tempStr .= str_repeat('-',($info['深さ']-1)*3);
$tempStr.=$info['タイトル'];
if(empty($info['pid']))
{
//追加操作
}
$tempStr .= "
";
if(!empty($info['cid']))
$tempStr .=parseTree($treeCache,$info['cid']);
}
$tempStr を返します。
}
*/
?>
この種は改善されており、当初はこれの組み合わせであり、数字の数として機能するだけです、次は文字母了
另外就は解析に関するものです
クリップボードプリントへのプレーンコピーを表示しますか?
class parseTree
{
var $ads_type_file = "";
var $isX = false;
var $rowSize=2;
function parseTree()
{
$this->ads_type_file = CACHE_PATH."ads_type_arr.data.php";
$this->ads_city_file = CACHE_PATH."ads_city_arr.data.php";
}
関数 make_ads_type()
{
$db = Factory::getDB("ads_type");
$tree =Factory::getItemClass('treeCache');
$tree->set($db);
$tree->テーブル名=$db->テーブル名;
$tree->pidStr ="ads_type_pid";
$tree->idStr = "ads_type_id";
$tree->title = "広告タイプ名";
$tree->createArrayName ="ads_type_arr";
$tree->where = " ads_type_state=1 ORDER BY ads_type_id DESC ";
$tree->appendArr = array("ads_type_info");
$tree->createFileName = $this->ads_type_file;
$tree->is_utf8 = true;
return $tree->make();
}
関数 get_ads_type_str()
{
$temp_arr = $this->get_ads_type_arr();
$treeArr = emptyempty($temp_arr) ? array() : $temp_arr;
$rootStr = isset($temp_arr['root']) ? $temp_arr['root'] : "";
$show_content = $this->__parseTree($treeArr,$rootStr,'pares_type_link');
$show_content を返します;
}
function get_ads_type_arr()
{
return is_file($this->ads_type_file) ? require($this->ads_type_file) : array();
}
function pares_type_link($info)
{
$class_name = "ads_type";
$tempStr = "[子-追加]";
$tempStr .="[编辑]";
$tempStr .="[删除]";
return $tempStr;
}
//基づいて提供された类别号取得类别数组
function get_type_arr($type_no=0)
{
$temp_arr = $this-> get_ads_type_arr();
$rootStr = $type_no==0 ? (isset($temp_arr['root'])?$temp_arr['root'] : "") : (isset($temp_arr[$type_no]['cid) '])?$temp_arr[$type_no]['cid']:"");
$temp =explode(',',$rootStr);
$return_temp = array(); )
{
if(isset($temp_arr[$cid])) $return_temp[$temp_arr[$cid]['id']]=$temp_arr[$cid]['title']
}
return $return_temp; ;
}
関数 make_ads_city()
{
$db = Factory::getDB("ads_city");
$tree->set($db);
$tree->tableName=$db->tableName;
$tree->pidStr = "ads_city_no";
$tree->title = "ads_city_name"; ;
$tree->createArrayName ="ads_city_arr";
$tree->where = "ads_city_state=1 ORDER BY ads_city_no DESC ";
$tree->appendArr = array("ads_city_info"); >createFileName = $this->ads_city_file;
$tree->is_utf8 = true;
}
関数 get_ads_city_arr()
{
return is_file($this->ads_city_file) ? require($this->ads_city_file) : array();
}
関数 get_ads_city_str()
{
$temp_arr = $this->get_ads_city_arr();
$treeArr = emptyempty($temp_arr) ? array() : $temp_arr;
$rootStr = isset($temp_arr['root']) ? $temp_arr['root'] : "";
$show_content = $this->__parseTree($treeArr,$rootStr,'pares_city_link');
$show_content を返します;
}
function pares_city_link($info)
{
$class_name = "ads_city";
$tempStr = "[子-追加]";
$tempStr .="[编辑]";
$tempStr .="[删除]";
$tempStr を返します。
}
//準拠城市号取得城市数组
function get_city_arr($city_no=0)
{
$temp_arr = $this->get_ads_city_arr();
$rootStr = $city_no==0 ? (isset($temp_arr['root'])?$temp_arr['root'] : "") : (isset($temp_arr[$city_no])?$temp_arr[$city_no]:"");
$temp =explode(',',$rootStr);
$return_temp = array();
foreach($temp as $cid)
{
if(isset($temp_arr[$cid])) $return_temp[$temp_arr[$cid]['id']]=$temp_arr[$cid]['title' ];
}
return $return_temp;
}
function __parseTree($treeCache,$rootStr,$fuc_str)
{
$tempStr = "";
$temp =explode(',',$rootStr);
if(emptyempty($temp)) return "";
$this->layer=0;
foreach ($temp AS $cid)
{
if(isset($treeCache[$cid]))
{
$info = $treeCache[$cid];
$cidStr = $info['cid'];
//如果下面有子id
if($info["cid"]!="")
{
$tempStr .="

";
$tempStr .= str_repeat(' ',($info['深さ']-1)*3);
if($info["cid"]!="")
{
//$tempStr .="";
}
//$tempStr .=">";
$tempStr.=$info['タイトル'];
$tempStr .=$this->{$fuc_str}($info);
$tempStr .="
";
$tempStr .="";
$tempStr .= $this->__parseTree($treeCache,$info['cid'],$fuc_str);
$tempStr .="
";
}else{
$this->layer++;
$tempStr .= str_repeat(' ',($info['深さ']-1)*3);
$tempStr.=$info['タイトル'];
$tempStr .=$this->{$fuc_str}($info);
if($this->isX==true)
{
if($this->layer % $this->rowSize ==0)
$tempStr .= "
";
else
$tempStr .= " ";
}else{
$tempStr .= "
";
}
}
}
}
return $tempStr;
}
}
?>



以上は、無制限の超級警察 php 無制限に保存されている種類の拡張であり、無制限の超級警察に関するコンテンツが含まれており、PHP 教則に関心のある友人の助けを希望します。

このウェブサイトの声明
この記事の内容はネチズンが自主的に寄稿したものであり、著作権は原著者に帰属します。このサイトは、それに相当する法的責任を負いません。盗作または侵害の疑いのあるコンテンツを見つけた場合は、admin@php.cn までご連絡ください。

ホットAIツール

Undresser.AI Undress

Undresser.AI Undress

リアルなヌード写真を作成する AI 搭載アプリ

AI Clothes Remover

AI Clothes Remover

写真から衣服を削除するオンライン AI ツール。

Undress AI Tool

Undress AI Tool

脱衣画像を無料で

Clothoff.io

Clothoff.io

AI衣類リムーバー

AI Hentai Generator

AI Hentai Generator

AIヘンタイを無料で生成します。

ホットツール

メモ帳++7.3.1

メモ帳++7.3.1

使いやすく無料のコードエディター

SublimeText3 中国語版

SublimeText3 中国語版

中国語版、とても使いやすい

ゼンドスタジオ 13.0.1

ゼンドスタジオ 13.0.1

強力な PHP 統合開発環境

ドリームウィーバー CS6

ドリームウィーバー CS6

ビジュアル Web 開発ツール

SublimeText3 Mac版

SublimeText3 Mac版

神レベルのコード編集ソフト(SublimeText3)

Laravelでフラッシュセッションデータを使用します Laravelでフラッシュセッションデータを使用します Mar 12, 2025 pm 05:08 PM

Laravelは、直感的なフラッシュメソッドを使用して、一時的なセッションデータの処理を簡素化します。これは、アプリケーション内に簡単なメッセージ、アラート、または通知を表示するのに最適です。 データは、デフォルトで次の要求のためにのみ持続します。 $リクエスト -

PHPのカール:REST APIでPHPカール拡張機能を使用する方法 PHPのカール:REST APIでPHPカール拡張機能を使用する方法 Mar 14, 2025 am 11:42 AM

PHPクライアントURL(CURL)拡張機能は、開発者にとって強力なツールであり、リモートサーバーやREST APIとのシームレスな対話を可能にします。尊敬されるマルチプロトコルファイル転送ライブラリであるLibcurlを活用することにより、PHP Curlは効率的なexecuを促進します

Laravelテストでの簡略化されたHTTP応答のモッキング Laravelテストでの簡略化されたHTTP応答のモッキング Mar 12, 2025 pm 05:09 PM

Laravelは簡潔なHTTP応答シミュレーション構文を提供し、HTTP相互作用テストを簡素化します。このアプローチは、テストシミュレーションをより直感的にしながら、コード冗長性を大幅に削減します。 基本的な実装は、さまざまな応答タイプのショートカットを提供します。 Illuminate \ support \ facades \ httpを使用します。 http :: fake([[ 'google.com' => 'hello world'、 'github.com' => ['foo' => 'bar']、 'forge.laravel.com' =>

Codecanyonで12の最高のPHPチャットスクリプト Codecanyonで12の最高のPHPチャットスクリプト Mar 13, 2025 pm 12:08 PM

顧客の最も差し迫った問題にリアルタイムでインスタントソリューションを提供したいですか? ライブチャットを使用すると、顧客とのリアルタイムな会話を行い、すぐに問題を解決できます。それはあなたがあなたのカスタムにより速いサービスを提供することを可能にします

PHPにおける後期静的結合の概念を説明します。 PHPにおける後期静的結合の概念を説明します。 Mar 21, 2025 pm 01:33 PM

記事では、PHP 5.3で導入されたPHPの後期静的結合(LSB)について説明し、より柔軟な継承を求める静的メソッドコールのランタイム解像度を可能にします。 LSBの実用的なアプリケーションと潜在的なパフォーマ

フレームワークのカスタマイズ/拡張:カスタム機能を追加する方法。 フレームワークのカスタマイズ/拡張:カスタム機能を追加する方法。 Mar 28, 2025 pm 05:12 PM

この記事では、フレームワークにカスタム機能を追加し、アーキテクチャの理解、拡張ポイントの識別、統合とデバッグのベストプラクティスに焦点を当てています。

フレームワークセキュリティ機能:脆弱性から保護します。 フレームワークセキュリティ機能:脆弱性から保護します。 Mar 28, 2025 pm 05:11 PM

記事では、入力検証、認証、定期的な更新など、脆弱性から保護するためのフレームワークの重要なセキュリティ機能について説明します。

See all articles