Jump to content
php.lv forumi

Datu Glabaashana


jonass

Recommended Posts

Jakonfiguree apache un jaaizliedz .txt faili (vai arii lasiit direktoriju kuraa atrodas muusu txt db)..

Ja ir atljauts izmantot .htacess failus vai ir pieeja konfigam (tas ir tavs pasha webserveris) tad easy ja nav (teiksim hosteejies pie kaada) tad var meegjinaat datus glabaat nevis .txt failos bet .php failos un saakumaa un beigaas iebakstiit <? un ?>

Liidz ar to pie nolasiishanas buus jaaizmet faila pirmaa peedeejaa rinda tachu useris pa taisno failu apskatiit nevarees..

 

Protams visaadaa zinjaa tas ir krietni saregzjiitaak (zinaamos jautaajumos kaa atlasiishana,sorteeshana, ierakstu limiteeshana) nekaa straadaat ar kaadu no sql datubaazeem (mysql,pgsql u.c.)

Link to comment
Share on other sites

Txt formāts no īstas datubāzes ir tikpat tāls kā cūkkūtiņa no kosmosa stacijas. Txt failā var tikai glabāt informāciju, visāda datu atlasīšana un meklēšana txt failā būs nejēdzīgi neērts pasākums. Bet darīt jau var.

Ērti ir glabāt masīvus txt failā izmantojot funkcijas serialize() un unserialize().

Windows vidē gan laikam ar txt failiem var strādāt arī kā ar datu tabulām, ja darbojas caur odbc - iekš odbc var noformēt comma-delimited teksta failu kā datu avotu.

Link to comment
Share on other sites

nju es atradu vienu ljoti vienkaarshu guestbooku, kuraa tiek ievietots txt fails, bat kad posteeju formu, vinjsh man nesaglabaa tajaa txt failaa.

<code><font color="#000000">
<div class="normalText">
<form action="addbook.php" method="post">
Message


<textarea name="message" cols="50" rows="7" class="textbox"></textarea>


Name


<input type="text" name="name" size="48" class="textbox">


<input type="submit" value=" Submit " class="textbox">
</form>
</div>
</font>
</code>

- postoshanas kods

<code><font color="#000000">
<div class="guestbookTop">
<a href="postform.php">Write</a> to a guestbook


</div>

<font color="#0000CC"><?php

$fileName </font><font color="#006600">= </font><font color="#0000CC">file </font><font color="#006600">(</font><font color="#CC0000">"guestbook.txt"</font><font color="#006600">);
</font><font color="#0000CC">$rows </font><font color="#006600">= </font><font color="#0000CC">count </font><font color="#006600">(</font><font color="#0000CC">$fileName</font><font color="#006600">);

