Skip to main content

Posts

Model in Cakephp

Models are the classes that sit as the business layer in your application. This means that they should be responsible for managing almost everything that happens regarding your data, its validity, interactions and evolution of the information workflow in your domain of work.   Define Model App :: uses ( ’AppModel’ , ’Model’ ); class Member extends AppModel {           var $name='Member'; } Association in Model 1#  HasOne : One to one relation with two tables public $hasOne = array ( ’Profile’ => array ( ’className’ => ’Profile’ , ’ foreignKey’ => ’user_id’ , ’dependent’ => true ) ); Notes:  Here foreignKey founds in the other model. 2#  HasMany: One to many var $hasMany=array(           'BusinessHours'=>array(  'className'=>'BusinessHours',           ...

Yii installation in xampp Server

Step 1:  Download the yii-1.1.14.f0fee9.tar file from http://www.yiiframework.com/ Step 2: Now click on download Step 3 : Unzip & rename the file , put on web directory C:\xampp\htdocs Step 4 : Run cmd write 1: C:\Users\sid>cd\ 2: C:\> cd xampp\htdocs\yii Note: here yii is the rename folder name 3: C:\xampp\htdocs\yii>framework\yiic '"php.exe"' is not recognized as an internal or external command, operable program or batch file. Note: now open the yiic batch file in framework & edit this  set YII_PATH=%~dp0 if "%PHP_COMMAND%" == "" set PHP_COMMAND=C:\xampp\php\php.exe "%PHP_COMMAND%" "%YII_PATH%yiic" %* 4: C:\xampp\htdocs\yii>framework\yiic 5: C:\xampp\htdocs\yii>framework\yiic webapp Now specific the path  6:  C:\xampp\htdocs\yii>framework\yiic webapp C:\xampp\htdocs\yiiTest write yes Note: yiiTest is folder name of application  you can also watch video. ...

Define Variable Path in Php & jQuery

How to define path in Php 1: define it in core.php file in cakephp define('HTTP_ROOT','http://'.$_SERVER['HTTP_HOST'].'/'); 2: define third-party url in expression engine define('HTTP_THIRD_PARTY','https://'.$_SERVER['HTTP_HOST'].'/system/expressionengine/third_party/'); 3. defines route path in cakephp  Router::connect('/', array('controller' => 'Homes', 'action' => 'index')); Router::connect('/admin', array('controller' => 'users', 'action' => 'login', 'prefix' => 'admin', 'admin' => true, 'layout' => 'default')); How to define path in jQuery var host = window.location.host; var proto = window.location.protocol; var ajax_url = proto+"//"+host+"/";

MySql join

INNER JOIN (or just JOIN) The most frequently used clause is INNER JOIN. This produces a set of records which match in both the user and course tables, i.e. all users who are enrolled on a course: SELECT user.name, course.name FROM `user`INNER JOIN `course` on user.course = course.id; Result: user.name course.name Alice HTML5 Bob HTML5 Carline CSS3 David MySQL LEFT JOIN What if we require a list of all students and their courses even if they’re not enrolled on one? A LEFT JOIN produces a set of records which matches every entry in the left table (user) regardless of any matching entry in the right table (course): SELECT user.name, course.name FROM `user` LEFT JOIN `course` on user.course = course.id; Result: user.name course.name Alice HTML5 Bob HTML5 Emma (NULL) RIGHT JOIN Perhaps we require a list all courses and students even if no one has been enrolled? A RIGHT JOIN produces a set of records which matches every entry in the right table (course) regardless of any matching entry in ...

MySql Storage Engine

Change table engine to MyISAM ALTER TABLE `tableName` ENGINE = MYISAM Change table engine to innodb ALTER TABLE `tableName` ENGINE = innodb How to create table to MYISAM mysql> CREATE TABLE table2 (col1 INT, col2 CHAR(30)) ENGINE = MYISAM; Features of MYISAM and INNODB Feature InnoDB MyISAM Storage limits 64TB 256TB Transactions Yes No Locking granularity Row Table MVCC Yes No B-tree indexes Yes Yes Clustered indexes Yes No Data caches Yes No MyISAM MyISAM doesn’t support foreign key constraints or transactions , which are essential for data integrity. Hence we call MySQL with MYISAM is DBMS MYISAM not supports transaction. You cannot commit and rollback with MYISAM. MYISAM supports Table-level Locking : In addition, the whole table is locked whenever a record is inserted or updated; this causes a detrimental...