Quantcast
Browsing all 60 articles
Browse latest View live

yii, Executing a SQL without calling a Model

yii, Executing a SQL without calling a Model<?$connection=Yii::app()->db;$sql="SELECT id,username FROM users";$command=$connection->createCommand($sql); $dataReader=$command->query();...

View Article


yii, mode rule for unique composite key

Here is the code to to make a rule in the model file to make unique composite keys :Save code below as proctected/components/CompositeUniqueKeyValidator.php<?php/** * CompositeUniqueKeyValidator...

View Article


yii, some form validation examples

Yii some basic form validations using rules in modelslike email, compare password (match password), date, unique, captcha etcBelow is full model code:<?php/** * This is the model class for table...

View Article

yii, best way to call jquery, js and css files

Yii, Best pratice to include jquery, js and css files :<?php Yii::app()->clientScript->registerCoreScript('jquery'); ?><?php...

View Article

Yii, Ccaptcha. Captcha image doesnt show

Yii CcaptchaCaptcha refers to the imagery device ment to capture bots attempting to fill out your forms for automatic spam submission. It auto generates images with codes that users have to input to...

View Article


mysql, import sql file from command line

Method 1:A quick way to duplicate MySQL databases is to do the following:Step 1: Dump the database either through PHPMyAdmin’s export form or through mysqldump (as I mentioned above). Note (usually,...

View Article

YII, my sample model for search with relataionship

A model file for yii which has search fucntion which searches using relation ship:<?php/** * This is the model class for table "sf_category_slider". * * The followings are the available columns in...

View Article

yii, handling image uploads

In Model file function rules() :<?phparray('product_image_1, product_image_2, product_image_3', 'file', 'types'=>'jpg, gif, png', 'allowEmpty'=>true),?>In View file set form like this...

View Article


yii, form, create drop down with values from a model

yii, form, create drop down and populate it with values from any model :Use code below in the view file inside the form:<?php echo...

View Article


YII, get name of the called controller action

YII, get name of the called controller action:<?phpprint CController::getAction()->id ;?>

View Article

YII, get current page url

YII, get current page URL Yii::app()->request->requestUri

View Article

YII, display model errors

Yii, display model errors :print_r($model->getErrors());

View Article

yii, extension to use for image thumbnail generation

yii, extension to use for image thumbnail generation :http://www.yiiframework.com/extension/justintimeimageresizer/And this extension requires this extension :http://www.yiiframework.com/extension/image/

View Article


Yii, return to previous url after login or logout

If you want to return to your previous url after login or logout try this :<?php$this->redirect(Yii::app()->request->urlReferrer);?>To set the return url to be the url that was before...

View Article

YII, How to get current controller name and action name

To get current controller name use this code :<?php$controllerId= Yii::app()->controller->id;//or$controllerId=$this->getId();?>To get current action name/id being executed, if you are...

View Article


Yii, how to add current date or time or timestamp in DB field automatically

To add current date or time or timestamp in DB field automaticallyUsing Rules in model use it like below :<?php/** * @return array validation rules for model attributes....

View Article

MySQL and UTF-8

NotesGood support from 4.1utf-8 is utf8 in MySQL.A collation defines the sort order for the data, it may be case sensitive or notTo find out your current setup:SHOW VARIABLES LIKE...

View Article


yii widgets.CDetailView show HTML

<?php $this->widget('zii.widgets.CDetailView', array(  'data'=>$model,  'attributes'=>array(  'visit_feedback:html',  ...),

View Article

Yii, update record (update query) method

Update By Primary KeyModel::model()->updateByPk($Model->id,array("status"=>'ok')); Update All...

View Article

PHP remove hidden characters from text

PHP remove hidden character like line breaks and tabs and hidden character like following:$description=ereg_replace( "\r\n", "", $row['short_description']);$description=ereg_replace( "\r\t", "",...

View Article
Browsing all 60 articles
Browse latest View live