The i5_ functions and db2_ functions are both fine. And they are not mutually exclusive. There's no reason why you couldn't use both.
If you plan to develop PHP on systems other than the AS400, then you may want to get into the habit of using the db2_ functions. The i5_ functions only work on the AS400. The db2_ functions will work on any platform running DB2.
Also, here is a list of the db2_ functions:
■ db2_autocommit - Returns or sets the AUTOCOMMIT state for a database connection
■ db2_bind_param - Binds a PHP variable to an SQL statement parameter
■ db2_client_info - Returns an object with properties that describe the DB2 database client
■ db2_close - Closes a database connection
■ db2_column_privileges - Returns a result set listing the columns and associated privileges for a table
■ db2_columns - Returns a result set listing the columns and associated metadata for a table
■ db2_commit - Commits a transaction
■ db2_conn_error - Returns a string containing the SQLSTATE returned by the last connection attempt
■ db2_conn_errormsg - Returns the last connection error message and SQLCODE value
■ db2_connect - Returns a connection to a database
■ db2_cursor_type - Returns the cursor type used by a statement resource
■ db2_escape_string - Used to escape certain characters
■ db2_exec - Executes an SQL statement directly
■ db2_execute - Executes a prepared SQL statement
■ db2_fetch_array - Returns an array, indexed by column position, representing a row in a result set
■ db2_fetch_assoc - Returns an array, indexed by column name, representing a row in a result set
■ db2_fetch_both - Returns an array, indexed by both column name and position, representing a row in a result set
■ db2_fetch_object - Returns an object with properties representing columns in the fetched row
■ db2_fetch_row - Sets the result set pointer to the next row or requested row
■ db2_field_display_size - Returns the maximum number of bytes required to display a column
■ db2_field_name - Returns the name of the column in the result set
■ db2_field_num - Returns the position of the named column in a result set
■ db2_field_precision - Returns the precision of the indicated column in a result set
■ db2_field_scale - Returns the scale of the indicated column in a result set
■ db2_field_type - Returns the data type of the indicated column in a result set
■ db2_field_width - Returns the width of the current value of the indicated column in a result set
■ db2_foreign_keys - Returns a result set listing the foreign keys for a table
■ db2_free_result - Frees resources associated with a result set
■ db2_free_stmt - Frees resources associated with the indicated statement resource
■ db2_get_option - Retrieves an option value for a statement resource or a connection resource
■ db2_last_insert_id - Returns the auto generated ID of the last insert query that successfully executed on this connection
■ db2_lob_read - Gets a user defined size of LOB files with each invocation
■ db2_next_result - Requests the next result set from a stored procedure
■ db2_num_fields - Returns the number of fields contained in a result set
■ db2_num_rows - Returns the number of rows affected by an SQL statement
■ db2_pclose - Closes a persistent database connection
■ db2_pconnect - Returns a persistent connection to a database
■ db2_prepare - Prepares an SQL statement to be executed
■ db2_primary_keys - Returns a result set listing primary keys for a table
■ db2_procedure_columns - Returns a result set listing stored procedure parameters
■ db2_procedures - Returns a result set listing the stored procedures registered in a database
■ db2_result - Returns a single column from a row in the result set
■ db2_rollback - Rolls back a transaction
■ db2_server_info - Returns an object with properties that describe the DB2 database server
■ db2_set_option - Set options for connection or statement resources
■ db2_special_columns - Returns a result set listing the unique row identifier columns for a table
■ db2_statistics - Returns a result set listing the index and statistics for a table
■ db2_stmt_error - Returns a string containing the SQLSTATE returned by an SQL statement
■ db2_stmt_errormsg - Returns a string containing the last SQL statement error message
■ db2_table_privileges - Returns a result set listing the tables and associated privileges in a database
■ db2_tables - Returns a result set listing the tables and associated metadata in a database
I don't believe you get all these functions in the PHP Toolkit.
Finally, PHP developers in the community at large will be more familiar with the DB2_ functions than the i5_ functions. This means a better chance of help in email lists and forums.
Still, I see db2_ and i5_ as two tools in my toolbox. I just happen to prefer the db2_ functions. I would the i5_ functions if I thought it made sense to do so.
Kelly
-----Original Message-----
From: web400-bounces@xxxxxxxxxxxx [mailto:web400-bounces@xxxxxxxxxxxx] On Behalf Of Porterfield, Sean
Sent: Thursday, December 03, 2009 6:42 PM
To: Web Enabling the AS400 / iSeries
Subject: Re: [WEB400] php vs net.data
I've been wondering about i5_ versus db2_ and still have no answer.
i5_fetch_array sounds just like db2_fetch_assoc
--
Sean Porterfield
________________________________________
From: Kelly Cookson
Here's a simple db2_ example. Suppose you wanted to read a file called
MYLIB/MEMBERS. The file has three fields: FNAME, LNAME, and PHONE.
//Connect to the database
$conn = db2_connect("", "", "")
or die(db2_conn_errormsg());
//Prepare the SQL Query for execution
$query = "SELECT * FROM MYLIB.MEMBERS";
$statement = db2_prepare($conn, $query)
or die(db2_stmt_errormsg());
//Execute the query
db2_execute($statement)
or die(db2_stmt_errormsg());
//Retrieve the results
while ($row = db2_fetch_assoc($statement))
{
$first_name = $row["FNAME"];
$last_name = $row["LNAME"];
$phone_number = $row["PHONE"];
//process or display the data
}
//Close the connection
db2_close($conn);
Hope that helps a little.
Kelly
This email is confidential, intended only for the named recipient(s) above and may contain information that is privileged. If you have received this message in error or are not the named recipient(s), please notify the sender immediately and delete this email message from your computer as any and all unauthorized distribution or use of this message is strictly prohibited. Thank you.
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact
[javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.