⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

Problem with search in a set_relation



vecais
  • profile picture
  • Member

Posted 02 December 2013 - 08:49 AM

Hi everyone,

 

This is my problem.

 

 

1) I have a set_relation:

 

$crud->set_relation('code','table_products,'{code}--{name}');               

 

[attachment=725:rec1.PNG]

 

 

So,

 

[attachment=726:rec2.png]

 

 

2) I search by the "de" string and this is the result:

 

 

[attachment=727:rec3.png]

 

This works fine!

 

4) But now, if I search for this string "saco" (for example)

this is the result:

 

[attachment=729:rec5.png]

 

Not show any result,

 

but however there are records with the string:

 

[attachment=728:rec4.png]

 

 

I don´t understand the problem...

 

Thanks,

 


Robert
  • profile picture
  • Member

Posted 03 December 2013 - 10:04 AM

From what i see you have U.-Saco so GC takes it as 1 word try to mod it to U. Saca and see then ...


vecais
  • profile picture
  • Member

Posted 03 December 2013 - 18:23 PM

Yes, I understand that you say, however in this case, the search shows the word "BEBEDERO" (see next image)

 

[sharedmedia=core:attachments:727]
 
and is 1 word, and the search string is "de" and works fine.
 

In your approach, if I search "saco" and the 1 word is: "U.-SACO" should list it..

 

Even so, I have tried to do as you say, and if found. Is there a problem the "-" char??

 

 

Thank you for your reply,

Amit Shah
  • profile picture
  • Member

Posted 04 December 2013 - 06:50 AM

Hi there,

 

What you might be searching is "saco" might be english word and what might be in table would be in language other then english... try doing a copy paste and see if it still finds a same issue.. if so. theres something to lookup for .. else its the linguistinc issue we looking at


vecais
  • profile picture
  • Member

Posted 04 December 2013 - 07:35 AM

Hi,

 

Sorry, I don´t understand you...

 

I think that isn't a problem the language, because I undestand that the search must be a select in the table with the input string, likes this:

"select field_1, field_2, .... from my_table where field_x likes '%string_input%s' "

 

I try copy+paste, that you say, but it doesn´t show any result.

 

However, this is my opinion, and I don´t know that it works really.

 

Regards,


heruprambadi
  • profile picture
  • Member

Posted 18 December 2016 - 14:28 PM

Any solution ? I have exactly the same problem.


buoncri
  • profile picture
  • Member

Posted 19 December 2016 - 10:18 AM

In my experience the problem is in the string that you have.

 

Es. "U.-SACO" is like a unit. If I am searching for saco, it will not appear becouse the search don't recognize the word in the middle of a string but from the starting point of the string. For searching what you want try to type "U.-s" ... One solution can be to divide this string in " U.-(space)SACO".

 

Es.2 in my index i have number with initial zero like 0675 so to find you have to search starting with zero. Typing 06, will find all 06* strings, typing 675 is finding nothing.


Amit Shah
  • profile picture
  • Member

Posted 21 December 2016 - 08:08 AM

Hi,

 

Sorry  - was damn busy with project work.. hardly get time for myself. .. anyways - i am sharing u a solution for the same... You know what happens up in GC for relations.. when we try to search - it still fails to search through the text values being shooted.

 

Here - i am sharing a solution that i worked out for the same solution... say i have a field partner_assigned_to (that is an id representing to an employee)

Now when displaying the partner_Assigned_to - i display emp_first_name and emp_last_name merged. Now i have to search the text from user in both this fields ...so here is what i do...

 

(Sorry - i worked out this solution on bootstrap theme where user can search for an individual search box for each field. Let's first go through the code solution below - then we will go ahead with other solution)

               /* Controller Code */
		if(isset($_POST['search_field']))  {
			$searchFields = $_POST['search_field'];
			$searchValues = $_POST['search_text'];
			$key = array_search('partner_assigned_to', $searchFields);
			if($key !== false) {
				$searchFields[$key] = 'emp_first_name';
				$_POST['search_field'] = $searchFields;
			}
		}

//In case the we encountered the search field to be partner_assigned_to ..... what we do is - add emp_first_name 
//to the searchFields instead of partner_assigned_to -- now it will work for same - because that field is available 
//as the reason for relationship

//Now here is the trick if u have a multiple fields merged up just in case like i have had for my project.
//If we encounter - the search field to have emp_first_name ... we also include and OR_like for emp_last_name...

		if(isset($_POST['search_field']))  {
			$searchFields = $_POST['search_field'];
			$searchValues = $_POST['search_text'];
			$key = array_search('emp_first_name', $searchFields);
			if($key !== false) {
				$crud->or_like('trade_partners.emp_last_name', $searchValues[$key]);
			}
		}

This way we encounter the solution for  relation ship in the bootstrap theme.

 

Now in case of flexigrid,  there may not be a case of search_fields being set up ... in such scenario - we can just add up 

$crud->or_like($someTextFieldNameForRelation) ... this will ensure that the text is not only search in the values in the current table .. but also related tables.

 

Happy GCing to you all :)