John Davidson

php - shell_exec + mysqldump not working with where condition

0 comments
Message:


I am trying to run mysqldump with shell_exec command with where condition.


$shell_result = shell_exec('mysqldump --op ctax91_db leads  --where="id  =  "a"   " |  gzip > Leads.sql.gz ');

i tried many options for changng quotes but it is not working .
also tried for --where="id = '"'a'" , but not working


please suggest



My Answer:
You need to properly escape the quotes in your shell command. Try the following:

php
$shell_result = shell_exec('mysqldump --op ctax91_db leads --where="id=\'a\'" | gzip > Leads.sql.gz');


This should work as expected. Make sure to replace `'a'` with the actual value you want to use in the `where` condition.

Rate this post

3 of 5 based on 6078 votes

Comments




© 2024 Hayatsk.info - Personal Blogs Platform. All Rights Reserved.
Create blog  |  Privacy Policy  |  Terms & Conditions  |  Contact Us