Originariamente inviato da luca200
Per finire, la possibilità di modificare quel comportamento di mysql_affected_rows(), di cui parla quell'articolo, è qualcosa di cui non avevo mai sentito parlare, e di cui non trovo traccia sul sito di php. La pagina della funzione mysql_connect() fa riferimento ad un quinto parametro che contiene flags utente, ma nessuno di questi si riferisce al risultato di mysql_affected_rows(). In sostanza, non conterei troppo su questa possibilità.
Ciao Luca200,

hai ragione su tutti i fronti tranne che uno e cioè quello che ho citato.
Ti spiego; sul php.net si parla eccome di come modificare il comportamento di mysql_affected_rows, infatti se scorri in basso troverai un post dove si elencano una serie di parametri che è possibile inserire ed in fondo allo stesso elenco c'è una postilla dove si dice che non sempre tali "hack" funzionino tranne per CLIENT_FOUND_ROWS ovvero il famoso parametro con valore 2.

riporto qui l'intero post tanto per renderlo utile a chi interessa:
client_flags can be things other than MYSQL_CLIENT_COMPRESS, MYSQL_CLIENT_IGNORE_SPACE and MYSQL_CLIENT_INTERACTIVE.

I presume that mysql_connect() just passes through to the C MySQL API, which provides these constants:

#define CLIENT_LONG_PASSWORD 1 /* new more secure passwords */
#define CLIENT_FOUND_ROWS 2 /* Found instead of affected rows */
#define CLIENT_LONG_FLAG 4 /* Get all column flags */
#define CLIENT_CONNECT_WITH_DB 8 /* One can specify db on connect */
#define CLIENT_NO_SCHEMA 16 /* Don't allow database.table.column */
#define CLIENT_COMPRESS 32 /* Can use compression protocol */
#define CLIENT_ODBC 64 /* Odbc client */
#define CLIENT_LOCAL_FILES 128 /* Can use LOAD DATA LOCAL */
#define CLIENT_IGNORE_SPACE 256 /* Ignore spaces before '(' */
#define CLIENT_CHANGE_USER 512 /* Support the mysql_change_user() */
#define CLIENT_INTERACTIVE 1024 /* This is an interactive client */
#define CLIENT_SSL 2048 /* Switch to SSL after handshake */
#define CLIENT_IGNORE_SIGPIPE 4096 /* IGNORE sigpipes */
#define CLIENT_TRANSACTIONS 8192 /* Client knows about transactions */

Not all of these may work or be meaningful, but CLIENT_FOUND_ROWS does, at least.

In ogni caso non è affidabile in quanto alla fin-fine, sempre se non ho frainteso io, questo benedetto parametro fa si che il comportamento di mysql_affected_rows assuma lo stesso comportamento di mysql_num_rows ovvero è come se ti restituisca il numero dei record trovati.

infine per chiudere, dato che la mia esigenza prevede l'effettuazione di una serie di query che possono essere "SELECT", "UPDATE", "DELETE" ho per il momento optato per la seguente soluzione:

Codice PHP:
        $TypeQueryExe substr($query,0,6);

        
$DataBaseConnect->query($query);

        
$ResultQuery 0;
        if(
$TypeQueryExe == "UPDATE") {
          
$ResultQuery 1;
        }
        else
        if( (
$TypeQueryExe == "INSERT") || ($TypeQueryExe == "DELETE") ) {
          
$ResultQuery $DataBaseConnect->affected_rows();
        } 
In attesa che mi vengano idee migliori uso questo e poi vedrò di intercettare l'errore con:
or die(mysql_error())
da te giustamente citato.
Saluti ed ancora grazie per i consigli.
Se vi va potete anche continuare a darne che sono sempre utili.