Domanda

Questo mi sta sconcertando. Ho una query MySQL, in esecuzione tramite PDO:

$stmt = $db->prepare( "UPDATE member SET acode='' AND status='active' WHERE username=:u" );
$stmt->bindValue( ':u', $member->username, PDO::PARAM_STR );
$stmt->execute();

Il campo acode viene impostato su 0 per qualche motivo. È stato creato con

`acode` varchar(8) NOT NULL

C'è qualcosa di speciale che devo fare quando uso dichiarazioni preparate?

È stato utile?

Soluzione

Gidday,

Il problema si presenta con questa parte della tua query:

SET acode='' AND status='active'

l'AND lo trasforma nel controllo booleano di '' AND status = 'active', che restituisce 0. Modifica la tua query in:

SET acode='', status='active'
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top