mysql multiple query

From: Date: Wed, 17 Jul 2002 10:34:57 +0000
Subject: mysql multiple query
References: 1 2  Groups: php.db 
Request: Send a blank email to php-db+get-20596@lists.php.net to get a copy of this message
hello.. i have a pretty wired query to do with php/mysql . i don't manage to do mysql_query($qry,$connection); . (query bellow) so i found a quick and dirty solution.see bellow . but it's no realy elegant . any ideea how can i do multiple queries at once with mysql_query() ? function copy_question($qid,$test_target) { global $connection,$username,$password,$database; $fp = fopen ('/tmp/copy_table_qry', 'w'); $qry="create temporary table q_temp as select * from questions; create temporary table ans_temp as select * from answers; set @test_id=$test_target; set @q_id=$qid; insert into questions select '',@test_id,t2.q_type,t2.description,t2.dimension,t2.combination,t2.checkit from q_temp as t2 where id=@q_id; select @last:=LAST_INSERT_ID(); insert into answers select '',@last,score,description from ans_temp where id_question_fk=@q_id;"; fputs($fp,"$qry"); fclose($fp); $a=exec("/usr/bin/mysql -u $username -p$password $database </tmp/copy_table_qry"); -- thnx .

« previous php.db (#20596) next »