At the risk of looking totally silly

Have a programming question regarding your component, plug-in, extension or core hacks? Have an interesting tidbit, FAQ or programming tip you’d like to share? This is the place for you.

Moderators: tjay, seadap, Rogue4ngel, matthewhayashida

Post Reply
User avatar
tjay
Joomla! Intern
Joomla! Intern
Posts: 73
Joined: Thu Aug 18, 2005 1:50 am
Location: New Orleans
Contact:

At the risk of looking totally silly

Post by tjay » Sun Sep 09, 2007 11:30 pm

Ok so we are here to learn to code J1.5 that means looking silly should be ok right? so take it easy on me.
I am trying to actually write a phpbb3 latest post module for J1.5

Steps to my approach
get a module skeleton to work and install. (thanks to the wiki and the 1.5 module hello world) done
Modify the helper.php to hold a basic SQL query that hits a hardcoded phpbb3 table in my joomla database and return it in a list
Not Done

Future load in all the neat parameters to make the module useful  not even thinking there yet.

here is the problem, and it will most likely provide some of you with a chuckle but my function returns "Array" and nothing else

So here is the code

Code: Select all

class modHelloWorldHelper
{
    /**
     * Retrieves posts from phpbb3
     *
     * @param array $params An object containing the module parameters
     * @access public
     */
    function getPosts( $params )
    {

       global $mainframe;

      $db         =& JFactory::getDBO();

$query = 'SELECT phpbb_posts.post_subject,phpbb_posts.post_text' .
         ' FROM phpbb_posts' .
         ' WHERE phpbb_posts.post_approved =  1';
      $db->setQuery($query, 0, 5);
      $rows = $db->loadObjectList();

      $i      = 0;
      $lists   = array();
      foreach ( $rows as $row )
      {
         $lists[$i]->text = htmlspecialchars( $row->phpbb_posts.post_subject );
         $i++;
      }

      return $lists;
    }
}
?>
This day it is my wish that I helped you to live

User avatar
DeanMarshall
Joomla! Apprentice
Joomla! Apprentice
Posts: 46
Joined: Fri Aug 19, 2005 2:26 am
Location: Lancaster, Lancashire, United Kingdom
Contact:

Re: At the risk of looking totally silly

Post by DeanMarshall » Mon Sep 10, 2007 1:21 am

Hi,

I think the problem is the arrow notation you are using.
Are you coming from a Perl background by any chance?
This is probably nearer the mark - though undoubtedly not perfect.

Code: Select all

      $lists[$i]['text'] = htmlspecialchars( $row['post_subject'] );


I'm not sure whether your $row is an associative array (with named keys)
or a standard array with numeric keys so there is still some doubt in my mind
as to whether this line is right or not.

Dean
Dean Marshall - http://www.deanmarshall.co.uk/
Mambo and Joomla Consultant

Add an Amazon Store to your site: http://www.Project-TinA.com/
(coming soon)

User avatar
Pentacle
Joomla! Intern
Joomla! Intern
Posts: 61
Joined: Wed Oct 25, 2006 12:34 pm
Location: Turkey

Re: At the risk of looking totally silly

Post by Pentacle » Mon Sep 10, 2007 10:21 am

Don't call yourself silly. If you think like that, we all are silly now. :D

My advice is:

change the query like this:

SELECT phpbb_posts.post_subject AS phpbb_subject

and change $row->phpbb_posts.post_subject to $row->phpbb_subject.

Hope it helps,
Ercan.
My Joomla! 1.5 extensions - http://joomla.ercan.us
Progress is made by lazy men looking for easier ways to do things.

User avatar
jalil
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 128
Joined: Wed Jul 04, 2007 4:54 am
Location: Kuala Lumpur, Malaysia
Contact:

Re: At the risk of looking totally silly

Post by jalil » Tue Sep 11, 2007 2:53 am

yeah, don't silly yourself. i tetsed my fresh made component, made changes and thought it fit to be tested so upload/install it all to my test site, which deletes the working version, and leaves me with a faulty version, with no copy of the correct initial version.
now thats is silly.

my question is is SQL able to take database name and object name of the same name without getting confused (as in the code above ) ?

User avatar
louis.landry
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 101
Joined: Wed Aug 17, 2005 11:03 pm
Location: New Orleans, Louisiana
Contact:

Re: At the risk of looking totally silly

Post by louis.landry » Tue Sep 11, 2007 3:03 am

tjay,

the string "Array" is what is output when you print/echo an array variable in PHP.  If you want to see the contents of the array try doing,

Code: Select all

var_dump($variable);


or

Code: Select all

print_r($variable);


You may be surprised what you get.

Louis
Project Manager :: Developer
http://www.webimagery.net
A hacker does for love what others would not do for money.


Post Reply