DBD-DBMaker

 view release on metacpan or  search on metacpan

DBMaker.pm  view on Meta::CPAN

Example:
 
  ... = $h->{NUM_OF_FIELDS};    # get/read

=over 4

=item NUM_OF_FIELDS (integer)  read-only

Number of fields (columns) the prepared statement will return. Non-select
statements will have NUM_OF_FIELDS = 0.

=item NUM_OF_PARAMS (integer)  read-only

The number of parameters (placeholders) in the prepared statement.

=item NAME (array-ref)         read-only

Returns a *reference* to an array of field names for each column.

  Example: 
  print "First column name: $sth->{NAME}->[0]\n";

=item NAME_lc (array-ref)      read-only

Like the NAME entry elsewhere in this document but always returns lowercase 
names.

=item NAME_uc (array-ref)      read-only

Like the NAME entry elsewhere in this document but always returns uppercase
names.

=item TYPE (array-ref)         read-only

Returns a *reference* to an array of integer values for each column.  The
value indicates the data type of the corresponding column.

=item PRECISION (array-ref)    read-only

Returns a *reference* to an array of integer values for each column.  For
nonnumeric columns the value generally refers to either the maximum length
or the defined length of the column. For numeric columns the value refers 
to the maximum number of significant digits used by the data type (without
considering a sign character or decimal point). 

=item SCALE (array-ref)        read-only

Returns a *reference* to an array of integer values for each column.  NULL
(undef) values indicate columns where scale is not applicable. 

=item NULLABLE (array-ref)     read-only

Returns a *reference* to an array indicating the possibility of each column
returning a null: 0 = no, 1 = yes.

  Example: 
  print "First column may return NULL\n" if $sth->{NULLABLE}->[0];

=item CursorName (string)      read-only

Returns the name of the cursor associated with the statement handle if
available.

=item Statement (string)       read-only

Returns the statement string passed to the the prepare entry elsewhere in
this document method.

=item RowsInCache (integer)    read-only, currently return undef.

If the driver supports a local row cache for select statements then this
attribute holds the number of un-fetched rows in the cache.  Currently
DBMaker will return undef for this value, while DBMaker will prefetch about
8K size's data into client side.

=back

=head2 Handling BLOB Fields with DBMaker

DBMaker support LONG VARCHAR, LONG VARBINARY and FILE data type
for user to store BLOB in the database.  For easier handling with
blob input/output, DBMaker support the following method for user to
store their blob file into the database or retrieve their blob data
to a user local file.

=over 4

=item Use file as input parameter to a BLOB column

Statement Attribute: dbmaker_file_input (default is 1)

a. Store file content for BLOB field

When this attribute value is 1 and user add quote for a file name as 
input parameter value, and the parameter's SQL type is SQL_LONGVARCHAR/
SQL_LONGVARBINARY/SQL_FILE, DBMaker will store the file's content into
database.

  Example:
  $dbh->do("create table blobt1 (c1 long varchar)");
  my $sql=qq{INSERT INTO blobt1 values(?)};
  my $sth = $dbh->prepare($sql);
 
  # By default, DBMaker will try to open a blob file name (for example: test.gif), 
  # read the file and then store into the database
  $sth->bind_param(1,"'test.gif'");
  $sth->execute();

  # If you want to store a blob file name (for example: test.gif) with string quote 
  # into database
  $sth->{dbmaker_file_input} = 0;
  $sth->bind_param(1,"'test.gif'");
  $sth->execute();

You can select c1 from this table and see what's the difference between these two
insert.

b. Store file name only for FILE column

When dbmaker_file_input statement attribute sets on, there are 
difference when you input file name with or without single quote for



( run in 0.722 second using v1.01-cache-2.11-cpan-39bf76dae61 )