Login | Register For Free | Help
Search for: (Advanced)

Mailing List Archive: Bricolage: users

Finding Stories by Type

 

 

Bricolage users RSS feed   Index | Next | Previous | View Threaded


smith_t at denison

Jul 15, 2008, 7:47 AM

Post #1 of 21 (515 views)
Permalink
Finding Stories by Type

So I am trying to get a list of all Stories of a certain type within
all subdirectories and so according to the api I am trying to use this
function:
my @subcats = list Bric::Biz::Category(parent_id -> $cat);
Where $cat was defined by:
my $cat = $story->get_primary_category->get_id;
However I am getting this error, which is probably just due to my
novice skills at bricolage:
Can't locate object method "1362" via package "parent_id"
(perhaps you forgot to load "parent_id"?) at
/usr/local/bricolage/data/burn/sandbox/user_1368/oc_1/event_widget.mc
line 16, <GEN545> line 460.

Any help would be very much appreciated, thanks in advance! Also does
this function only get a list of the next level of directories, or all
subdirectories? Thanks.

-Trevor


lannings at who

Jul 15, 2008, 7:51 AM

Post #2 of 21 (504 views)
Permalink
Re: Finding Stories by Type [In reply to]

On Tue, 15 Jul 2008, Trevor Smith wrote:
> my @subcats = list Bric::Biz::Category(parent_id -> $cat);

fat arrow, =>
not ->


smith_t at denison

Jul 15, 2008, 7:53 AM

Post #3 of 21 (503 views)
Permalink
Re: Finding Stories by Type [In reply to]

Thanks however, now I am getting this error:
Can't use string ("parent_id") as a HASH ref while "strict refs" in
use at /usr/local/bricolage/lib/Bric/Biz/Category.pm line 1581,
<GEN546> line 461.

Is this just how we have our server configured?

-Trevor

On Tue, Jul 15, 2008 at 10:51 AM, Scott Lanning <lannings[at]who.int> wrote:
> On Tue, 15 Jul 2008, Trevor Smith wrote:
>>
>> my @subcats = list Bric::Biz::Category(parent_id -> $cat);
>
> fat arrow, =>
> not ->
>


rolfm at denison

Jul 15, 2008, 7:55 AM

Post #4 of 21 (504 views)
Permalink
Re: Finding Stories by Type [In reply to]

On Jul 15, 2008, at 10:53 AM, Trevor Smith wrote:

> Is this just how we have our server configured?

No.


lannings at who

Jul 15, 2008, 7:57 AM

Post #5 of 21 (504 views)
Permalink
Re: Finding Stories by Type [In reply to]

On Tue, 15 Jul 2008, Trevor Smith wrote:
> Thanks however, now I am getting this error:
> Can't use string ("parent_id") as a HASH ref while "strict refs" in
> use at /usr/local/bricolage/lib/Bric/Biz/Category.pm line 1581,
> <GEN546> line 461.

Methods usually have a hashref passed to them:

my @subcats = list Bric::Biz::Category({parent_id -> $cat});

Also, as for it recursing, no it doesn't.
Probably easier to do ->get_uri on the category you got,
then pass it to Bric::Biz::Category->list({uri => "$uri%"});


smith_t at denison

Jul 15, 2008, 8:15 AM

Post #6 of 21 (503 views)
Permalink
Re: Finding Stories by Type [In reply to]

Thanks, so I tried to fix it using this line:
my @subcats = Bric::Biz::Category->list({'parent_id' => $cat});
But instead I got a massive error:

Unable to execute SQL statement

Cannot bind a reference (Bric::Biz::Category=HASH(0xb7163ad8))
((null)) (0) type=7 10 4 0 at
/usr/local/bricolage/lib/Bric/Util/DBI.pm line 1087, <GEN479> line
634.

