Stergerea unei baze de date

Stefanescu Mihai 3 years ago PHP
Acest articol face parte din cursul Toate lectiile PHP. Te poti inscrie la acest curs aici!

Daca nu mai aveti nevoie de o baza de date puteti sa o stergeti. Ca si in cazul anterior, putem folosi functia query pentru a sterge o baza de date.

<?php
$dbhost = 'localhost';
$dbuser = 'user';
$dbpass = 'parola';
$conn = new mysqli($dbhost, $dbuser, $dbpass);
if(! $conn ){
  die('Nu ma pot conecta: ' . $conn->error());
}
$sql = 'DROP DATABASE test_mike';

$retval = $conn->query( $sql );

if(! $retval ){
  die('Nu pot sterge baza de date: ' . $conn->error());
}
echo "Baza de date stearsa.\n";
$conn->close();
?>

Atentie: Stergerea unei baze de date este periculoasa. Asigurati-va ca stergeti ce trebuie si/sau ca aveti un backup.

Stergerea unui tabel

Ca si in cazul de mai sus, putem folosi functia query() pentru a sterge un tabel.

<?php
$dbhost = 'localhost';
$dbuser = 'root';
$dbpass = '';
$dbdb = 'test_mike';
$conn = new mysqli($dbhost, $dbuser, $dbpass, $dbdb);
if(! $conn ){
  die('Nu ma pot conecta: ' . $conn->error());
}
$sql = 'DROP TABLE users';

$retval = $conn->query( $sql );

if(! $retval ){
  die('Nu pot sterge tabelul: ' . $conn->error());
}
echo "Tabel sters.\n";
$conn->close();
?>

 

Programator de ~8 ani, am lucrat la proiecte din mai multe industrstrii, de la eCommerce la telecomunicatii la automatizari. In acest timp am folosi diferite tehnologii, de la PHP, MySQL, PostgreSql, RabbitMq, Redis, Memcached si altele.


Get in touch
Pentru nelamuriri, dubii, comentarii si chestii de pe suflet ne putem auzi pe Discord, Reddit sau poti deschide o discutie noua pe forum

