common/services/base/ActiveRecordService.php
public static function generateSearchQuery( $columns, $searchTerms ) {

		$searchTerms	= preg_split( '/,/', $searchTerms );
		$searchQuery	= "";

		// Multiple columns
		if( is_array( $columns ) ) {

			foreach( $columns as $ckey => $column ) {

				$query	= null;

				foreach( $searchTerms as $skey => $term ) {

					if( $skey  == 0 ) {

						$query = " $column like '%$term%' ";
					}
					else {

						$query .= " OR $column like '%$term%' ";
					}
				}

				if( isset( $query ) ) {

					if( $ckey  == 0 ) {

						$searchQuery =	"( $query )";
					}
					else {

						$searchQuery .= " OR ( $query )";
					}
				}
			}
		}
		// Single column
		else {

			foreach( $searchTerms as $key => $value ) {

				if( $key  == 0 ) {

					$searchQuery .= " $columns like '%$value%' ";
				}
				else {

					$searchQuery .= " OR $columns like '%$value%' ";
				}
			}
		}

		return $searchQuery;
	}
public static function generateSearchQuery( $columns, $searchTerms ) {

		$searchTerms	= preg_split( '/,/', $searchTerms );
		$searchQuery	= "";

		// Multiple columns
		if( is_array( $columns ) ) {

			foreach( $columns as $ckey => $column ) {

				$query	= null;

				foreach( $searchTerms as $skey => $term ) {

					if( $skey  == 0 ) {

						$query = " $column like '%$term%' ";
					}
					else {

						$query .= " OR $column like '%$term%' ";
					}
				}

				if( isset( $query ) ) {

					if( $ckey  == 0 ) {

						$searchQuery =	"( $query )";
					}
					else {

						$searchQuery .= " OR ( $query )";
					}
				}
			}
		}
		// Single column
		else {

			foreach( $searchTerms as $key => $value ) {

				if( $key  == 0 ) {

					$searchQuery .= " $columns like '%$value%' ";
				}
				else {

					$searchQuery .= " OR $columns like '%$value%' ";
				}
			}
		}

		return $searchQuery;
	}
public static function generateSearchQuery ( $ columns , $ searchTerms ) { $ searchTerms = preg_split ( '/,/' , $ searchTerms ) ; $ searchQuery = "" ; // Multiple columns if ( is_array ( $ columns ) ) { foreach ( $ columns as $ ckey => $ column ) { $ query = null ; foreach ( $ searchTerms as $ skey => $ term ) { if ( $ skey == 0 ) { $ query = " $column like '%$term%' " ; } else { $ query .= " OR $column like '%$term%' " ; } } if ( isset ( $ query ) ) { if ( $ ckey == 0 ) { $ searchQuery = "( $query )" ; } else { $ searchQuery .= " OR ( $query )" ; } } } } // Single column else { foreach ( $ searchTerms as $ key => $ value ) { if ( $ key == 0 ) { $ searchQuery .= " $columns like '%$value%' " ; } else { $ searchQuery .= " OR $columns like '%$value%' " ; } } } return $ searchQuery ; }
It generate search query for specified columns by parsing the comma separated search terms
It generate search query for specified columns by parsing the comma separated search terms