Welcome Guest, Not a member yet? Register   Sign In
Passing a single array to a model
#8

[eluser]TheFuzzy0ne[/eluser]
[quote author="xwero" date="1236710237"]why not use the parameters like some of the CI functions do
Code:
function get($field, $val='')
{
   if(is_string($field) && strlen($val)>0)
   {
      $field = array($field=>$val);
   }

   if( ! is_array($field))
   {
      return array();
   }

   $this->db->where($field);
   $query = $this->db_>get('table');

   return $query->result();
}
[/quote]

That was one of my thoughts, but I don't know whether or not it's considered a good way to do things, and also, I'm not sure. What if we needed to add limits and order by clauses into the mix? Perhaps I should just do this with CRUD? I tried using CRUD in the past, and we got along like Bill Gates using Linux... Perhaps it's time for me to start again? The trouble I had with crud was how to deal with multiple tables. Maybe it would just be easier for me to write a separate function for each case, and once everything is working, look towards optimising the code?

Thanks for your comments.


Messages In This Thread
Passing a single array to a model - by El Forum - 03-08-2009, 12:40 PM
Passing a single array to a model - by El Forum - 03-10-2009, 06:59 AM
Passing a single array to a model - by El Forum - 03-10-2009, 07:18 AM
Passing a single array to a model - by El Forum - 03-10-2009, 07:30 AM
Passing a single array to a model - by El Forum - 03-10-2009, 07:35 AM
Passing a single array to a model - by El Forum - 03-10-2009, 07:37 AM
Passing a single array to a model - by El Forum - 03-10-2009, 07:43 AM
Passing a single array to a model - by El Forum - 03-10-2009, 07:48 AM
Passing a single array to a model - by El Forum - 03-10-2009, 08:36 AM
Passing a single array to a model - by El Forum - 03-10-2009, 08:50 AM
Passing a single array to a model - by El Forum - 03-10-2009, 08:55 AM
Passing a single array to a model - by El Forum - 03-10-2009, 09:13 AM
Passing a single array to a model - by El Forum - 03-10-2009, 09:47 AM
Passing a single array to a model - by El Forum - 03-10-2009, 09:53 AM
Passing a single array to a model - by El Forum - 03-10-2009, 10:35 AM
Passing a single array to a model - by El Forum - 03-10-2009, 10:53 AM
Passing a single array to a model - by El Forum - 03-10-2009, 11:23 AM
Passing a single array to a model - by El Forum - 03-10-2009, 11:42 AM



Theme © iAndrew 2016 - Forum software by © MyBB