Re: DB_DataObjects and generating search filters

From: Date: Thu, 21 Apr 2005 01:41:06 +0000
Subject: Re: DB_DataObjects and generating search filters
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-18844@lists.php.net to get a copy of this message
If I understand your question correctly, you can't do this by simply setting the fields on the DB_DataObject, as it wont know to do anything other than an equality comparison (and combine with AND). However, you can call $data_object->whereAdd(). -------------- /** * Adds a condition to the WHERE statement, defaults to AND * * $object->whereAdd(); //reset or cleaer ewhwer * $object->whereAdd("ID > 20"); * $object->whereAdd("age > 20","OR"); * * @param string $cond condition * @param string $logic optional logic "OR" (defaults to "AND") * @access public * @return string|PEAR::Error - previous condition or Error when invalid args found */ function whereAdd($cond = false, $logic = 'AND') --------------- Note that this means that your values are not automatically escaped, meaning that they may have quotes in them or something (or worse, malicious user entered SQL statements). I believe that an example of the correct technique to use value from $_POST (providing magic quotes was off) would be something like: $my_field_value = $data_object->escape($_POST['field']); $data_object->whereAdd("my_field_name LIKE = '%$my_field_value%'", 'OR'); regards, Craig On Thu, 21 Apr 2005 11:26 am, pear@electroteque.org wrote: > Hi there I am up to generating search filters from post vars, I was > wondering how I could do the following , use a setter method for a few > fields in particular I would like to use fulltext match against search > rather than field='' and also give the user the option for an OR search > aswell as AND , is this possible ? -- Craig Ambrose Web Elements http://www.portallus.com/people/craigambrose/

« previous php.pear.general (#18844) next »