Wiki articles in category Tips

Showing 81-100 of 162 items.

Debuging variables in Yii2

Created 9 years ago by johonunu, updated 9 years ago by johonunu.

This tutorial is explained following "basic" application structure.

4 1
8 followers
Viewed: 41 902 times
Version: 2.0
Category: Tips

Saving files to a blob field in the database

Created 13 years ago by zaccaria, updated 13 years ago by zaccaria.

As a follow-up from the How to upload a file using a model wiki entry that explains how to save a file to the filesystem, this article will do the same using a blob field in the database.

6 2
17 followers
Viewed: 79 550 times
Version: 1.1
Category: Tips

An important tip when you are using CArrayDataProvider.

Created 11 years ago by sirin k, updated 6 years ago by Maurizio Domba Cerin.

Yii's CArrayDataProvider is very helpful to display model relation data's directly on it.But it is truely a confusing one because by default it will assume a table field named “id” as primary key for its pagination purpose and what if you dont have field named “id” as primary key on your table? so its truely confusing and if you tried to display without an “id” field on ur table you will get an...

5 1
5 followers
Viewed: 19 748 times
Version: 1.1
Category: Tips

Putting Function To Be Called In View

Created 13 years ago by junxiong, updated 13 years ago by junxiong.

Sometimes we need some complicated view to be displayed (such as generating complicated table). Most people suggest that in MVC the View must be as simple as possible (don't have too much loops, etc). So what we have to do is to hide away the complex code by putting it at somewhere else. The following are few places options to keep the function:

5 1
5 followers
Viewed: 51 812 times
Version: 1.1
Category: Tips
Tags: render, view

How to change GridView delete confirmation message for specific controllers only?

Created 8 years ago by AlaFalaki, updated 8 years ago by AlaFalaki.

Hello,
If you want to give extra attention for some specific delete actions and you don't want to override whole yii.confirm JS method here is what you can do:
(I've only put the ActionColumn part of the GridView here to just give you the idea)

3 0
4 followers
Viewed: 46 067 times
Version: 2.0
Category: Tips

Access log output from unit tests

Created 11 years ago by Mike, updated 11 years ago by Mike.

Say, you want to write a test for a component which provides a caching feature. How would you know, that some method of your component returns a cached result? With the solution described here you can inspect all log outputs. So you could search the logs for accesses to the DB to really make sure, that the result was served from cache.

3 0
2 followers
Viewed: 15 331 times
Version: 1.1
Category: Tips

Using sub query for doubletts

Created 11 years ago by mb, updated 10 years ago by mb.

find doubletts by db fields. in this example i will check doublets for 3 tabelfields (col1,col2,col3). so i will get a subquery with the condition, select and grouping of the tablefields. the having with COUNT() > 1 means: find all records more then one result.

$model=new MyModel('search');
$model->unsetAttributes();

3 0
10 followers
Viewed: 24 976 times
Version: 1.1
Category: Tips

CGridView customized CCheckBoxColumn

Created 10 years ago by chandran, updated 10 years ago by CeBe.

Hi friends,

3 0
6 followers
Viewed: 19 845 times
Version: 1.1
Category: Tips

Auto TDD - How to auto-run PHPUnit

Created 13 years ago by imehesz, updated 13 years ago by imehesz.

If you are lucky enough and have the privilege to develop on a Linux based environment, this little tip might boost-up your TDD process (at least the Unit Testing part). Please note, that this should work just fine with Apple computers also, but not tested!

3 0
6 followers
Viewed: 20 767 times
Version: 1.1
Category: Tips

A simple action for XUpload extension

Created 12 years ago by tydeas_dr, updated 12 years ago by tydeas_dr.

All the basic functionality for an action used by the xupload extension. Check resources for the source code of this action

3 0
5 followers
Viewed: 20 235 times
Version: 1.1
Category: Tips

Key web server settings after installing a fresh Yii 2 basic or advanced app

Created 9 years ago by Kartik V, updated 9 years ago by Kartik V.

So, you have installed a brand new Yii 2 app (basic) or (advanced). Here are a few tips for Apache web server users to get things running more secure and better with your yii2 app.

3 0
46 followers
Viewed: 29 085 times
Version: 2.0
Category: Tips

CGridView: Adding behaviors from configuration, and template items from behaviors to CGridView

Created 11 years ago by le_top, updated 11 years ago by le_top.

Changing the way a CGridView is rendered from the configuration file, or through behaviors specified at the moment it is used, is handy to extend a CGridView without creating tons of different classes for it. I am surprised that this is not in the default implementation, so I made my default CGridView implementation.

3 0
3 followers
Viewed: 14 810 times
Version: 1.1
Category: Tips

an easy way to required multi columns(At least one cannot be blank)

Created 12 years ago by 1065227709, updated 12 years ago by 1065227709.

in model add the following code:

3 0
3 followers
Viewed: 11 591 times
Version: 1.1
Category: Tips
Tags: rules

Inline views, write less

Created 10 years ago by Firebreaker, updated 10 years ago by Firebreaker.

Sometimes writing views like

3 0
3 followers
Viewed: 11 552 times
Version: Unknown (update)
Category: Tips

FORM with GET method causes repeated stacking of URL Parameters

Created 9 years ago by Kartik V, updated 9 years ago by toph.

// In Yii 1.x $form = $this->beginWidget('CActiveForm', [

'id' => 'order-search-form',
'method' => 'get',

]); echo $form->textInput($searchModel, 'id'); echo CHtml::submitButton('Find', ['class' => 'btn btn-primary']); $this->endWidget(); `

7 2
41 followers
Viewed: 61 505 times
Version: all
Category: Tips

Update two models with one view

Created 12 years ago by sensorario, updated 11 years ago by SebK.

Suppose to have two models: Users and Emails. You do not want to store email in a Users model. And User can have 0 or many emails. This is the form generated to create a new user (just username).

9 3
13 followers
Viewed: 55 447 times
Version: 1.1
Category: Tips

Cgridview counter column

Created 10 years ago by Nisanth thulasi, updated 10 years ago by trond.

some times we want to show the serialNo on cgridview .

4 0
8 followers
Viewed: 10 752 times
Version: Unknown (update)
Category: Tips

Managing constants easily

Created 12 years ago by briiC.lv, updated 12 years ago by briiC.lv.

/*

    Get class constants by token.
    If you set constants with same prefix, like:
	MY_STATUS_1
	MY_STATUS_2
	MY_STATUS_3
4 0
7 followers
Viewed: 30 663 times
Version: 1.1
Category: Tips

How to catch and log MySQL deadlock errors

Created 12 years ago by seb, updated 12 years ago by seb.

This method allows to log InnoDB monitor output when deadlock error occured. This way we will have much more useful data to find and fix deadlock.

4 0
7 followers
Viewed: 20 615 times
Version: 1.1
Category: Tips
Tags: database

Get notified about the status of a Facebook user in your web app using periodic Ajax calls.

Created 11 years ago by sirin k, updated 6 years ago by Maurizio Domba Cerin.

hello,

 This article is helpful only if you have the following situation:
 A web app which uses facebook login to login its users and if a user is logged out from his/her facebook account through another browser tab, then your app dont know that he is logged out  out or not from his facebook account and he/she will remain as logged in your web application.Its ok if you have no problem wi...
4 0
6 followers
Viewed: 15 629 times
Version: 1.1
Category: Tips
Tags: facebook, user