Are you spending money on Robux # 8 months ago Hi my loved one! I want to say that this article is amazing, nice written and come with almost all vital infos. I would like to look more posts like this .
amox-clav ordenado en España # 4 months ago Wonderful article! We will be linking to this particularly great article on our site. Keep up the great writing.
farmacia de fexofenadine # 4 months ago you are actually a excellent webmaster. The website loading speed is amazing. It seems that you're doing any distinctive trick. Moreover, The contents are masterwork. you have done a magnificent job in this matter!
Cumeaa # 3 months ago purchase fenofibrate pill <a href="https://fenoficor.com/">generic tricor 200mg</a> buy fenofibrate generic
prix cesia Maroc # 3 months ago Excellent beat ! I wish to apprentice while you amend your website, how can i subscribe for a weblog site? The account aided me a acceptable deal. I have been a little bit acquainted of this your broadcast provided vivid transparent concept
dostinex kopen in België # 3 months ago Link exchange is nothing else but it is only placing the other person's weblog link on your page at suitable place and other person will also do same for you.
Ruebrj # 3 months ago zaditor 1 mg pills <a href="https://geozipin.com/">order geodon online</a> imipramine cost
Dxdlal # 3 months ago purchase minoxytop generic <a href="https://abcelemax.shop/">flomax generic</a> where to buy over the counter ed pills
Lpqbaz # 3 months ago buy generic acarbose <a href="https://tofobose.shop/">buy acarbose 25mg sale</a> buy griseofulvin 250mg online cheap
Zhqide # 3 months ago buy aspirin generic <a href="https://imitonin.com/">zovirax oral</a> order generic imiquad
aygestin te koop in België # 3 months ago It's awesome in favor of me to have a website, which is beneficial in favor of my knowledge. thanks admin
Landon # 3 months ago It's really very difficult in this full of activity life to listen news on Television, so I simply use web for that reason, and obtain the hottest information.
Landon # 3 months ago It's really very difficult in this full of activity life to listen news on Television, so I simply use web for that reason, and obtain the hottest information.
Claude # 3 months ago Thank you for some other informative website. Where else may I get that type of info written in such an ideal approach? I have a mission that I'm just now working on, and I have been on the glance out for such info.
Spgenp # 3 months ago order duphaston 10 mg generic <a href="https://empaolol.com/">order empagliflozin</a> buy empagliflozin 25mg sale
Fkzzdv # 3 months ago brand florinef 100 mcg <a href="https://imocarbam.com/">buy generic imodium over the counter</a> buy imodium
Iewbjn # 3 months ago etodolac 600 mg generic <a href="https://colotazol.shop/">buy cilostazol 100 mg without prescription</a> cilostazol 100 mg tablet
Sudfdt # 3 months ago prasugrel 10 mg cost <a href="https://imocarbam.shop/">prasugrel pills</a> buy tolterodine 2mg for sale
Ihtkvj # 3 months ago order ferrous 100mg <a href="https://detorbic.shop/">oral ascorbic acid 500mg</a> betapace cost
Yzylha # 2 months ago purchase mestinon generic <a href="https://mestien.com/">cheap pyridostigmine</a> maxalt 5mg pills
Plviqk # 2 months ago order vasotec <a href="https://casosin.com/">order casodex online cheap</a> duphalac ca
Lsskso # 2 months ago where to buy latanoprost without a prescription <a href="https://aexeloda.shop/">buy rivastigmine 6mg online cheap</a> exelon 6mg oral
Ngnajd # 2 months ago buy betahistine for sale <a href="https://haloatan.shop/">order latanoprost online cheap</a> order benemid generic
Ryczzj # 2 months ago micardis 20mg price <a href="https://atizordis.shop/">order micardis 20mg online cheap</a> molnupiravir 200 mg sale
Qbiumw # 2 months ago order cenforce 50mg online cheap <a href="https://chlodinir.com/">aralen cheap</a> aralen 250mg for sale
Jhvyfx # 2 months ago roulette casino <a href="https://furocheap.com/">order lasix 40mg generic</a> buy lasix generic
Mlrhde # 2 months ago free online blackjack <a href="https://strvnonline.com/">order stromectol 3mg pill</a> stromectol buy uk
Oreggi # 2 months ago order amantadine 100mg generic <a href="https://atenulfon.shop/">oral avlosulfon</a> buy dapsone cheap
Rdhcgc # 2 months ago clomid price <a href="https://azatophene.com/">cheap clomiphene</a> imuran 50mg without prescription
Acjscq # 2 months ago methylprednisolone 16mg oral <a href="https://arisceon.com/">aristocort pills</a> aristocort 4mg ca
Etiexr # 1 month ago buy generic perindopril 4mg <a href="https://claegra.com/">purchase desloratadine</a> allegra 120mg us
Hsafrb # 1 month ago buy generic dilantin <a href="https://sumentin.shop/">buy phenytoin without a prescription</a> ditropan cost
Feeauh # 1 month ago lioresal pills <a href="https://bactyline.shop/">endep 10mg generic</a> toradol 10mg drug
Qqnqdg # 1 month ago claritin buy online <a href="https://daporide.com/">order priligy</a> priligy ca
Izayqm # 1 month ago order generic baclofen 25mg <a href="https://bactyline.com/">buy baclofen no prescription</a> toradol 10mg usa
Heyvfc # 1 month ago alendronate uk <a href="https://macroicine.shop/">order generic furadantin 100 mg</a> order macrodantin 100 mg online
Irujdw # 1 month ago glimepiride 1mg cost <a href="https://daporide.shop/">order amaryl 1mg sale</a> order arcoxia 60mg generic
Glrrnh # 1 month ago order nortriptyline 25 mg online <a href="https://meloceto.shop/">paracetamol sale</a> buy paracetamol 500mg online cheap
Mxrusx # 1 month ago buy medex online cheap <a href="https://wafetine.com/">medex over the counter</a> purchase maxolon online
Oqykfg # 1 month ago order orlistat 120mg <a href="https://diltastel.com/">buy diltiazem 180mg without prescription</a> diltiazem buy online
Dlcwkx # 1 month ago buy pepcid 20mg online cheap <a href="https://cozolimus.shop/">oral prograf 1mg</a> order tacrolimus online cheap
Jqlmqf # 1 month ago buy azelastine 10ml sprayer <a href="https://acypapro.shop/">cost irbesartan</a> buy irbesartan without prescription
Eikdvp # 1 month ago imitrex price <a href="https://aimaptan.com/">order generic imitrex 25mg</a> avodart pill
Evnpit # 1 month ago buy zyloprim 300mg online cheap <a href="https://allovatep.com/">allopurinol 300mg uk</a> buy rosuvastatin 20mg without prescription
Tyhvtt # 1 month ago buy buspin pills for sale <a href="https://ezetdarone.com/">order ezetimibe without prescription</a> cordarone 100mg canada
Kxaabw # 1 month ago motilium 10mg over the counter <a href="https://domedilol.com/">domperidone oral</a> tetracycline 250mg generic
Imaafq # 1 month ago order spironolactone <a href="https://vaclorex.com/">buy valacyclovir</a> brand finpecia
Fojtep # 1 month ago help with term paper <a href="https://essaystada.com/">editing essays</a> how to write an about me essay
Sgqeqp # 1 month ago order fluconazole 100mg without prescription <a href="https://ampacitim.com/">buy ampicillin generic</a> order cipro 500mg generic
Uqlfoe # 1 month ago aurogra canada <a href="https://auroafil.com/">aurogra cheap</a> purchase estradiol generic
Pmdehj # 4 weeks ago buy generic lamotrigine <a href="https://averzol.com/">vermox price</a> order mebendazole 100mg sale
Lqzrao # 3 weeks ago buy cleocin 150mg online <a href="https://aperytxpro.com/">erythromycin ca</a> pills for erection
Wwvjzg # 3 weeks ago tretinoin gel price <a href="https://abvatol.com/">oral avana</a> buy avana online
Xpfgqd # 3 weeks ago nolvadex pills <a href="https://tamoitutex.com/">cheap tamoxifen 20mg</a> symbicort cost
Jxckbb # 3 weeks ago buy cefuroxime 500mg generic <a href="https://acaropro.com/">where can i buy lumigan</a> robaxin 500mg without prescription
Pislan # 2 weeks ago paperwriter <a href="https://abessonline.com/">writing better essays</a> buy cefixime 100mg generic
Bttujt # 2 weeks ago order amoxicillin without prescription <a href="https://biacrobol.com/">clarithromycin 500mg for sale</a> buy clarithromycin tablets
Blvakv # 2 weeks ago cheap calcitriol 0.25 mg <a href="https://triprefibran.com/">generic fenofibrate</a> purchase fenofibrate sale
Tnayfl # 2 weeks ago catapres 0.1 mg generic <a href="https://cloprebol.com/">order clonidine without prescription</a> order tiotropium bromide 9 mcg for sale
Kvpkls # 2 weeks ago buy acne pills online <a href="https://placnemedx.com/">best acne treatment teen boys</a> trileptal 600mg canada
Wbofrw # 1 week ago order minocin 100mg sale <a href="https://amrenirol.com/">order generic requip 1mg</a> ropinirole 1mg pill
Otnmjl # 1 week ago buy sleeping tablets online uk <a href="https://urupdiol.com/">online pharmacies sleeping pills</a> strongest weight loss prescription
Qflmaq # 1 week ago tobacco cessation medications chart <a href="https://healthybonesots.com/">dmard meds list</a> strongest pain killer list
Mrffow # 1 week ago medroxyprogesterone 10mg sale <a href="https://microchloroth.com/">buy hydrochlorothiazide 25mg online</a> hydrochlorothiazide 25 mg tablet
Ujvzjo # 1 week ago how are antiviral drugs used <a href="https://andiabeps.com/">diabetic drugs starting with b</a> lowest gli sugar for diabetics
Hdvtwo # 1 week ago cyproheptadine us <a href="https://peritadin.com/">generic periactin 4mg</a> nizoral oral
Kopldu # 6 days ago antifungal cream for pediatric face <a href="https://rebloodpressure.com/">best hypertension medication combinations</a> antihypertensive tablet name
Tdzzuc # 4 days ago antibiotics to treat peptic ulcer <a href="https://aheartop.com/">tricks to lower blood pressure instantly</a> otc pain relief for uti
Qafahp # 3 days ago buy promethazine cheap <a href="https://proedpls.com/">buy ed medications</a> buy oral ivermectin
Fikdap # 3 days ago birth control online without insurance <a href="https://premaxejacu.com/">pe and ed treatment</a> premature ejaculation pills review
Hfbpib # 1 day ago severe stomach paincaused by medication <a href="https://benauseap.com/">nausea medicines over the counter</a> medications that cause foul smelling gas
Club-ul este dedicat membrilor si ofera access la mai multe zone ale website-ului.
Login Register

🔖 Bookmarks
✨ Pentru a sustine aceasta comunitate am sa te rog sa te autentifici sau sa te inregistrezi!

🌪️ Discord
Back to top
Folosim cookie-uri pentru a oferi functionalitatile critice ale aplicatiei Invata-Programare. Folosim cookie-uri si pentru a analiza traficul, pentru care e nevoie de consimtamantul dvs. explicit.