How can I invoke the MySQL interactive client from PHP? -


i'm trying get

`mysql -uroot`; 

to enter mysql interactive client executing

$ mysql -uroot  

from shell does.

it's okay if php script exists after (or before), need invoke mysql client.

i've tried using proc_open() , of course system(), exec() , passthru(). wondering if has tips.

new solution:

<?php $descriptorspec = array(    0 => stdin,    1 => stdout,    2 => stderr ); $process = proc_open('mysql -uroot', $descriptorspec, $pipes); 

old one:

save tab completion (you in there if read out bytes fread instead of using fgets), gets on way, lots left tweak:

<?php $descriptorspec = array(    0 => array("pty"),    1 => array("pty"),    2 => array("pty") ); $process = proc_open('mysql -uroot', $descriptorspec, $pipes); stream_set_blocking($pipes[1], 0); stream_set_blocking($pipes[2], 0); stream_set_blocking(stdin,0); {    echo stream_get_contents($pipes[1]);    echo stream_get_contents($pipes[2]);    while($in = fgets(stdin)) fwrite($pipes[0],$in); } while (1); 

Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -