11.07.2015 Views

PHP MySQL - Stilson.net

PHP MySQL - Stilson.net

PHP MySQL - Stilson.net

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

www.it-ebooks.infoCHAPTER 30 • USING <strong>PHP</strong> WITH MYSQLExactly what “Do something…” refers to in the preceding code will become apparent as you learnmore about the other relevant methods, which are introduced next.Executing a Prepared StatementOnce the statement has been prepared, it needs to be executed. Exactly when it’s executed dependsupon whether you want to work with bound parameters or bound results. In the case of boundparameters, you’d execute the statement after the parameters have been bound (with the bind_param()method, introduced later in this section). In the case of bound results, you would execute this methodbefore binding the results with the bind_result() method, also introduced later in this section. In eithercase, executing the statement is accomplished using the execute() method. Its prototype follows:class stmt {boolean execute()}See the later introductions to bind_param() and bind_result() for examples of execute() in action.Recuperating Prepared Statement ResourcesOnce you’ve finished using a prepared statement, the resources it requires can be recuperated with theclose() method. Its prototype follows:class stmt {boolean close()}See the earlier introduction to prepare() for an example of this method in action.Binding ParametersWhen using the bound-parameter prepared statement variant, you need to call the bind_param()method to bind variable names to corresponding fields. Its prototype follows:class stmt {boolean bind_param(string types, mixed &var1 [, mixed &varN])}The types parameter represents the datatypes of each respective variable to follow (represented by&var1, … &varN) and is required to ensure the most efficient encoding of this data when it’s sent to theserver. At present, four type codes are available:i: All INTEGER typesd: The DOUBLE and FLOAT typesb: The BLOB typess: All other types (including strings)601

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!