note 75143 deleted from function.mysqli-num-fields by hholzgra
| From: | hholzgra@php.net | Date: | Sat, 29 Sep 2007 11:51:54 +0000 |
| Subject: | note 75143 deleted from function.mysqli-num-fields by hholzgra | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-130923@lists.php.net to get a copy of this message | ||
Note Submitter: jcwebb at dicoe dot com
----
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