Name
Msql::Statement::type
Synopsis
@column_types = $statement_handle->type;
Msql::Statement::type
returns the types of the
columns of data contained in the statement handle. When called in a
scalar context the function returns a reference to an array. The pure
value of this array is not of much use to most users (in the current
implementation it is a list of integers). Rather, the values can be
compared to the built-in values defined in Msql.pm such as
&Msql::CHAR_TYPE
and
&Msql::INT_TYPE
. One method of accessing this
data is to build an array matching readable names to the predefined
types. This method was demonstrated in Chapter 10.
Another method is demonstrated below.
Example
use Msql; my $db = Msql->connect; $db->selectdb('mydata'); my $output = $db->query("select name, date from myothertable"); my ($name_type, $date_type) = $output->type; for ($name_type) { $_ eq &Msql::CHAR_TYPE and do { print 'name is a CHAR'; last; } $_ eq &Msql::INT_TYPE and do { print 'name is an INT'; last; } # etc... } # repeat for $date_type
Get MySQL and mSQL now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.