Download the PHP package ynamics/relatedsearchbehavior without Composer

On this page you can find all versions of the php package ynamics/relatedsearchbehavior. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package relatedsearchbehavior

yii-relatedsearchbehavior

Yii Extension - RelatedSearchBehavior

  1. Requirements
  2. Forum
  3. Usage
  4. History
  5. Resources

Creating CGridViews with related tables or getting fields from related tables is simplified with this behavior. It magically adds the needed 'with' clauses and provides aliases to fields of records in the relations.

Live demo

Uses the KeenActiveDataProvider extension to limit the number of requests to the database.

Requirements ¶

Used with Yii 1.1.12-1.1.26 versions.

Forum ¶

A Forum thread is available for this extension.

Usage ¶

To use this extension you must do 5 steps:

  1. "Install" the RelatedSearchBehavior;
  2. Update the Model's search() method;
  3. Add/Update the 'behaviors()' method;
  4. Add the search fields to the Model rules as safe fields;
  5. Use the search field as any other field in the CGridView.

Here are the details for these steps:

1. "Install" the RelatedSearchBehavior; ¶

Installation is as easy as adding the location to the 'import' configuration of the Yii configuration file (main.php):

In the above the RelatedSearchBehavior file was placed in the extensions directory.

2. Update the Model's search() method; ¶

Update the overload of ActiveRecord::search(). The following example shows how you can set the default search order. You can set any parameter accepted by CActiveDataProvider (such as pagination) in the second array. So, replace code like this:

by code like this (I prefer using intermediate variables like '$sort' to improve readability and increase flexibility):

In the above example, 'title' can be one of the related fields that you defined.

3. Add/Update the 'behaviors()' method ¶

Attach the behavior to the CActiveRecord and specifies the related fields.

4. Add the search fields to the Model rules as safe fields; ¶
5. Use the search field as any other field in the CGridView. ¶

For the CGridView column specification, you can then just put 'serial' for the column (no need to do 'name'=>..., 'filter'=>..., 'value'=>... .

Example:

6. To use "autoScope" ¶

Autoscope allows you to search a field using a scope without declaring the scope yourself.

For instance, you can use this:

Before, you have to:

  1. Add RelatedSearchBehavior to the behaviors of your CActiveRecord (already done in the preceding steps,
  2. Add the following generic code to your CActiveRecord Model.

You are allowed to provide all the regular compare parameters:

defaults are the same as compare: autoscope(,false,"AND",false).

This is useful in complex nested conditions, not so much for simple searches like the above.

7. Using relations in CSort's attributes for sorting. ¶

'CSort' allows you to specify 'virtual attributes' for sorting as mentioned in the Yii documentation. Without RelatedSearchBehavior, you must make sure that you include the relations used in the search condition. With RelatedSearchBehavior, you do not need to take care about that - the extension takes care about it for you (since 1.16).

The preferred approach is that you'ld use attributes defined for RelatedSearchBehavior, but this might be useful in combined sort conditions:

8. exactSearchAttributes ¶

When CActiveRecord::exactSearchAttributes is defined in a CActiveRecord, the attributes listed there are matched exactly by default rather than partial. This is particularly useful in combination with tables, and works for columns as well (not just relations). For instance, IDs should not be partially matched, the id "1" would also match 10..19, 21, 31, etc. Requiring an exact match can also improve the performance of the search as this is more appropriate when using an index.

Example:

In the above example:

9. Tips & notes ¶

This is the search method in projects where the author uses this extension. All Models extends from YActiveRecord which extends from CActiveRecord and implements several additions to default CActiveRecord features. It implements the following search method (the RelatedSearchBehavior has to be added to the model class itself):

`php

History ¶

See RelatedSearchbehavior.php for a short description of the versions

Resources ¶


All versions of relatedsearchbehavior with dependencies

PHP Build Version
Package Version
No informations.
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package ynamics/relatedsearchbehavior contains the following files

Loading the files please wait ....