2013-04-11, 04:44 PM
Does the MyBB database class have any support for bind variables?
Something like:
->prepare ("INSERT INTO sometable ( field1, field2 ) VALUES ( ?, ? )")
and then later
->execute ( $val1, $val2 );
->execute ( $val3, $val4 );
->execute ( $val5, $val6);
etc. One prepare, many executions without having to to write_query every time a variable changes.
For busy databases, bind variables save a ton of CPU power because the query only needs to be parsed once instead of on every query. It also avoids the need to handle string escaping, etc. (I know the db class has a string escaping but I'm saying with bind variables you don't need to run it).
php supports bind variables (mysqli_bind_param, etc.)
Something like:
->prepare ("INSERT INTO sometable ( field1, field2 ) VALUES ( ?, ? )")
and then later
->execute ( $val1, $val2 );
->execute ( $val3, $val4 );
->execute ( $val5, $val6);
etc. One prepare, many executions without having to to write_query every time a variable changes.
For busy databases, bind variables save a ton of CPU power because the query only needs to be parsed once instead of on every query. It also avoids the need to handle string escaping, etc. (I know the db class has a string escaping but I'm saying with bind variables you don't need to run it).
php supports bind variables (mysqli_bind_param, etc.)