Monday, December 25, 2017

How To Delete Child Table's Rows While Deleting Parent Items in Mysql in a Single Request

While working in a php and mysql project I have faced to remove child table's rows while deleting it's parent table's items and here is my solution for such kind of functionality:
 Suppose that I have two tables named user_roles and users:

CREATE TABLE `user_roles` (
      `id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
      `name` varchar(64) NOT NULL
    ) ENGINE=InnoDB DEFAULT CHARSET=latin1;

    CREATE TABLE `users` (
      `id` int(11) NOT NULL AUTO_INCREMENT PRIMARY KEY,
      `name` varchar(128) NOT NULL,
      `address` varchar(255) DEFAULT NULL,
      `email` varchar(128) NOT NULL,
      `password` varchar(64) NOT NULL,
      `role_id` int(11) NOT NULL
    ) ENGINE=InnoDB DEFAULT CHARSET=latin1;


and below is the code to obtain such above functionality:

    ALTER TABLE users
    ADD CONSTRAINT FK_RoleUser
    FOREIGN KEY (role_id) REFERENCES user_roles(id)
    ON DELETE CASCADE


 so now if you delete any row of table user_roles then all the users related to that role id will be deleted automatically. 

Sunday, March 26, 2017

Magento 2 links in admin or backend doesn't work

For the fresh installation of magento2.1.5 I have found some admin url don't work and to overcome such errors here is the solution:

according to my windows platform with xampp setup, I have pointed to magento's bin folder using windows command prompt as below:

 cd c:\xampp\htdocs\magento2\bin> php magento setup:static-content:deploy

after running the above command refresh admin panel or store and it will be resolving broken links issues.

How to run magento commands for windows user?

While working with a magento project in my windows computer I needed to run some magento commands and here is the basic process to do this task:

I have my magento project installed under my xampp server so I need to point that directory using windows command prompt like below:

c:
cd xampp \ htdocs \ magento2 \ bin
C:\xampp\htdocs\magento2\bin> php magento setup:upgrade

in this way we can run magento commands on windows platform.

make sure xampp server has been started prior to run the command.

Wednesday, March 22, 2017

Error The "UnpackLibraryResources" task failed unexpectedly

While working with Xamarin Forms project I face a common error basically for Xamarin iOS project when mac disconnected and error like below:

Severity Code Description Project File Line Suppression State
Error The "UnpackLibraryResources" task failed unexpectedly.

and the solution for it just reconnect the mac pc with visual studio going through Tools -> iOS -> Xamarin Mac Agent. and click on Connect button.

if it doesn't work try to restart the visual studio and it will automatically be connected with Xamarin Mac agent.

Hope it will help someone. 

Sunday, March 5, 2017

Invalid Code Signing Entitlements

While working with Xamarin.iOS project I had faced a deployment problem to iTunes Connect using Application Loader and got the error like below:

Invalid Code Signing Entitlements. Your application bundle's singature contains code signing entilements that are not supported on iOS. Specifially, value 'Development' for key 'com.apple.developer.icloud-container-environment' in 'Payload/YourProject.app

and to overcome such error open file Entitlements.plist from Xamarin.iOS project using Json Editor and add these two lines below:

<key>com.apple.developer.icloud-container-environment</key>
<string>Production</string>

so the complete code example could be:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
 <key>com.apple.developer.icloud-container-environment</key>
 <string>Production</string>
</dict>
</plist>