if (</font><font color="#0000CC">$rows </font><font color="#006600">> </font><font color="#0000CC">10</font><font color="#006600">)
{
	if (!isset (</font><font color="#0000CC">$row</font><font color="#006600">) )
	{
		</font><font color="#0000CC">$row </font><font color="#006600">= </font><font color="#0000CC">0</font><font color="#006600">;
	}

	print (</font><font color="#CC0000">"<table class="</font><font color="#0000CC">guestbookLinks</font><font color="#CC0000">"><tr><td width="</font><font color="#0000CC">50</font><font color="#006600">%</font><font color="#CC0000">">"</font><font color="#006600">);

	if (</font><font color="#0000CC">$row </font><font color="#006600">> </font><font color="#0000CC">0</font><font color="#006600">)
	{
	echo </font><font color="#CC0000">"<div class="</font><font color="#0000CC">nextPage</font><font color="#CC0000">"><< <a href="</font><font color="#0000CC">readbook</font><font color="#006600">.</font><font color="#0000CC">php</font><font color="#006600">?</font><font color="#0000CC">row</font><font color="#006600">=</font><font color="#CC0000">" . ($row - 10) . "">Next 10</a></div>"</font><font color="#006600">;
}

print (</font><font color="#CC0000">"</td><td width="</font><font color="#0000CC">50</font><font color="#006600">%</font><font color="#CC0000">">"</font><font color="#006600">);

	if ( (</font><font color="#0000CC">$rows </font><font color="#006600">- </font><font color="#0000CC">$row</font><font color="#006600">) > </font><font color="#0000CC">10</font><font color="#006600">)
	{
	echo </font><font color="#CC0000">"<div class="</font><font color="#0000CC">previousPage</font><font color="#CC0000">"><a href="</font><font color="#0000CC">readbook</font><font color="#006600">.</font><font color="#0000CC">php</font><font color="#006600">?</font><font color="#0000CC">row</font><font color="#006600">=</font><font color="#CC0000">" . ($row + 10) . "">Previous 10</a> >></div>"</font><font color="#006600">;
}

print (</font><font color="#CC0000">"</td></tr></table>"</font><font color="#006600">);

   for (</font><font color="#0000CC">$i </font><font color="#006600">= </font><font color="#0000CC">$row</font><font color="#006600">; </font><font color="#0000CC">$i </font><font color="#006600">< (</font><font color="#0000CC">$row </font><font color="#006600">+ </font><font color="#0000CC">10</font><font color="#006600">); </font><font color="#0000CC">$i</font><font color="#006600">++)
{
	echo </font><font color="#0000CC">$fileName </font><font color="#006600">[</font><font color="#0000CC">$i</font><font color="#006600">];
}
}
else
{
  for (</font><font color="#0000CC">$i</font><font color="#006600">=</font><font color="#0000CC">0</font><font color="#006600">; </font><font color="#0000CC">$i </font><font color="#006600">< </font><font color="#0000CC">$rows</font><font color="#006600">; </font><font color="#0000CC">$i</font><font color="#006600">++)
  {
	  echo </font><font color="#0000CC">$fileName </font><font color="#006600">[</font><font color="#0000CC">$i</font><font color="#006600">];
  }
}

</font><font color="#0000CC">?>
</font>
<div class="guestbookUp">





<a href="postform.php">Write</a> to a guestbook
</div></font>
</code>

- nolasiishanas kods

mosh kaukas nepareizi

Link to comment
Share on other sites

aa un veel addbook.php, kuram tiek posteec tas viss

