420 Part IV (Vps web hosting) . Development Figure 15-33 illustrates

420 Part IV . Development Figure 15-33 illustrates the fetchrow_arrayref() method. Notice that the first call retrieves the host from the query, and the second call actually retrieves the password corresponding to the second entry or second row of results. The third method call retrieves an entire row of results from the query at once. Not all interactions with the database require both a prepare()and execute() method call. The do()method enables you to execute statements without having to make two separate calls as with prepare() and execute(). Like the prepare() and execute() methods, do() can accept placeholders. The placeholders are question marks and should be included as the last argument of the do()method call. Figure 15-34 shows an example of do(). You cannot retrieve results using a do() method call, so it is not appropriate for SELECT statements. The do() method does return the number of rows affected by the statement. Therefore, it can be helpful to store this value for sanity checking. In other words, you can compare the number of returned rows to ensure that the value makes sense for the given query. Note Figure 15-34: Using the do() method call to execute a statement without having to prepare it in a separate statement Another method, dump_results(), can assist to print results for testing purposes while you are programming. dump_results() calls another method, neat_string(), to format the results and make them look nicer as output. The dump_results() method can take up to five arguments. The syntax is as follows: $result = DBI::dump_results($sth, $length, $line_break, $field_break, $filedes);
Searching for affordable and reliable webhost to host and run your web applications? Go to our java web server services and you will be pleased.

Leave a Reply