Jump to content
php.lv forumi

Access


jannis

Recommended Posts

Vienkaarshaakais (varbuut) veids ir taisiit taa sauktaas "DSN (Data Source Name) Less" konekcijas - proti pa taisno sleegties pie .mdb faila:

 

<code><font color="#000000">

<font color="#0000CC"><?php
</font><font color="#006600">if (!</font><font color="#0000CC">$conn </font><font color="#006600">= new </font><font color="#0000CC">COM</font><font color="#006600">(</font><font color="#CC0000">"ADODB.Connection"</font><font color="#006600">))
	exit(</font><font color="#CC0000">"Unable to create an ADODB connection
"</font><font color="#006600">);

</font><font color="#0000CC">$strConn </font><font color="#006600">= </font><font color="#CC0000">"DRIVER={Microsoft Access Driver (*.mdb)}; DBQ=" </font><font color="#006600">. </font><font color="#0000CC">[url=http://lv.php.net/realpath]realpath[/url]</font><font color="#006600">(</font><font color="#CC0000">"dbsearch.mdb"</font><font color="#006600">); 

</font><font color="#0000CC">$conn</font><font color="#006600">-></font><font color="#0000CC">open</font><font color="#006600">(</font><font color="#0000CC">$strConn</font><font color="#006600">); 

</font><font color="#0000CC">$strSQL </font><font color="#006600">= </font><font color="#CC0000">"SELECT * FROM tabula"</font><font color="#006600">; 
</font><font color="#0000CC">$rs </font><font color="#006600">= </font><font color="#0000CC">$conn</font><font color="#006600">-></font><font color="#0000CC">execute</font><font color="#006600">(</font><font color="#0000CC">$strSQL</font><font color="#006600">);

</font><font color="#0000CC">$lauks1</font><font color="#006600">= </font><font color="#0000CC">$rs</font><font color="#006600">-></font><font color="#0000CC">Fields</font><font color="#006600">(</font><font color="#0000CC">0</font><font color="#006600">);
</font><font color="#0000CC">$lauks2 </font><font color="#006600">= </font><font color="#0000CC">$rs</font><font color="#006600">-></font><font color="#0000CC">Fields</font><font color="#006600">(</font><font color="#0000CC">1</font><font color="#006600">);
</font><font color="#0000CC">$lauks3 </font><font color="#006600">= </font><font color="#0000CC">$rs</font><font color="#006600">-></font><font color="#0000CC">Fields</font><font color="#006600">(</font><font color="#0000CC">2</font><font color="#006600">);

 while (!</font><font color="#0000CC">$rs</font><font color="#006600">-></font><font color="#0000CC">EOF</font><font color="#006600">) 
{
	echo </font><font color="#CC0000">"Lauks1 = $lauks1 | Lauks2 = $lauks2... <br/>"</font><font color="#006600">;
	</font><font color="#0000CC">$rs</font><font color="#006600">-></font><font color="#0000CC">MoveNext</font><font color="#006600">(); 
}

</font><font color="#0000CC">$rs</font><font color="#006600">-></font><font color="#0000CC">Close</font><font color="#006600">();
</font><font color="#0000CC">$conn</font><font color="#006600">-></font><font color="#0000CC">Close</font><font color="#006600">();
</font><font color="#0000CC">?>
</font>
</font>
</code>

Link to comment
Share on other sites

Ar COM gan nemaaceeshu teikt kaa dabuut db lauka tipu..

Tachu taakaa skatos ka tu shaa vai taa stradaa uz Windows platformas tad vienkaarshaka principaa buutuu to visu dariit caur ODBC http://www.php.net/manual/en/ref.odbc.php

 

Un tad ar http://www.php.net/manual/en/function.odbc...-field-type.php

 

Iisumaa http://www.phpbuilder.com/columns/siddarth...p3?print_mode=1

 

Ja tas viss tiks paarliks uz kaadas linux/unix kastes tad buus speciaali jaapiemeklee ODBC draiveri (unixodbc, odbcsock vai kaadi citi) un jaapaarkompilee php..

Link to comment
Share on other sites

×
×
  • Create New...