PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
robster
Forum Contributor
Posts: 360 Joined: Wed Jul 16, 2003 8:28 am
Location: Sunshine Coast, Australia
Post
by robster » Tue Dec 28, 2004 5:54 pm
I know it sounds silly, but I can't find the code to do this on Google or on php.net.
I need to say basically: 'Empty table X' I don't even need a while clause or anything.
Sorry to directly ask for code, but i have searched and searched and have just had enough so I thought I'd just come here and ask
Thanks a tonne!
Rob
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Tue Dec 28, 2004 6:06 pm
[mysql_man]truncate[/mysql_man] and [mysql_man]drop[/mysql_man] ...
robster
Forum Contributor
Posts: 360 Joined: Wed Jul 16, 2003 8:28 am
Location: Sunshine Coast, Australia
Post
by robster » Tue Dec 28, 2004 6:16 pm
Thank you yes, I did see that
It basically says (in my case) to do this:
TRUNCATE TABLE 'artwork_info_tmp'
The problem being I really don't know how to convert that MYSQL code into PHP ready code. I'm presuming it gets called from an UPDATE function or similar?
Thanks again, I really appreciate it
Rob
timvw
DevNet Master
Posts: 4897 Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium
Post
by timvw » Tue Dec 28, 2004 6:17 pm
just do it like you perform your other queries, usually
$query = "select * from bar";
$query2 = "truncate bar";
$result = [php_man]mysql_query[/php_man]($query);
robster
Forum Contributor
Posts: 360 Joined: Wed Jul 16, 2003 8:28 am
Location: Sunshine Coast, Australia
Post
by robster » Tue Dec 28, 2004 6:31 pm
worked a charm, this was the final code :
$query = "select * from artwork_info_tmp";
$query2 = "truncate artwork_info_tmp";
$result = mysql_query($query);
$result = mysql_query($query2);
mysql_free_result($result);
magicrobotmonkey
Forum Regular
Posts: 888 Joined: Sun Mar 21, 2004 1:09 pm
Location: Cambridge, MA
Post
by magicrobotmonkey » Tue Dec 28, 2004 11:08 pm
you dont need the select query as you obviously dont do anything with it as you immediately write it over
Code: Select all
<?php
$query = "truncate artwork_info_tmp";
$result = mysql_query($query);
mysql_free_result($result);
?>