Stack:
[/usr/local/bricolage/lib/Bric/Util/DBI.pm:1087]
[/usr/local/bricolage/lib/Bric/Util/DBI.pm:730]
[/usr/local/bricolage/lib/Bric/Biz/Asset.pm:312]
[/usr/local/bricolage/data/burn/sandbox/user_1368/oc_1/event_widget.mc:18]
[/usr/local/lib/perl5/site_perl/5.8.8/HTML/Mason/Component.pm:135]
[/usr/local/bricolage/lib/Bric/Util/Burner/Mason.pm:752]
[/usr/local/bricolage/lib/Bric/Util/Burner/Mason.pm:491]
[/usr/local/bricolage/data/burn/comp/oc_1/widgets.mc:31]
[/usr/local/lib/perl5/site_perl/5.8.8/HTML/Mason/Component.pm:135]
[/usr/local/bricolage/data/burn/comp/oc_1/autohandler:125]
[/usr/local/lib/perl5/site_perl/5.8.8/HTML/Mason/Component.pm:135]


On Tue, Jul 15, 2008 at 10:57 AM, Scott Lanning <lannings[at]who.int> wrote:
> On Tue, 15 Jul 2008, Trevor Smith wrote:
>>
>> Thanks however, now I am getting this error:
>> Can't use string ("parent_id") as a HASH ref while "strict refs" in
>> use at /usr/local/bricolage/lib/Bric/Biz/Category.pm line 1581,
>> <GEN546> line 461.
>
> Methods usually have a hashref passed to them:
>
> my @subcats = list Bric::Biz::Category({parent_id -> $cat});
>
> Also, as for it recursing, no it doesn't.
> Probably easier to do ->get_uri on the category you got,
> then pass it to Bric::Biz::Category->list({uri => "$uri%"});
>


david at kineticode

Jul 15, 2008, 11:13 AM

Post #7 of 21 (498 views)
Permalink
Re: Finding Stories by Type [In reply to]

On Jul 15, 2008, at 08:15, Trevor Smith wrote:

> Thanks, so I tried to fix it using this line:
> my @subcats = Bric::Biz::Category->list({'parent_id' => $cat});
> But instead I got a massive error:
>
> Unable to execute SQL statement
>
> Cannot bind a reference (Bric::Biz::Category=HASH(0xb7163ad8))
> ((null)) (0) type=7 10 4 0 at
> /usr/local/bricolage/lib/Bric/Util/DBI.pm line 1087, <GEN479> line
> 634.

Looks like $cat is a category object, rather than an ID. Try

my @subcats = Bric::Biz::Category->list({ parent_id => $cat-
>get_id });

Best,

David


smith_t at denison

Jul 15, 2008, 11:48 AM

Post #8 of 21 (498 views)
Permalink
Re: Finding Stories by Type [In reply to]

thanks but now i'm getting this error again:

Can't call method "get_id" without a package or object reference at
/usr/local/bricolage/data/burn/sandbox/user_1368/oc_1/event_widget.mc
line 14, <GEN403> line 3690.

lol, why is this so hard?

T

On Tue, Jul 15, 2008 at 2:13 PM, David E. Wheeler <david[at]kineticode.com> wrote:
> On Jul 15, 2008, at 08:15, Trevor Smith wrote:
>
>> Thanks, so I tried to fix it using this line:
>> my @subcats = Bric::Biz::Category->list({'parent_id' => $cat});
>> But instead I got a massive error:
>>
>> Unable to execute SQL statement
>>
>> Cannot bind a reference (Bric::Biz::Category=HASH(0xb7163ad8))
>> ((null)) (0) type=7 10 4 0 at
>> /usr/local/bricolage/lib/Bric/Util/DBI.pm line 1087, <GEN479> line
>> 634.
>
> Looks like $cat is a category object, rather than an ID. Try
>
> my @subcats = Bric::Biz::Category->list({ parent_id => $cat->get_id });
>
> Best,
>
> David
>


david at kineticode

Jul 15, 2008, 12:08 PM

Post #9 of 21 (499 views)
Permalink
Re: Finding Stories by Type [In reply to]

On Jul 15, 2008, at 11:48, Trevor Smith wrote:

