How configure php in environment varible for windows?


To configure php in environment variable for windows,just run below code with current wamp path in command prompt:

SET PATH=%PATH%;C:\your\wamp\path\php

C:\>php -a
Interactive mode enabled
<?php
echo 'pppp';
echo "hello world";
?>
^Z
echo 'pppp';
hello world

to finish the code with <?php and end ?> to run the code just (^z) Press control button + (z) button.
Tagged with: , , , , , ,
Posted in php

yii onchange ajax validation issue(cleared)


I was working the yii project in which i have update form ,where the data are  populated from controller to view allow model data to controller render function in yii.I had reset button in which default worked ,but as i update the form empty madtory field raised validation issue as i clicked the reset button it didnt restored the mandatory field.so assigned copy model varible by calling  findByPk

Eg:

Controller:
$id = $_REQUEST['id'];
$modelular= Milestones::model()->findByPk($id);
$this->render('update',array(
 'model'=>$model,
 'users'=>$Users,
 'allowEdit'=>$allowEdit,
 'copymodel'=>$copymodel,
 ));
View:
javascript function to reset the update form.
 $("#resetform").click(function(e) {
 e.preventDefault();//used rectifier the jquery issue
 $(".errorMessage").text("");
 $(".errorMessage").hide();
 $(".betterform").removeClass("error")
 $(".required").removeClass("error")
 // $("#milestones-form").trigger('reset');
 $("#Milestones_milestone_title").val("<?php echo $copymodel->milestone_title; ?>");
 $("#Milestones_milestone_description").val("<?php echo $copymodel->milestone_description; ?>");
 $('#Milestones_milestone_startdate').datepicker('setDate', "<?php echo date('d-m-Y',strtotime($copymodel->milestone_startdate));?>");
 $("#Milestones_milestone_duedate").datepicker('setDate', "<?php echo date('d-m-Y',strtotime($copymodel->milestone_duedate));?>");
 });

Onchange Issue:

Then comes the testing department issue that form does hides the validation msg after filling the input fields.

Controller:
just added code in controller function.
 $this->performAjaxValidation($model);
View :
<?php $form=$this->beginWidget('CActiveForm', array(
 'id'=>'milestones-form',
 'enableAjaxValidation'=>true,
 'enableClientValidation'=>true,
 'clientOptions'=>array(
 'validateOnChange'=>true,
),
)); ?>

<?php
 echo $form->textField($model,'milestone_title',array('class'=>'betterform','style'=>'width:95%','maxlength'=>100,'tabindex'=>1));
 // echo CHtml::label(Yii::t('milestones','FormMilestoneTitle'), CHtml::activeId($model, 'milestone_title'), array('class'=>'labelhelper'));
 echo $form->error($model,'milestone_title',array('validateOnChange'=>true));
 ?>
Tagged with: , , , , , , , , , , , ,
Posted in yii framwork

speed test to class with public variable and function vs static variable and function


Currently refreshing the oops concept in php as i worked in drupal cms which almost functional oriented derived cms.

public variable and function inside class:

   /**
 *
 * Used to list the brands in the car
 * class:car
 * function:carlist()
 *
 */
class car {
    var $car = array('benz'=>'benz','mahinder'=>'mahinder','bmw'=>'bmw','honda'=>'honda','hundai'=>'hundai','tata'=>'tata');
        public function carlist(){
        return $this->car['benz'].' </br> '. $this->car['mahinder'].' </br> '. $this->car['bmw'].' </br> '. $this->car['honda'].' </br> '. $this->car['hundai'].' </br> '. $this->car['tata'].' </br> ';
        
    }    
    
}
$startTime = microtime(true);
$car = new car;
echo $car->carlist();
echo "Time:  " . number_format(( microtime(true) - $startTime), 5) . " Seconds\n";

Result:

Time: 0.00003

static variable and function inside class:

/**
 *
 * Used to list the brands in the car
 * class:car
 * Varible Type:static
 * function Type:static
 * function:carlist()
 *
 */
class cars {
    static $car = array('benz'=>'benz','mahinder'=>'mahinder','bmw'=>'bmw','honda'=>'honda','hundai'=>'hundai','tata'=>'tata');
        static function carlist(){
        return cars::$car['benz'].' </br> '. cars::$car['mahinder'].' </br> '. cars::$car['bmw'].' </br> '. cars::$car['honda'].' </br> '. cars::$car['hundai'].' </br> '. cars::$car['tata'].' </br> ';
        
    }    
    
}
 $startTimes = microtime(true);
echo  cars::carlist();
echo "Time:  " . number_format(( microtime(true) - $startTimes), 5) . " Seconds\n";

Result:

Time: 0.00001

Tagged with: , , , , , , ,
Posted in php

datatable jquery : how to create table and display link on hover table row?


The datatable is jquery  plugin to create table and consist many functionality to do any thing with the table.Recently i was assiggned to drupal in which we used DataTables module to create table and call rest service populate data in table.I have created table and populated the array to table and appended link on hover of table row.


 

example.html

<div id = "demo" class="pane-inner-content team-logos-pane" >
<table id="example" class="hover">
 <thead>
 <tr><th> Name</th><th>Url </th><th>Type</th><th>Last modified</th><th>sxdsdadw</th></tr>
 </thead>
 <tbody>
 </tbody>
</table>
</div>


example.js

var table = $("#example").dataTable({
 "bPaginate": false,
 "bLengthChange": false,
 "bFilter": false,
 "bInfo": false,
 "bAutoWidth": false,
 "sDom": 'T<"clear">lfrtip',
 "aaData":[
 ["Sitepoint","http://sitepoint.com","Blog","2013-10-15 10:30:00","http://sitepoint.com"],
 ["Flippa","http://flippa.com","Marketplace","null","http://sitepoint.com"],
 ["99designs","http://99designs.com","Marketplace","null","http://sitepoint.com"],
 ["Learnable","http://learnable.com","Online courses","null","http://sitepoint.com"],
 ["Rubysource","http://rubysource.com","Blog","2013-01-10 12:00:00","http://sitepoint.com"]
 ],
 "aoColumnDefs": [
 { "aTargets": [0]},
 {
 "aTargets": [ 1 ],
 "bSortable": false,
 "mRender": function ( url, type, full ) {
 
 return '<a href="'+url+'">' + url + '</a>';
 }
 },
 { "aTargets": [2]},
 { "aTargets": [3]},
 {
 "aTargets": [ 4 ],
 "bSortable": false,
 
 "mRender": function ( url ) {
 return '<a class="button">Hello yes this is dog</a>';
  }
 },
 
 ],
 
 });

example.css

 table#example tr td a.button { display:none;}
 table#example tr:hover td a.button { display:inline-block;}
Tagged with: , , , , , , , , ,
Posted in Practice Makes a beginner to become php programmer expert(practical task to become php programmer)

Drupal 7 :Hello World Module


Tagged with: , , , ,
Posted in Drupal
Follow php tutorial on WordPress.com
categories
Calendar
July 2015
M T W T F S S
« Jun    
 12345
6789101112
13141516171819
20212223242526
2728293031  
Follow me on Twitter
Blog Stats
  • 61,538 hits
Follow

Get every new post delivered to your Inbox.

Join 42 other followers

%d bloggers like this: