dongsheng4126335 2015-05-26 13:33
浏览 102

如何在PHP中使用dbase优化.dbf文件的研究?

I would like to know if you have some ideas/suggestions about the use of dbase in PHP.

Here's my problem, i have to "translate" a Foxpro script in PHP, and i'm using dbase since I have to deal with .DBF files. The problem is the time it takes for PHP to execute the script, because i didn't find a better way to translate the select queries than iterating through the entire file to select the data I need ...

And obviously, I reached the point where it takes too much time for PHP to render the script to the user. I know I can give the server more time to execute the PHP by modifying the php.ini file etc. but that's not a solution since this script is later going to be accessible to almost every user of the site i'm developping, so if it could go as fast as possible to render that would be really great ...

So, to sum up, what can I do to get a faster execution time with PHP on .dbf files queries ? How would you translate Foxpro's SELECT queries in PHP ? Do you recommend me to make this script in an other language than PHP ?

I give you an example of what i have to translate, it's just a small part of what i have to translate, and .dbf files are containing at least 50 000 lines with at least 10 columns each :/

FUNCTION 
PARAMETERS n_pc_id, l_pc_euro, n_sf_id, l_contrat
PRIVATE tb_res, mwhere
DIMENSION tb_res[1]
STORE 0 TO tb_res

IF n_sf_id = 0
IF l_contrat
    mwhere = "lig_mo.lo_gar = 'T' AND mo.mo_sf_id != m.pa_sfd_id"
ELSE
    mwhere = "lig_mo.lo_gar != 'T' AND mo.mo_sf_id != m.pa_sfd_id"
ENDIF
ELSE
IF l_contrat
    mwhere = "lig_mo.lo_gar = 'T' AND mo.mo_sf_id = n_sf_id"
ELSE
    mwhere = "lig_mo.lo_gar != 'T' AND mo.mo_sf_id = n_sf_id"
ENDIF
ENDIF

SELECT SUM(lig_mo.lo_qte);
FROM mo, lig_mo;
WHERE mo.mo_id = lig_mo.lo_mo_id;
AND (lig_mo.lo_pc_id = n_pc_id;
AND &mwhere;
AND lig_mo.lo_mo_id != 99999999);
AND lig_mo.lo_type IN ('F','V','B');
INTO ARRAY tb_res
RETURN tb_res[1]
  • 写回答

1条回答 默认 最新

  • duancan8382 2015-05-27 15:04
    关注

    You definitely don't want to be doing it on a row basis. I would look at this discussion of accessing DBF files from PHP, then you can pass the (presumably Rushmore-optimised) query above straight into that, after changing it to use query parameters.

    评论

报告相同问题?

悬赏问题

  • ¥15 使用C#,asp.net读取Excel文件并保存到Oracle数据库
  • ¥15 C# datagridview 单元格显示进度及值
  • ¥15 thinkphp6配合social login单点登录问题
  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配