> thanks but now i'm getting this error again:
>
> Can't call method "get_id" without a package or object reference at
> /usr/local/bricolage/data/burn/sandbox/user_1368/oc_1/event_widget.mc
> line 14, <GEN403> line 3690.
>
> lol, why is this so hard?

Okay, so it wasn't an ID. So this should work:

my @subcats = Bric::Biz::Category->list({ parent_id => $cat });

But that's what you had before, isn't it?

Best,

David


smith_t at denison

Jul 15, 2008, 12:12 PM

Post #10 of 21 (498 views)
Permalink
Re: Finding Stories by Type [In reply to]

yeah thats what I had and I tried it again and it returns this error:

Unable to execute SQL statement

Cannot bind a reference (Bric::Biz::Category=HASH(0xd0b38ac)) ((null))
(0) type=7 10 4 0 at /usr/local/bricolage/lib/Bric/Util/DBI.pm line
1087, <GEN237> line 3687.

Stack:
[/usr/local/bricolage/lib/Bric/Util/DBI.pm:1087]
[/usr/local/bricolage/lib/Bric/Util/DBI.pm:730]
[/usr/local/bricolage/lib/Bric/Biz/Asset.pm:312]
[/usr/local/bricolage/data/burn/sandbox/user_1368/oc_1/event_widget.mc:16]
[/usr/local/lib/perl5/site_perl/5.8.8/HTML/Mason/Component.pm:135]
[/usr/local/bricolage/lib/Bric/Util/Burner/Mason.pm:752]
[/usr/local/bricolage/lib/Bric/Util/Burner/Mason.pm:491]
[/usr/local/bricolage/data/burn/comp/oc_1/widgets.mc:31]
[/usr/local/lib/perl5/site_perl/5.8.8/HTML/Mason/Component.pm:135]
[/usr/local/bricolage/data/burn/sandbox/user_1368/oc_1/autohandler:147]
[/usr/local/lib/perl5/site_perl/5.8.8/HTML/Mason/Component.pm:135]


On Tue, Jul 15, 2008 at 3:08 PM, David E. Wheeler <david[at]kineticode.com> wrote:
> On Jul 15, 2008, at 11:48, Trevor Smith wrote:
>
>> thanks but now i'm getting this error again:
>>
>> Can't call method "get_id" without a package or object reference at
>> /usr/local/bricolage/data/burn/sandbox/user_1368/oc_1/event_widget.mc
>> line 14, <GEN403> line 3690.
>>
>> lol, why is this so hard?
>
> Okay, so it wasn't an ID. So this should work:
>
> my @subcats = Bric::Biz::Category->list({ parent_id => $cat });
>
> But that's what you had before, isn't it?
>
> Best,
>
> David
>


david at kineticode

Jul 15, 2008, 12:26 PM

Post #11 of 21 (491 views)
Permalink
Re: Finding Stories by Type [In reply to]

On Jul 15, 2008, at 12:12, Trevor Smith wrote:

> yeah thats what I had and I tried it again and it returns this error:
>
> Unable to execute SQL statement
>
> Cannot bind a reference (Bric::Biz::Category=HASH(0xd0b38ac)) ((null))
> (0) type=7 10 4 0 at /usr/local/bricolage/lib/Bric/Util/DBI.pm line
> 1087, <GEN237> line 3687.
>
> Stack:
> [/usr/local/bricolage/lib/Bric/Util/DBI.pm:1087]
> [/usr/local/bricolage/lib/Bric/Util/DBI.pm:730]
> [/usr/local/bricolage/lib/Bric/Biz/Asset.pm:312]
> [/usr/local/bricolage/data/burn/sandbox/user_1368/oc_1/
> event_widget.mc:16]


What's at line 16 of event_widget.mc? That's not your call to Category-
>list()…

Best,

David


smith_t at denison

Jul 15, 2008, 12:41 PM

Post #12 of 21 (491 views)
Permalink
Re: Finding Stories by Type [In reply to]

Wow, yeah you are right, not sure how I missed that. This is that
segment of code:

my $elem = 'event';
my @subcats = Bric::Biz::Category->list({ parent_id => $cat });
foreach (@subcats){
my @sttemp = Bric::Biz::Asset::Business::Story->list({ site_id =>
$story->get_site_id, category_id => $_, limit => 20, active => 1,
unexpired => 1, publish_status => 0, element_key_name => $elem });
push(@stories, @sttemp);
}

I'm trying to generate a list of all stories with the type 'event' in
the subdirectories. Line 16 is the my $sttemp... line.

T

On Tue, Jul 15, 2008 at 3:26 PM, David E. Wheeler <david[at]kineticode.com> wrote:
> On Jul 15, 2008, at 12:12, Trevor Smith wrote:
>
>> yeah thats what I had and I tried it again and it returns this error:
>>
>> Unable to execute SQL statement
>>
>> Cannot bind a reference (Bric::Biz::Category=HASH(0xd0b38ac)) ((null))
>> (0) type=7 10 4 0 at /usr/local/bricolage/lib/Bric/Util/DBI.pm line
>> 1087, <GEN237> line 3687.
>>
>> Stack:
>> [/usr/local/bricolage/lib/Bric/Util/DBI.pm:1087]
>> [/usr/local/bricolage/lib/Bric/Util/DBI.pm:730]
>> [/usr/local/bricolage/lib/Bric/Biz/Asset.pm:312]
>>
>> [/usr/local/bricolage/data/burn/sandbox/user_1368/oc_1/event_widget.mc:16]
>
>
> What's at line 16 of event_widget.mc? That's not your call to
> Category->list()…
>
> Best,
>
> David


smith_t at denison

Jul 15, 2008, 1:15 PM

Post #13 of 21 (491 views)
Permalink
Re: Finding Stories by Type [In reply to]

Just fyi, I'm still getting the same error:

Unable to execute SQL statement

Cannot bind a reference (Bric::Biz::Category=HASH(0xd40ff58)) ((null))
(0) type=7 10 4 0 at /usr/local/bricolage/lib/Bric/Util/DBI.pm line
1087, <GEN181> line 3687.

Stack:
[/usr/local/bricolage/lib/Bric/Util/DBI.pm:1087]
[/usr/local/bricolage/lib/Bric/Util/DBI.pm:730]
[/usr/local/bricolage/lib/Bric/Biz/Asset.pm:312]
[/usr/local/bricolage/data/burn/sandbox/user_1368/oc_1/event_widget.mc:16]
[/usr/local/lib/perl5/site_perl/5.8.8/HTML/Mason/Component.pm:135]
[/usr/local/bricolage/lib/Bric/Util/Burner/Mason.pm:752]
[/usr/local/bricolage/lib/Bric/Util/Burner/Mason.pm:491]
[/usr/local/bricolage/data/burn/comp/oc_1/widgets.mc:31]
[/usr/local/lib/perl5/site_perl/5.8.8/HTML/Mason/Component.pm:135]
[/usr/local/bricolage/data/burn/sandbox/user_1368/oc_1/autohandler:147]
[/usr/local/lib/perl5/site_perl/5.8.8/HTML/Mason/Component.pm:135]


Thanks for all your help so far guys.

T

