MySQL Cascade on Update and Delete

 

ALTER TABLE `material_storage_actions` ADD CONSTRAINT `fk_materialStorageActions_idSubscriber`
FOREIGN KEY (`idSubscriber` )REFERENCES `tbl_subscriber` (`idSubscriber` )
ON DELETE CASCADE ON UPDATE CASCADE

 

This can only be used on InnoDB tables

Creating SEO friendly URL using htaccess

TweetCreating SEO friendly URL requires a knowledge on how htaccess works. Not just that, you should also be familiar with Regular Expressions but I won’t cover that one in this post though since we’ll be focusing on putting those in htaccess. Now, let’s get our hands dirty. For example: http://mysite.com/profile.php?username=JuanDelaCruz If you wanted that one…

How to create a zip file in PHP

TweetHowdy! I will show you how to create a zip file in PHP. All the directory in your server will also be zipped in the code. I will use the ZipArchive class in php. It’s easy as 1 2 3 function ListFiles($dir) { if($dh = opendir($dir)) { $files = Array(); $inner_files = Array(); while($file = readdir($dh))…

Displaying all database records in a dropdown in Yii

TweetI will show you how to display all database records of a certain table in a dropdownlist in Yii. Model Code: class UserType extends CActiveRecord { public function GetUserType(){ $connection=Yii::app()->db; $command= $connection->createCommand("SELECT * FROM ".$this->tableName()); $rows = $command->queryAll(); return CHtml::listData($rows,'id', 'type'); } } View Code: echo $form->dropDownList($model,'user_type_id',UserType::model()->GetUserType()); The CHTML::listData() takes 3 parameters. 1st is the…

Yii Date validation in rules

TweetHere’s how to specify a date validation rules in the Model. The idea here is that “Date To” should always be greater than “Date From”. Here’s how to do that public function rules() { return array( array( 'date_to','compare','compareAttribute' => 'date_from','operator'=>'>', 'allowEmpty'=>'false', 'message' => '{attribute} should be greater than "{compareValue}".'), ); } Piece of cake eh?…

Implementing Paypal Subscription API in PHP

TweetI’m working on implementing Paypal Subscription API in PHP for the past weeks, I thought this was kinda complicated just like the DirectPayment method API. Guess what, it was just a piece of cake, i’ll show you my code: <form name="_xclick" id="_xclick" action="https://www.paypal.com/cgi-bin/webscr" method="post"> <input type="image" src="http://www.paypal.com/en_US/i/btn/btn_subscribe_LG.gif" border="0" name="submit" alt="Make payments with PayPal – it's…

About Elson...
Elson Solano is a computer programmer/web developer from The Philippines.
He is a great guy who loves to learn from the experts, so if you wish to share something feel free to contact him.
Spending time with his love-ones and hitting the gym is what he does whenever he's not in front of a square object (monitor).

Stackoverflow.com Profile profile for Elson Solano on Stack Exchange, a network of free, community-driven Q&A sites
Advertisements
Stuff you might be interested
Your Ad Here
Know how Techs