文本文件数据库处理函数库

因为我租不起MySQL支持 所以只能采用扁平文件存储

我是采用perl常用的
"|"定界的格式就像 "name|email|homepage" 这样的格式。

随便写了几个函数
觉得还是有点用处的。 大家有什么心得

也希望能告诉我啊
我来完善完善。



<?php



// dtf.inc.php3

//

// DTF -- Delimited Text File Functions 数据挖掘交友

// Written by: Goghs <goghs@mail.com>

// http://www.eqiao.com

//

// Function to manage a delimited text file database



function dtf_fetch_all_as_string($filename) {

$fp = fopen( $filename, "r" );

$current = fread($fp, filesize($filename));

fclose($fp);

return $current;

}





function dtf_fetch_all_as_array($dbname) {

return file($dbname);

}



function dtf_update_db($dbname, $item) {

if (file_exists($dbname)):

$fp = fopen($dbname,"w+");

fputs($fp,$item);

fclose($fp);

else:

$fp = fopen($dbname,"w");

fputs($fp,$item);

fclose($fp);

endif;

}



function dtf_get_total_rows($dbname) {

return count(file($dbname));

}



function dtf_remove_pipe($input) {

if (is_string($input)) {

// $input=ereg_replace("|","",$input); // It’s said that str-replace is faster than ereg_replace

$input=str_replace("|","",$input);

}

if (is_array($input)) {

for ($i=0; $i<count($input); $i++) {

$input[$i] = ereg_replace("|","|",$input[$i]);

}

}

return $input;

}





// 这个函数没有用, 用htmlspecialchars就可以

// 但是如果只需要处理"<",">"而不需要处理 引号和 &时就很有用

function dtf_remove_html_tag($input) {

if (is_string($input)) {

$input = ereg_replace("<","<",$input);

$input = ereg_replace(">",">",$input);

}

if (is_array($input)) {

for ($i=0; $i<count($input); $i++) {

$input[$i] = ereg_replace("<","<",$input[$i]);

$input[$i] = ereg_replace(">",">",$input[$i]);

}

}

return $input;

}





// 可以定制这个函数, 控制是否允许html标记等

function dtf_sanitize($input) {

$input = dtf_remove_pipe($input);

// $input = dtf_remove_html_tag($input); 数据挖掘实验室

$input = stripslashes($input);

$input = htmlspecialchars($input);

return $input;

}



?>
[数据挖掘专家] [数据挖掘研究院] [数据挖掘论坛] [数据挖掘实验室]
上一篇:显示目标网页中的的联接地址
下一篇:通过数据库进行身份验证的一点注意事项
最新评论共有 0 位网友发表了评论 , 查看所有评论
发表评论( 不能超过250字,需审核,请自觉遵守互联网相关政策法规。 )
匿名?
数据挖掘网站导航 数据挖掘论坛导航
  • 数据挖掘工具
  • 数据挖掘论坛
  • DataCruncher - Cognos
  • MineSet - MathSoft
  • Intelligent Miner - GainSmarts
  • Sqlserver - SAS - Clementine
  • CART - Weka - WizSoft
  • NeuroShell - ModelQuest
  • data mining tools - Darwin
  • 数据挖掘交友
  • 数据挖掘博客
  • 数据挖掘工具
  • 数据挖掘资源
  • 数据挖掘技术算法
  • 数据挖掘相关期刊、会议
  • 研究院联盟合作专区
  • 数据挖掘基础与相关技术
  • 数据挖掘厂商与就业
  • 数据挖掘研究者乐园
  • 知名厂商数据挖掘工具资料
  • 国内数据挖掘实验室
  • Foreign Data Mining Lab
  • 热点关注
  • 揭秘成为最牛程序员的五大要诀
  • MYSQL错误:Illegal mix of collations (lat
  • PHP程序不适用大型系统的九大原因
  • 上海酒店公寓,上海短租公寓,上海短租房,上
  • 安装php5.2.5和mysql5.045后phpmyadmin报错
  • 福利彩票幸运号码自动生成器
  • 关于APACHE的配置文件httpd.conf
  • 国际:身处两难境地,PHP 该走向何方?
  • PHP跳转的方法?
  • 函式:preg_match_all()
  • 论坛最新话题
  • Foundations of Statistical Natural Langu
  • Game Theory meet Data Mining: A Recent P
  • System Building: How does it help or hin
  • 数据挖掘与Clementine培训
  • 新手报到
  • 求 SASEM 客户流失预测分析
  • 数据挖掘工程师/搜索研究院—北京——无线
  • 数据挖掘入门介绍(如何着手数据挖掘)
  • Information Overload Survey Results
  • The INEX 2005 Workshop on Element Retrie
  • 相关资讯
  • Module mod_log_config
  • 圣殿骑兵PHP 2007年Web开发技术预言 (四)
  • 圣殿骑兵PHP 2007年Web开发技术预言 (三)
  • 圣殿骑兵PHP 2007年Web开发技术预言 (二)
  • 圣殿骑兵PHP 2007年Web开发技术预言 (一)
  • 一棵php的类树(支持无限分类)
  • 通过对php一些服务器端特性的配置加强php的
  • 如何使用动态共享对象的模式来安装PHP
  • 提升PHP执行速度全攻略(上)
  • phpBBBBcode处理的漏洞
  • 数据挖掘实验室资料
  • 数据挖掘博客地址
  • 数据挖掘实验室网站地址
  • Prepare for Medicare audits by using dat
  • 注册成为SAS用户与爱好者俱乐部会员
  • 水南梅
  • 明日烟
  • 新人报道
  • 下载
  • 厦门服务器托管,450元/月—0592-5177319 高
  • 买空间送域名--0592-5177319 高静