On Tue, Jul 15, 2008 at 3:41 PM, Trevor Smith <smith_t[at]denison.edu> wrote:
> Wow, yeah you are right, not sure how I missed that. This is that
> segment of code:
>
> my $elem = 'event';
> my @subcats = Bric::Biz::Category->list({ parent_id => $cat });
> foreach (@subcats){
> my @sttemp = Bric::Biz::Asset::Business::Story->list({ site_id =>
> $story->get_site_id, category_id => $_, limit => 20, active => 1,
> unexpired => 1, publish_status => 0, element_key_name => $elem });
> push(@stories, @sttemp);
> }
>
> I'm trying to generate a list of all stories with the type 'event' in
> the subdirectories. Line 16 is the my $sttemp... line.
>
> T
>
> On Tue, Jul 15, 2008 at 3:26 PM, David E. Wheeler <david[at]kineticode.com> wrote:
>> On Jul 15, 2008, at 12:12, Trevor Smith wrote:
>>
>>> yeah thats what I had and I tried it again and it returns this error:
>>>
>>> Unable to execute SQL statement
>>>
>>> Cannot bind a reference (Bric::Biz::Category=HASH(0xd0b38ac)) ((null))
>>> (0) type=7 10 4 0 at /usr/local/bricolage/lib/Bric/Util/DBI.pm line
>>> 1087, <GEN237> line 3687.
>>>
>>> Stack:
>>> [/usr/local/bricolage/lib/Bric/Util/DBI.pm:1087]
>>> [/usr/local/bricolage/lib/Bric/Util/DBI.pm:730]
>>> [/usr/local/bricolage/lib/Bric/Biz/Asset.pm:312]
>>>
>>> [/usr/local/bricolage/data/burn/sandbox/user_1368/oc_1/event_widget.mc:16]
>>
>>
>> What's at line 16 of event_widget.mc? That's not your call to
>> Category->list()…
>>
>> Best,
>>
>> David
>


greg at node79

Jul 15, 2008, 1:17 PM

Post #14 of 21 (492 views)
Permalink
Re: Finding Stories by Type [In reply to]

On 15-Jul-08, at 3:41 PM, Trevor Smith wrote:

> my $elem = 'event';
> my @subcats = Bric::Biz::Category->list({ parent_id => $cat });
> foreach (@subcats){
> my @sttemp = Bric::Biz::Asset::Business::Story->list({ site_id =>
> $story->get_site_id, category_id => $_, limit => 20, active => 1,
> unexpired => 1, publish_status => 0, element_key_name => $elem });
> push(@stories, @sttemp);
> }


I think the category_id is the problem...@subcats is a list of
category objects, not category IDs. So that bit of the hash should be:

category_id => $_->get_id



---
Greg Heo
web/software systems developer
greg[at]node79.com
416.826.7630


smith_t at denison

Jul 15, 2008, 1:22 PM

Post #15 of 21 (491 views)
Permalink
Re: Finding Stories by Type [In reply to]

Wow, yay! It works now. Thanks everyone for all their help today.
Special thanks to David, Greg, and Scott. :)

-Trevor

On Tue, Jul 15, 2008 at 4:17 PM, Greg Heo <greg[at]node79.com> wrote:
>
> On 15-Jul-08, at 3:41 PM, Trevor Smith wrote:
>
>> my $elem = 'event';
>> my @subcats = Bric::Biz::Category->list({ parent_id => $cat });
>> foreach (@subcats){
>> my @sttemp = Bric::Biz::Asset::Business::Story->list({ site_id =>
>> $story->get_site_id, category_id => $_, limit => 20, active => 1,
>> unexpired => 1, publish_status => 0, element_key_name => $elem });
>> push(@stories, @sttemp);
>> }
>
>
> I think the category_id is the problem...@subcats is a list of category
> objects, not category IDs. So that bit of the hash should be:
>
> category_id => $_->get_id
>
>
>
> ---
> Greg Heo
> web/software systems developer
> greg[at]node79.com
> 416.826.7630
>
>
>
>


david at kineticode

Jul 15, 2008, 1:44 PM

Post #16 of 21 (491 views)
Permalink
Re: Finding Stories by Type [In reply to]

On Jul 15, 2008, at 13:22, Trevor Smith wrote:

> Wow, yay! It works now. Thanks everyone for all their help today.
> Special thanks to David, Greg, and Scott. :)

If you don't need the category objects, use Category->list_ids(),
instead. Much more efficient.

Best,

David


smith_t at denison

Jul 16, 2008, 5:17 AM

Post #17 of 21 (481 views)
Permalink
Re: Finding Stories by Type [In reply to]

Can you show me where and how to use this in my code? Thanks.

-Trevor

On Tue, Jul 15, 2008 at 4:44 PM, David E. Wheeler <david[at]kineticode.com> wrote:
>
> If you don't need the category objects, use Category->list_ids(), instead.
> Much more efficient.
>
> Best,
>
> David
>


