Back to Code repository sumary
This is an improved way to do searching in a table, when the table contains joins (the standard proposed way generates some troubles).
I propose this replacement for the “search” function to be written in your mask:
... function search() { // for example $value = $this->txtSearch->getNewValue(); $where = ""; // I assume here that you have create an array containing the names of // all the visible columns in your table foreach($this->visibleColumnsInTable as $name) { if ($this->_use_fields_aliases) { foreach($this->src->getFields() as $field_name=>$field_alias) { if ($field_alias == $nom) { $name = $field_name; // should break here, but I don't know enougth PHP to do it ;) } } } if ($where !== "") $where = $where . " or "; $where = $name . " like '%{$value}%'"; } $this->src->setWhere($where); $this->src->firstRow(); $num_rows = $this->src->getNumRows(); if (!$num_rows) { // Say user there is no result corresponding to his search $this->message->setValue(__("No results were found")); // Cancel the search criteria $this->src->setWhere(null); // Show again all datas $this->src->firstRow(); } } ...
2007-01-15: Please ask question in forum, and say comments after here - thank’s - pespie