php 链接sqlite数据库 php 链接sqlite数据库 哪位高手知道?请教、、、急求 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 $db = sqlite_open('库名');$rs = sqlite_query($db, 'select * from tbl_name');print_r(sqlite_fetch_all($rs)); 这个跟mysql有什么区别吗? 没有太大区别,不过 sqlite 属于桌面数据库,不太适合存放大量数据和频繁访问如使用它的内存表并结合自定义函数,倒是可以简化很都复杂的算法 提一个代码给你看看class word { function word() { $this->db = sqlite_open(':memory:'); sqlite_query($this->db, "CREATE TABLE strings(word, num,PRIMARY KEY (word))"); sqlite_create_function($this->db, 'my', array($this, 'foo'), 2); } function add($str) { $n = strlen($str); $str = sqlite_escape_string($str); sqlite_query($this->db, "INSERT INTO strings VALUES ('$str', $n)"); } function foo($s, $v) { return $s == substr($this->dat, $this->i, $v); } function parse($s) { $this->i = 0; $this->dat = $s; $this->len = strlen($s); while($this->i < $this->len) $this->get(); } function get() { $ch = $this->dat{$this->i}; $rs = sqlite_query($this->db, "SELECT * from strings where my(word, num) order by 1,2 desc"); $num = sqlite_num_rows($rs); if( $num ) { $row = sqlite_fetch_array($rs, SQLITE_ASSOC ); echo "<b>$row[word]</b>"; $this->i += $row['num']; }else { echo $ch; } $this->i ++; } function test() { $rs = sqlite_query($this->db, "SELECT * from strings"); echo $num = sqlite_num_rows($rs); }}$data = array( 'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten', );$s = <<< TXT一.数词的定义 数词是表示数目多少或先后顺序的词,有基数词和序数词两种。表数量的数词叫基数词,如one, two, three。表顺序的数词叫序数词,如first, second, third, fourth, fifth,...二.基数词(一)构成1)1~12单独记 one, two, three, four, five, six, seven, eight, nine, ten, eleven, twelve2)13~19词尾为-teen:thirteen, fourteen, fifteen, sixteen, seventeen, eighteen, nineteen3)20~90逢整十词尾为-ty:twenty, thirty,forty,fifity,...4)21~ 99在十位数和个位数之间加连字符构成,如: 73 seventy-three, 88 eighty-eight5)101~ 999先说几百,再加and,再加末尾两位数,如: 178 one hundred and seventy-eight6)1000以上的数词,先从后向前数,每三位用一个数逗点“,”隔开。第一个“,”是thousand千,第二个“,”是million百万,第三个“,”是billion美语中的十亿(英国用thousand million),然后一节一节地用几百几十几的方法来数。TXT;$p = new word;foreach ($data as $str) { $p->add($str);}$p->parse($s); php+ajax按需多进程的问题 PDO数据分页类效率高还是用存储过程效率高?同时求代码! 关于文件上传目录创建的问题 初学PHP,菜鸟一只,问个小问题? 关于随机显示显示记录的问题 新手如何学习php 提供PHP脚本的反编译服务,反编译Zend加密的PHP文件 高难度???????????????? 急急急,在线等待,求救,传递单选按扭值的问题,代码如下 PHP入门问题 好技巧:eclipse for php 访问对象变量的自动代码提示 一个简单的php验证码
$rs = sqlite_query($db, 'select * from tbl_name');
print_r(sqlite_fetch_all($rs));
这个跟mysql有什么区别吗?
如使用它的内存表并结合自定义函数,倒是可以简化很都复杂的算法
function word() {
$this->db = sqlite_open(':memory:');
sqlite_query($this->db, "CREATE TABLE strings(word, num,PRIMARY KEY (word))");
sqlite_create_function($this->db, 'my', array($this, 'foo'), 2);
}
function add($str) {
$n = strlen($str);
$str = sqlite_escape_string($str);
sqlite_query($this->db, "INSERT INTO strings VALUES ('$str', $n)");
} function foo($s, $v) {
return $s == substr($this->dat, $this->i, $v);
}
function parse($s) {
$this->i = 0;
$this->dat = $s;
$this->len = strlen($s);
while($this->i < $this->len) $this->get();
}
function get() {
$ch = $this->dat{$this->i};
$rs = sqlite_query($this->db, "SELECT * from strings where my(word, num) order by 1,2 desc");
$num = sqlite_num_rows($rs);
if( $num ) {
$row = sqlite_fetch_array($rs, SQLITE_ASSOC );
echo "<b>$row[word]</b>";
$this->i += $row['num'];
}else {
echo $ch;
}
$this->i ++;
}
function test() {
$rs = sqlite_query($this->db, "SELECT * from strings");
echo $num = sqlite_num_rows($rs);
}
}$data = array(
'one',
'two',
'three',
'four',
'five',
'six',
'seven',
'eight',
'nine',
'ten',
);$s = <<< TXT
一.数词的定义
数词是表示数目多少或先后顺序的词,有基数词和序数词两种。表数量的数词叫基数词,如one, two, three。表顺序的数词叫序数词,如first, second, third, fourth, fifth,...二.基数词
(一)构成
1)1~12单独记
one, two, three, four, five, six, seven, eight, nine, ten, eleven, twelve
2)13~19词尾为-teen:thirteen, fourteen, fifteen, sixteen, seventeen, eighteen, nineteen
3)20~90逢整十词尾为-ty:twenty, thirty,forty,fifity,...
4)21~ 99在十位数和个位数之间加连字符构成,如:
73 seventy-three, 88 eighty-eight
5)101~ 999先说几百,再加and,再加末尾两位数,如:
178 one hundred and seventy-eight
6)1000以上的数词,先从后向前数,每三位用一个数逗点“,”隔开。第一个“,”是thousand千,第二个“,”是million百万,第三个“,”是billion美语中的十亿(英国用thousand million),然后一节一节地用几百几十几的方法来数。
TXT;$p = new word;
foreach ($data as $str) {
$p->add($str);
}
$p->parse($s);