简体   繁体   中英

A single function for select query in a project its execution or loading time is fast or slow

I am working on codeigniter project.

  1. I am making a "common_model" php page in codeignite project-->application->models and using a method(getSingleRow) for select only a row from tables(any table just like student, users,admin,employee). ex.

     public function getSingleRow($table_name,$where){ $this->db->where($where); $query = $this->db->get($table_name); return $query->row(); } $where is using for columns where condition data. 
  2. I have second project=>student,users,admin,employee section in my project. every section i am making different model page and different method for select query. ex. For student application->models->student_model php page and method is this.

     public function getStudentSingleRow($where){ $this->db->where($where); $query = $this->db->get('student_table'); return $query->row(); } 

and just like using for all section(admin,users,employee) for model page and method.

My question is which coding functionality is working faster first(1) or second(2)?

if i have 1100k users 50k employees and 100k students in different tables and more tables. i am using mysql server.

The only difference is the marginally small amount of memory you use when passing and storing the variable table_name otherwise the two are functionally and speed wise the same.

Also $this->db->where->($where); should be $this->db->where($where); .

As a matter of course I would stray away from the first approach as it is less maintainable is a specific table schema changes. Better to introduce a model for each student , admin , .etc.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM