Gossamer Forum
Quote Reply
Format of alter_col
Hi,

In regards to this function:
Code:
$editor->alter_col($column_name,
{
size => 20,
type => 'int'
});

..what kind of format is required for the form_names/form_values ??

This is whats in my glinks_Links.def file:


Code:
'form_names' => [
'Affiliate 1',
'Affiliate 2'
],
'form_values' => [
'Affiliate 1',
'Affiliate 2'
],
..basically, what I need to do - is go through another table, and get a list of values, like:

Affiliate 1
Affiliate 2
Affiliate 3
Affiliate 4
Affiliate 5

..and then update the glink_Links table, depending on the values got.

TIA

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Quote Reply
Re: [Andy] Format of alter_col In reply to
Got a feeling I'm doing something wrong with invoking the alter_col function full stop :/


Code:
my $editor = $DB->editor('Links');
$editor->alter_col('PartOfAffiliate', {
form_name => 'tyest'
# form_names => $vals,
# form_values => $vals
}) || die $GT::SQL::error;


...gives an error:

Quote:
An error occured:

GT::SQL::Editor (8473): Wrong argument passed to this subroutine. Column definition does not have a SQL type defined at GT::SQL::Driver::column_sql line 525.

Please enable debugging in setup for more details.
...the column definatly exists, glink_Links.PartOfAffiliate .... mmm .. anyone got any suggestions? Unsure

Cheers

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Quote Reply
Re: [Andy] Format of alter_col In reply to
haha - I'm answering my own question again :P

Heres a solution that worked for me :

Code:
my $editor = $DB->editor('Links');
$editor->alter_col('PartOfAffiliate', {
type => 'CHAR',
size => '255',
form_names => 'test
test2
test3',
form_values => 'test
test2
test3'
}) || die $GT::SQL::error;

Basically, the "type" and "size" had to be passed in too, rather than only the changes I wanted done.

Just thought I would share, in case anyone else comes across the same problems in the future Smile

Cheers

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Quote Reply
Re: [Andy] Format of alter_col In reply to
Damn it - still having issues :(

Seems that for some reason, the TEXTAREA is not being filled correctly - I was thinking maybe it was cos it needed \r\n - and not just \n ... but that still didn't sort it :/

Code:
my $tbl = $DB->table('AffiliatePrograms');
$tbl->select_options('ORDER BY Name ASC');

my $sth = $tbl->select( ) || die $GT::SQL::error;

my @loop;
while (my $hit = $sth->fetchrow_hashref) {
push @loop, $hit->{Name};
}

print qq|<h2>Updated PartOfAffilite field, with the following entries:</h2>| . join('<br />',@loop);

my $editor = $DB->editor('Links');
$editor->alter_col('PartOfAffiliate', {
type => 'CHAR',
size => '255',
form_names => join("\r\n",@loop),
form_values => join("\r\n",@loop),
form_type => 'SELECT',
form_size => 1,
form_display=> 'Part of Affiliate Program'
}) || die $GT::SQL::error;

...shows fine in the .def file - but obvioulsy not quite formatted right :/

Code:
'PartOfAffiliate' => {
'form_display' => 'Part of Affiliate Program',
'form_names' => 'another test
Program 1
test',
'form_size' => '1',
'form_type' => 'SELECT',
'form_values' => 'another test
Program 1
test',
'pos' => '68',
'size' => '255',
'type' => 'CHAR'
},

Anyone got any suggestions?

Cheers

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Quote Reply
Re: [Andy] Format of alter_col In reply to
form_names and form_values should be array refs.

Adrian
Quote Reply
Re: [brewt] Format of alter_col In reply to
Hi,

Thanks - kinda got that - this just refuses to work though :/ (only gets one result). Maybe too early in the morning, and I'm missing something stupid? Tongue

Code:
my $tbl = $DB->table('AffiliatePrograms');
$tbl->select_options('ORDER BY Name ASC');

my $loop = $tbl->select( ['Name'] )->fetchrow_arrayref;

use Data::Dumper;
print Dumper($loop);

..just gives:

Code:
$VAR1 = [ 'another test' ];

Any ideas?

TIA

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Quote Reply
Re: [Andy] Format of alter_col In reply to
Umm, you're only fetching one row? I think you mean to do:

my @aps = $tbl->select('Name')->fetchall_list;

Adrian
Quote Reply
Re: [brewt] Format of alter_col In reply to
LOL, good point Tongue

Still having some problems though;

Code:
my $tbl = $DB->table('AffiliatePrograms');
$tbl->select_options('ORDER BY Name ASC');

my @results = $tbl->select('Name')->fetchall_list;
use Data::Dumper;
print Dumper(@results);


print qq|<h2>Updated PartOfAffilite field, with the following entries:</h2>| . join('<br />');

my $editor = $DB->editor('Links');
$editor->alter_col('PartOfAffiliate', {
type => 'CHAR',
size => '255',
form_names => @results,
form_values => @results,
form_type => 'SELECT',
form_size => 1,
form_display=> 'Part of Affiliate Program'
}) || die $GT::SQL::error;

..prints out:

Code:
$VAR1 = 'another test'; $VAR2 = 'Program 1'; $VAR3 = 'test';
..but it only puts the first value into the form_values and form_names Unsure

Think I need to go make a coffee or 2 Crazy

TIA

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Quote Reply
Re: [Andy] Format of alter_col In reply to
Again, form_names and form_values are supposed to be array refs.

Adrian
Quote Reply
Re: [brewt] Format of alter_col In reply to
Sorry, being really dense still Frown

Code:
sub UpdateLinksTable {

print $IN->header;

print $css;

my $tbl = $DB->table('AffiliatePrograms');
$tbl->select_options('ORDER BY Name ASC');

my $results = $tbl->select( ['Name'] )->fetchall_arrayref;
use Data::Dumper;
print Dumper($results);

# print qq|<h2>Updated PartOfAffilite field, with the following entries:</h2>| . join('<br />');

my $editor = $DB->editor('Links');
$editor->alter_col('PartOfAffiliate', {
type => 'CHAR',
size => '255',
form_names => $results,
form_values => $results,
form_type => 'SELECT',
form_size => 1,
form_display=> 'Part of Affiliate Program'
}) || die $GT::SQL::error;

print qq|<br /><br />DONE|;

}


..this bit seems to look ok;

print Dumper($results);

..yet the values show up as:

Quote:
ARRAY(0x8fd314c)
ARRAY(0x8fd3170)
ARRAY(0x8fd3194)

Frown

Sorry to keep bugging you with this one. Had a bit of a heavy night last night and my heads killing me :(

TIA

Andy (mod)
andy@ultranerds.co.uk


IMPORTANT: I've now moved to ultranerds.co.uk, and the .com will no longer work!
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package (plugins total "value" $3,325 & rising, for just $350)| GLinks ULTRA Package PRO (plugins total "value" $5,625 & rising, for just $500)
Support Forum | Links SQL Plugins | DMOZ Dumps | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
Compare our different Plugin packages *new* Free CSS Templates
Quote Reply
Re: [Andy] Format of alter_col In reply to
Oh my gosh.

Andy, try to find out what fetchall_arrayref is returning and you'll realise it's not just an array reference, hence the incorrect display of your form fields as ARRAY(0x8fd3170), etc.

BIG HINT: fetchall_arrayref returns a REFERENCE of references and not just an array reference.

If you had taken care to read Adrian's response and use his example, you'd have the code working already, probably.

Quote:
Had a bit of a heavy night last night and my heads killing me :(

Having a hang over doesn't remove your ability to write Perl code - the ability was never there in the first place.

Last edited by:

Wychwood: Jul 15, 2008, 2:19 AM