lannings at who

Jul 16, 2008, 7:42 AM

Post #18 of 21 (481 views)
Permalink
RE: Finding Stories by Type [In reply to]

Just instead of using Bric::Biz::Category->list,
which returns Category objects
(so you have to call $_->get_id for each object),
use Bric::Biz::Category->list_ids directly.
Then the objects aren't created, which is a relatively
expensive thing to do (if you only need ID numbers).

-----Original Message-----
From: smith.t.denison[at]gmail.com on behalf of Trevor Smith
Sent: Wed 7/16/2008 2:17 PM
To: users[at]lists.bricolage.cc
Subject: Re: Finding Stories by Type

Can you show me where and how to use this in my code? Thanks.

-Trevor

On Tue, Jul 15, 2008 at 4:44 PM, David E. Wheeler <david[at]kineticode.com> wrote:
>
> If you don't need the category objects, use Category->list_ids(), instead.
> Much more efficient.
>
> Best,
>
> David
>


smith_t at denison

Jul 16, 2008, 8:49 AM

Post #19 of 21 (479 views)
Permalink
Re: Finding Stories by Type [In reply to]

I'm trying to use what you suggested in this code to return a list of
all the stories in these three directories:

my $subcat = Bric::Biz::Category->list_ids({ uri =>
'/offices/computing/facilities/computerlabs/' });
@stories = Bric::Biz::Asset::Business::Story->list({ category_id =>
$subcat, active => 1, unexpired => 1 });
$subcat = Bric::Biz::Category->list_ids({ uri =>
'/offices/computing/facilities/eclassrooms/' });
@stories = push(@stories,Bric::Biz::Asset::Business::Story->list({
category_id => $subcat->get_id, active => 1, unexpired => 1 }));
$subcat = Bric::Biz::Category->list_ids({ uri =>
'/offices/computing/facilities/laptopcarts/' });
@stories = push(@stories,Bric::Biz::Asset::Business::Story->list({
category_id => $subcat->get_id, active => 1, unexpired => 1 }));

I keep generating the same SQL error as seen here:

Unable to execute SQL statement

Cannot bind a reference (ARRAY(0xfa8eee8)) ((null)) (1) type=7 10 4 0
at /usr/local/bricolage/lib/Bric/Util/DBI.pm line 1087, <GEN950> line
460.

Stack:
[/usr/local/bricolage/lib/Bric/Util/DBI.pm:1087]
[/usr/local/bricolage/lib/Bric/Util/DBI.pm:730]
[/usr/local/bricolage/lib/Bric/Biz/Asset.pm:312]
[/usr/local/bricolage/data/burn/sandbox/user_1368/oc_1/software_index.mc:28]
[/usr/local/lib/perl5/site_perl/5.8.8/HTML/Mason/Component.pm:135]
[/usr/local/bricolage/lib/Bric/Util/Burner/Mason.pm:557]
[/usr/local/bricolage/data/burn/sandbox/user_1368/oc_1/autohandler:144]
[/usr/local/lib/perl5/site_perl/5.8.8/HTML/Mason/Component.pm:135]

Another stupid syntax error? Thanks.

-Trevor

On Wed, Jul 16, 2008 at 10:42 AM, Lanning, Scott <lannings[at]who.int> wrote:
> Just instead of using Bric::Biz::Category->list,
> which returns Category objects
> (so you have to call $_->get_id for each object),
> use Bric::Biz::Category->list_ids directly.
> Then the objects aren't created, which is a relatively
> expensive thing to do (if you only need ID numbers).
>
> -----Original Message-----
> From: smith.t.denison[at]gmail.com on behalf of Trevor Smith
> Sent: Wed 7/16/2008 2:17 PM
> To: users[at]lists.bricolage.cc
> Subject: Re: Finding Stories by Type
>
> Can you show me where and how to use this in my code? Thanks.
>
> -Trevor
>
> On Tue, Jul 15, 2008 at 4:44 PM, David E. Wheeler <david[at]kineticode.com> wrote:
>>
>> If you don't need the category objects, use Category->list_ids(), instead.
>> Much more efficient.
>>
>> Best,
>>
>> David
>>
>
>


