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 Articleyii, 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 Articleyii, 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 Articleyii, 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 ArticleYii, 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 Articlemysql, 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 ArticleYII, 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 Articleyii, 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 Articleyii, 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 ArticleYII, get name of the called controller action
YII, get name of the called controller action:<?phpprint CController::getAction()->id ;?>
View Articleyii, 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 ArticleYii, 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 ArticleYII, 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 ArticleYii, 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 ArticleMySQL 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 Articleyii widgets.CDetailView show HTML
<?php $this->widget('zii.widgets.CDetailView', array( 'data'=>$model, 'attributes'=>array( 'visit_feedback:html', ...),
View ArticleYii, update record (update query) method
Update By Primary KeyModel::model()->updateByPk($Model->id,array("status"=>'ok')); Update All...
View ArticlePHP 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