Equvilant of mysql dump but with a query

Hi Guys,

I want to get a output like what the below command would do


mysqldump --password=password --user=root hss > test_dump.sql

but Via PHP and i want to do a where statement

i’ve done

SELECT * INTO OUTFILE '/tmp/test.sql' FROM `tblcars` WHERE `CarID` = 50

but this does not format it so it has the table structure etc in the outputted sql file.

Can any one recommend a good way?