dongshan1959 2010-05-29 13:39
浏览 18
已采纳

PHP商业项目功能定义

Currently I am working with a commercial project with PHP. I think this question not really apply to PHP for all programming language, just want to discuss how your guys solve it.

I work in MVC framework (CodeIgniter).

all the database transaction code in model class.

Previously, I seperate different search criteria with different function name. Just an example

function get_student_detail_by_ID($id){}
function get_student_detail_by_name($name){}

as you can see the function actually can merge to one, just add a parameter for it. But something you are rushing with project, you won't look back previously got what similar function just make some changes can meet the goal. In this case, we found that there is a lot function there and hard to maintenance.

Recently, we try to group the entity to one ultimate search something like this

function get_ResList($is_row_count=FALSE, $record_start=0, $arr_search_criteria='', $paging_limit=20, $orderby='name', $sortdir='ASC')

we try to make this function to fit all the searching criteria. However, our system getting bigger and bigger, the search criteria not more 1-2 tables. It require join with other table with different purpose. What we had done is using IF ELSE,

if(bla bla bla)
{
   $sql_join = JOIN_SOME_TABLE;
   $sql_where = CONDITION;    
}

at the end, we found that very hard to maintance the function. it is very hard to debug as well.

I would like to ask your opinion, what is the commercial solution they solve this kind of issue, how to define a function and how to revise it. I think this is link project management skill. Hope you willing to share with us.

Thanks.

  • 写回答

3条回答 默认 最新

  • dongtan7418 2010-06-01 12:30
    关注

    After I did some research on ORM vs Active Record. For my situation I didn't find a lot of help by switching to ORM will help me better.

    I found out that ORM is not do very in READ data. But good in Create, Update, and Delete.

    My current solution is every model recompile the my own OR_WHERE() / AND_WHERE(), before pass to the $this->db->query(). It is more easy to maintain and customize.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥20 求个正点原子stm32f407开发版的贪吃蛇游戏
  • ¥15 正弦信号发生器串并联电路电阻无法保持同步怎么办
  • ¥15 划分vlan后,链路不通了?
  • ¥20 求各位懂行的人,注册表能不能看到usb使用得具体信息,干了什么,传输了什么数据
  • ¥15 个人网站被恶意大量访问,怎么办
  • ¥15 Vue3 大型图片数据拖动排序
  • ¥15 Centos / PETGEM
  • ¥15 划分vlan后不通了
  • ¥20 用雷电模拟器安装百达屋apk一直闪退
  • ¥15 算能科技20240506咨询(拒绝大模型回答)