<code><font color="#000000">
<font color="#0000CC"><?php
</font><font color="#006600">if (</font><font color="#0000CC">$message </font><font color="#006600">!= </font><font color="#CC0000">''</font><font color="#006600">) 
{
 </font><font color="#0000CC">$message </font><font color="#006600">= </font><font color="#0000CC">str_replace </font><font color="#006600">(</font><font color="#CC0000">"n"</font><font color="#006600">,</font><font color="#CC0000">"
"</font><font color="#006600">,</font><font color="#0000CC">$message</font><font color="#006600">);
 </font><font color="#0000CC">$message </font><font color="#006600">= </font><font color="#0000CC">strip_tags </font><font color="#006600">(</font><font color="#0000CC">$message</font><font color="#006600">, </font><font color="#CC0000">'
'</font><font color="#006600">);

 </font><font color="#0000CC">$newRow </font><font color="#006600">= </font><font color="#CC0000">'<div class="viewGuestbook">' </font><font color="#006600">. (</font><font color="#0000CC">$message</font><font color="#006600">) .
	  </font><font color="#CC0000">'
' </font><font color="#006600">. </font><font color="#0000CC">[url=http://lv.php.net/date]date[/url]</font><font color="#006600">(</font><font color="#CC0000">'d.m.Y H:i'</font><font color="#006600">) . </font><font color="#CC0000">' - ' </font><font color="#006600">. </font><font color="#0000CC">strip_tags </font><font color="#006600">(</font><font color="#0000CC">$name</font><font color="#006600">) .
	  </font><font color="#CC0000">'</div>'</font><font color="#006600">;

 </font><font color="#0000CC">$oldRows </font><font color="#006600">= </font><font color="#0000CC">join </font><font color="#006600">(</font><font color="#CC0000">''</font><font color="#006600">, </font><font color="#0000CC">file </font><font color="#006600">(</font><font color="#CC0000">'guestbook.txt'</font><font color="#006600">) );
 </font><font color="#0000CC">$fileName </font><font color="#006600">= </font><font color="#0000CC">fopen </font><font color="#006600">(</font><font color="#CC0000">'guestbook.txt'</font><font color="#006600">, </font><font color="#CC0000">'w'</font><font color="#006600">);
 </font><font color="#0000CC">fputs </font><font color="#006600">(</font><font color="#0000CC">$fileName</font><font color="#006600">, </font><font color="#0000CC">$newRow </font><font color="#006600">. </font><font color="#0000CC">[url=http://lv.php.net/chr]chr[/url]</font><font color="#006600">(</font><font color="#0000CC">13</font><font color="#006600">) . </font><font color="#0000CC">[url=http://lv.php.net/chr]chr[/url]</font><font color="#006600">(</font><font color="#0000CC">10</font><font color="#006600">) . </font><font color="#0000CC">$oldRows</font><font color="#006600">);
 </font><font color="#0000CC">fclose </font><font color="#006600">(</font><font color="#0000CC">$fileName</font><font color="#006600">);
}

include (</font><font color="#CC0000">"readbook.php"</font><font color="#006600">);
</font><font color="#0000CC">?></font>
</font>
</code>

Link to comment
Share on other sites

Txt formāts no īstas datubāzes ir tikpat tāls kā cūkkūtiņa no kosmosa stacijas. Txt failā var tikai glabāt informāciju, visāda datu atlasīšana un meklēšana txt failā būs nejēdzīgi neērts pasākums. Bet darīt jau var.

Ērti ir glabāt masīvus txt failā izmantojot funkcijas serialize() un unserialize().

Windows vidē gan laikam ar txt failiem var strādāt arī kā ar datu tabulām, ja darbojas caur odbc - iekš odbc var noformēt comma-delimited teksta failu kā datu avotu.

Nee nu kapeec?

ja tu vari uzrakstiit normaalu interfeisu funkcijas, sortinga atbalstu (aiz kam taadas lietas eksistee (ir uzkodeetas) kaa flat file databases) tad saliidzinaajums par cuukkuutinju ir nevietaa.. un pie maziem datu apjomiem cuukkuutinji liek iekshaa "kosmosa staciju" ka nemetas (var pamekleet googlee 'php text file databases' vai 'flat file databases')..

 

p.s. jaa pods.lv vismaz kaadreiz (iespeejams ka veelarvien ja CLX nav ko mainiijis) griezhas uz .txt

Link to comment
Share on other sites

  • 4 weeks later...

Klau! Man tads jautajums !! Piem. es datus saglabaju txt failos sada veida

 

Niks||||email@mails.lv||||www.adrese.lv||||site baigi liela zina|||||datums un laiks||||te vel sadi tadi dati

Niks||||email@mails.lv||||www.adrese.lv||||site baigi liela zina|||||datums un laiks||||te vel sadi tadi dati

Niks||||email@mails.lv||||www.adrese.lv||||site baigi liela zina|||||datums un laiks||||te vel sadi tadi dati

 

 

Mana problema es gribetu piemeram uztaisit ta lai es varetu tos datus izmaimnit redigejot vai pievienojot jaunus vai ari vispar izdzesot!!!! Ko man darit? Mysql neiesakiet , ja ari iesakiet tad vismaz iepostejiet kadu piemeeru kur varetu dzest datus un mainit un pievienot klat! Pleazzzzzzzzzzzzzzz es esmu izmisumaaaaaa! Un ja kas to MySQL es vispar nerubiju !!!!!!

Link to comment
Share on other sites

×
×
  • Create New...