phillip at communitybandwidth

Jul 16, 2008, 9:21 AM

Post #20 of 21 (479 views)
Permalink
Re: Finding Stories by Type [In reply to]

Trevor,

Have you taken a look at the archive_list.mc template from the
bricolage.cc templates:
https://www.buildingbrics.com/trac/browser/trunk/example_sites/bricolage.cc-1.4/templates/Library/util/archive_list.mc

I adjusted this at one point to allow multiple categories. The other
approach is just to use it once for each category (if there are only a
few).

Phillip.

On 16-Jul-08, at 11:49 AM, Trevor Smith wrote:

> I'm trying to use what you suggested in this code to return a list of
> all the stories in these three directories:
>
> my $subcat = Bric::Biz::Category->list_ids({ uri =>
> '/offices/computing/facilities/computerlabs/' });
> @stories = Bric::Biz::Asset::Business::Story->list({ category_id =>
> $subcat, active => 1, unexpired => 1 });
> $subcat = Bric::Biz::Category->list_ids({ uri =>
> '/offices/computing/facilities/eclassrooms/' });
> @stories = push(@stories,Bric::Biz::Asset::Business::Story->list({
> category_id => $subcat->get_id, active => 1, unexpired => 1 }));
> $subcat = Bric::Biz::Category->list_ids({ uri =>
> '/offices/computing/facilities/laptopcarts/' });
> @stories = push(@stories,Bric::Biz::Asset::Business::Story->list({
> category_id => $subcat->get_id, active => 1, unexpired => 1 }));
>
> I keep generating the same SQL error as seen here:
>
> Unable to execute SQL statement
>
> Cannot bind a reference (ARRAY(0xfa8eee8)) ((null)) (1) type=7 10 4 0
> at /usr/local/bricolage/lib/Bric/Util/DBI.pm line 1087, <GEN950> line
> 460.
>
> Stack:
> [/usr/local/bricolage/lib/Bric/Util/DBI.pm:1087]
> [/usr/local/bricolage/lib/Bric/Util/DBI.pm:730]
> [/usr/local/bricolage/lib/Bric/Biz/Asset.pm:312]
> [/usr/local/bricolage/data/burn/sandbox/user_1368/oc_1/
> software_index.mc:28]
> [/usr/local/lib/perl5/site_perl/5.8.8/HTML/Mason/Component.pm:135]
> [/usr/local/bricolage/lib/Bric/Util/Burner/Mason.pm:557]
> [/usr/local/bricolage/data/burn/sandbox/user_1368/oc_1/autohandler:
> 144]
> [/usr/local/lib/perl5/site_perl/5.8.8/HTML/Mason/Component.pm:135]
>
> Another stupid syntax error? Thanks.
>
> -Trevor
>
> On Wed, Jul 16, 2008 at 10:42 AM, Lanning, Scott <lannings[at]who.int>
> wrote:
>> Just instead of using Bric::Biz::Category->list,
>> which returns Category objects
>> (so you have to call $_->get_id for each object),
>> use Bric::Biz::Category->list_ids directly.
>> Then the objects aren't created, which is a relatively
>> expensive thing to do (if you only need ID numbers).
>>
>> -----Original Message-----
>> From: smith.t.denison[at]gmail.com on behalf of Trevor Smith
>> Sent: Wed 7/16/2008 2:17 PM
>> To: users[at]lists.bricolage.cc
>> Subject: Re: Finding Stories by Type
>>
>> Can you show me where and how to use this in my code? Thanks.
>>
>> -Trevor
>>
>> On Tue, Jul 15, 2008 at 4:44 PM, David E. Wheeler <david[at]kineticode.com
>> > wrote:
>>>
>>> If you don't need the category objects, use Category->list_ids(),
>>> instead.
>>> Much more efficient.
>>>
>>> Best,
>>>
>>> David
>>>
>>
>>

