note 75143 added to function.mysqli-num-fields
| From: | jcwebb at dicoe dot com | Date: | Tue, 15 May 2007 08:26:27 +0000 |
| Subject: | note 75143 added to function.mysqli-num-fields | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-126594@lists.php.net to get a copy of this message | ||
RE-CREATE TABLE
If you have noticed that 'delete from sometable' is a lot slower than 'drop table;
create table' then you are not alone. I finally figured out how to do it on the fly (so you
dont have to track 'alter table' commands throughout your code).
<?php
$q="SHOW CREATE TABLE temptable"; $r=mysqli_query($DBlink,$q);
$n=mysqli_num_rows($r); if ($n==1): $w=mysqli_fetch_assoc($r); $createstring=$w['Create
Table']; endif;
$q="DROP TEMPORARY TABLE IF EXISTS temptable"; $r=mysqli_query($DBlink,$q);
$q=$createstring; $r=mysqli_query($DBlink,$q);
?>
note: works with all tables (my example uses a temp table)
note: yes, there IS a space in ['Create Table']
This is a very fast way of resetting a table (and resetting its indexes). Hope it helps (it only
took me 100 years to figure out!).
Jon
----
Server IP: 130.206.1.5
Probable Submitter: 88.19.31.226
----
Manual Page -- http://www.php.net/manual/en/function.mysqli-num-fields.php
Edit -- https://master.php.net/note/edit/75143
Del: integrated -- https://master.php.net/note/delete/75143/integrated
Del: useless -- https://master.php.net/note/delete/75143/useless
Del: bad code -- https://master.php.net/note/delete/75143/bad+code
Del: spam -- https://master.php.net/note/delete/75143/spam
Del: non-english -- https://master.php.net/note/delete/75143/non-english
Del: in docs -- https://master.php.net/note/delete/75143/in+docs
Del: other reasons-- https://master.php.net/note/delete/75143
Reject -- https://master.php.net/note/reject/75143
Search -- https://master.php.net/manage/user-notes.php