Pergunta

I used to write some php a few years ago and used adodb to connect to a mysql database.

After reading a bit on stackoverflow I wondered if adodb is still maintained ? the latest changelog is from 3rd of September 2012.

I started reading the documentation of mysqli. I can get a database connection but can not seem to figure out a way to run a query and get the results of the query back.

Could someone tell me how to run a simple query like "SELECT * FROM Text WHERE TextId=10;" ?

I tried this

$dbconn = new mysqli($Host, $DbAdminUser, $DbAdminUserPassword, $Database);
if ($dbconn->connect_errno) {
    echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " .                $mysqli->connect_error;
}
echo $dbconn->host_info . "\n";

$stmt = mysqli_prepare($dbconn, "SELECT * FROM Text WHERE TextId=10;")
$result = mysqli_query($dbconn,$stmt);
print_r($result);

anybody could help me out or point me what I am doing wrong ?

or should I just stick with adodb ?

Foi útil?

Solução

Please note that mysqli is a low-level api that isn't intended to be used in the application code. So - it's incomparable to ADODB. So, instead of raw mysqli I'd suggest you to use PDO or a library built on top of mysqli, such as my safeMysql

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top