--
Phillip Smith,
Simplifier of Technology
Community Bandwidth
http://www.communitybandwidth.ca


lannings at who

Jul 17, 2008, 12:20 AM

Post #21 of 21 (474 views)
Permalink
Re: Finding Stories by Type [In reply to]

Category->list_ids returns a list in list context
or an array reference in scalar context. (ref($subcat) eq 'ARRAY')

On Wed, 16 Jul 2008, Trevor Smith wrote:
> I'm trying to use what you suggested in this code to return a list of
> all the stories in these three directories:
>
> my $subcat = Bric::Biz::Category->list_ids({ uri =>
> '/offices/computing/facilities/computerlabs/' });
> @stories = Bric::Biz::Asset::Business::Story->list({ category_id =>
> $subcat, active => 1, unexpired => 1 });
> $subcat = Bric::Biz::Category->list_ids({ uri =>
> '/offices/computing/facilities/eclassrooms/' });
> @stories = push(@stories,Bric::Biz::Asset::Business::Story->list({
> category_id => $subcat->get_id, active => 1, unexpired => 1 }));
> $subcat = Bric::Biz::Category->list_ids({ uri =>
> '/offices/computing/facilities/laptopcarts/' });
> @stories = push(@stories,Bric::Biz::Asset::Business::Story->list({
> category_id => $subcat->get_id, active => 1, unexpired => 1 }));
>
> I keep generating the same SQL error as seen here:
>
> Unable to execute SQL statement
>
> Cannot bind a reference (ARRAY(0xfa8eee8)) ((null)) (1) type=7 10 4 0
> at /usr/local/bricolage/lib/Bric/Util/DBI.pm line 1087, <GEN950> line
> 460.
>
> Stack:
> [/usr/local/bricolage/lib/Bric/Util/DBI.pm:1087]
> [/usr/local/bricolage/lib/Bric/Util/DBI.pm:730]
> [/usr/local/bricolage/lib/Bric/Biz/Asset.pm:312]
> [/usr/local/bricolage/data/burn/sandbox/user_1368/oc_1/software_index.mc:28]
> [/usr/local/lib/perl5/site_perl/5.8.8/HTML/Mason/Component.pm:135]
> [/usr/local/bricolage/lib/Bric/Util/Burner/Mason.pm:557]
> [/usr/local/bricolage/data/burn/sandbox/user_1368/oc_1/autohandler:144]
> [/usr/local/lib/perl5/site_perl/5.8.8/HTML/Mason/Component.pm:135]
>
> Another stupid syntax error? Thanks.
>
> -Trevor
>
> On Wed, Jul 16, 2008 at 10:42 AM, Lanning, Scott <lannings[at]who.int> wrote:
>> Just instead of using Bric::Biz::Category->list,
>> which returns Category objects
>> (so you have to call $_->get_id for each object),
>> use Bric::Biz::Category->list_ids directly.
>> Then the objects aren't created, which is a relatively
>> expensive thing to do (if you only need ID numbers).
>>
>> -----Original Message-----
>> From: smith.t.denison[at]gmail.com on behalf of Trevor Smith
>> Sent: Wed 7/16/2008 2:17 PM
>> To: users[at]lists.bricolage.cc
>> Subject: Re: Finding Stories by Type
>>
>> Can you show me where and how to use this in my code? Thanks.
>>
>> -Trevor
>>
>> On Tue, Jul 15, 2008 at 4:44 PM, David E. Wheeler <david[at]kineticode.com> wrote:
>>>
>>> If you don't need the category objects, use Category->list_ids(), instead.
>>> Much more efficient.
>>>
>>> Best,
>>>
>>> David
>>>
>>
>>
>

Bricolage users RSS feed   Index | Next | Previous | View Threaded
 
 


Interested in having your list archived? Contact lists@gossamer-threads.com
 
  Web Applications & Managed Hosting Powered by Gossamer Threads Inc.