Hi Ed,
RootsPersona 3.3.3 works fine with:
- PHP 7
- WordPress 4.5-alpha (nightly build)
as long as the following changes are made because the mysql extension was eliminated on PHP 7:
The mysql statements
$new_link = true;
$conn = mysql_connect( $credentials->hostname, $credentials->dbuser, $credentials->dbpassword, $new_link );
if ( ! $conn ) {
throw new Exception( 'could not connect to database' );
}
mysql_select_db( $credentials->dbname );
mysql_set_charset( 'utf8', $conn );
becomes the PDO equivalent:
try {
$dsn = 'mysql:host=' . $credentials->hostname . ';dbname=' . $credentials->dbname . ';charset=utf8';
$conn = new PDO($dsn, $credentials->dbuser, $credentials->dbpassword);
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
} catch(PDOException $e) {
echo 'ERROR: ' . $e->getMessage();
}
return $conn;
The mysql statements
return mysql_query( $sql, $this->connection );
becomes the PDO equivalent:
$stmt = $this->connection->prepare( $sql );
$stmt->execute();
return $stmt->fetchAll();
The mysql statements
while ( $row = mysql_fetch_array( $result ) ) {
$tab[$i++] = $row;
}
mysql_free_result( $result );
becomes the PDO equivalent:
foreach($result as $row) {
$tab[$i++] = $row;
}
The mysql statements
mysql_close( $connection );
becomes the PDO equivalent:
$connection = null;
The mysql statements
return mysql_affected_rows( $connection );
becomes the PDO equivalent:
return $result->rowCount();
The mysql statements
return mysql_insert_id();
becomes the PDO equivalent:
return $this->connection->lastInsertId();
The mysql statements
$row = mysql_fetch_array( $result );
becomes the PDO equivalent:
if ( $result[0] ) return $result[0][0];
The mysql statements
$this->connection->execute_query( 'BEGIN' );
becomes the PDO equivalent:
$this->connection->beginTransaction();
The mysql statements
$this->connection->execute_query( 'COMMIT' );
becomes the PDO equivalent:
$this->connection->commit();
The mysql statements
$this->connection->execute_query( 'ROLLBACK' );
becomes the PDO equivalent:
$this->connection->rollBack();
The mysql statements
$value = mysql_escape_string( $value );
is included in the PDO statement prepare( $sql )