Archive for the ‘Php’ Category

So, plan to change themes dynamically on your page with Yii?? Here is what i do. 1. Add this code to protected/components/Controller.php public $breadcrumbs=array(); public function beforeAction($action)         {             $dynamicTheme = ‘classic’;                      if(isset($_POST['mytheme']))             {                 $dynamicTheme = $_POST['mytheme'];        [...]

If you’re running your application with php 5.2.17, there is memory leak when using active record. The solution either upgrade your php version  to 5.3 (have garbage handling) OR use DAO instead.

Php & Yii :: Read Excel File xlsx Format The basic is from here http://www.yiiframework.com/extension/phpexcel-codeplex/   Installation Download from phpexcel-codeplex Extract the release file under protected/vendors To read the excel xlsx format: Yii::import(‘application.vendors.PHPExcel’,true); $objReader = PHPExcel_IOFactory::createReader(‘Excel2007′); $objPHPExcel = $objReader->load($file); //$file –> your filepath and filename $objWorksheet = $objPHPExcel->getActiveSheet(); $highestRow = $objWorksheet->getHighestRow(); // e.g. 10 $highestColumn = $objWorksheet->getHighestColumn(); // e.g [...]

If you’ve dialog box and tab in one page… let say you have multiple form in your tab, and dialog box outside the tab..When you click a link to open the dialog box from your form, the dialog box didn’t appear.My solution, just add this piece of code at the top of your form inside [...]

1. In your gridview, modify the update button like this:       array(            ‘class’=>’CButtonColumn’,                        ‘template’=>’{update}{delete}’,                        ‘buttons’=>array(                                        ‘update’=>array(                                                      ‘url’=>’Yii::app()->createUrl(“employee/educationUpdate”, array(“id”=>$data->id))’,                                        ),                                    ),        ), 2. Then,add this javascript code:       $(‘.update’).click(function(){                 var url=$(this).attr(‘href’);                eduUpdate(url); //this function is used to open dialog box *write your own dialog box*                return false;        });

Yii vs Zend vs Code Igniter

Posted: January 7, 2011 in Php, Yii Framework

Yii vs Zend vs Code Igniter Choosing a PHP framework is not an easy task, especially if you have relatively little experience in PHP to know what makes a good framework or and what doesn’t, but choosing the right PHP framework for the job is absolutely critical in the long term as choosing the wrong [...]

Error: Yii dialog box – dialog is not a function In Controller:$this->renderPartial(‘problemDetails’,array(                         ‘modelProblem’=>$modelProblem,                        ),false,true ); Then, add this script inside your partial view. <span class=”typ”>Yii</span><span class=”pun”>::</span><span class=”pln”>app</span><span class=”pun”>()-></span><span class=”pln”>clientScript</span><span class=”pun”>-></span><span class=”pln”>scriptMap</span><span class=”pun”>=</span><span class=”pln”>array</span><span class=”pun”>(</span><span class=”pln”>          </span><span class=”com”>//scripts that you don’t need inside this view</span><span class=”pln”>         </span><span class=”str”>’jquery.js’</span><span [...]

Server2Go PDO error connection

Posted: October 20, 2010 in Php, Uncategorized

Server2Go PDO error connectionError message:Warning: PDO::__construct() [pdo.--construct]: [2002] A connection attempt failed because the connected party did not (trying to connect via tcp://localhost:3306) in on line # Fatal error: Maximum execution time of 60 seconds exceeded in on line # Solution:Change the ‘localhost’ to 127.0.0.1 $dsn = “mysql:host=127.0.0.1;port=$S2G_MYSQL_PORT;dbname=haulagemy”;$username = “root”;$password = “”; try {        [...]

Standalone Php application and browsing from anywhere webserver apache,php and mysql. Server2Go is a Webserver that runs out of the box without any installation and on write protected media. This means that web applications based on Server2Go can be used directly from cdrom, a usb stick or from any folder on a hard disk without [...]

PHP Get previous month and end day of last month //Get previous month and year $lastmonth = date(“Y-m”,mktime(0, 0, 0, date(“m”)-1, date(“d”), date(“Y”))); //eg .output 2010-09 //Get end date of previous month (use ‘t’) $endDateOfLastMonth = date(“Y-m-t”, strtotime(“last month”)); //eg. output 2010-09-30