Jump to content
  • 0

Query A Table From Module Function


AllToolKits.com

Question

Hi,

 

I have to call a table i created from the function public function getAdminServiceInfo

 

I tried below code

$this->components(array("Record"));
        $cron_log = $this->Record->select()->
            from("my_table")->
            fetchall();

Seems like that is not working.  This table can't be part of the module, so i need a way to query the table.

Let me know how i can do it?

 

 

i recall someone told to use plugin for calling custom tables, but i can't use plugin as i need to call the table data from

module function getAdminServiceInfo. Please let me know how i can do it.

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

  • 0

The Record component may not be connecting to the database, or because of some other error, perhaps because you're calling "fetchall" rather than "fetchAll".

 

A plugin could be created that defines a model and method that performs the query, and then your module can call that plugin's model method to fetch the data. Using a plugin also allows you to better define the creation and removal of your database tables. You could also setup your module to not install itself if the associated plugin dependency is not installed first.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...