Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8522333
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T07:05:12+00:00 2026-06-11T07:05:12+00:00

In my cakephp i need to retrieve datas from database. how can i display

  • 0

In my cakephp i need to retrieve datas from database.

how can i display the table result in neat format.

Controller:

  function MarketingTaskmanagement(){
    $data['list'] = $this->TravancoAdmin->get_task_all();
    $this->set($data); 
    $this->render('Marketing/taskmanagement');
  }

Model:

function get_task_all(){

               $users = $this->query('select * from tbl_tasks');

        if($users){
            return $users;
        }else{
            return 1;
        }
    }

View:

But it displays values as so many arrays:

Array ( [0] => Array ( [tbl_tasks] => Array ( [task_ids_mm] => 1 [task_title_mm] => ghjg [task_description_mm] => gjg [task_from_mm] => 09/04/2012 [task_to_mm] => 09/27/2012 ) ) [1] => Array ( [tbl_tasks] => Array ( [task_ids_mm] => 2 [task_title_mm] => hf [task_description_mm] => hfgh [task_from_mm] => 09/03/2012 [task_to_mm] => 09/27/2012 ) ) [2] => Array ( [tbl_tasks] => Array ( [task_ids_mm] => 3 [task_title_mm] => hf [task_description_mm] => hfgh [task_from_mm] => 09/03/2012 [task_to_mm] => 09/27/2012 ) ) [3] => Array ( [tbl_tasks] => Array ( [task_ids_mm] => 4 [task_title_mm] => hfh [task_description_mm] => fgh [task_from_mm] => 09/03/2012 [task_to_mm] => 09/20/2012 ) ) [4] => Array ( [tbl_tasks] => Array ( [task_ids_mm] => 5 [task_title_mm] => h [task_description_mm] => h [task_from_mm] => 09/04/2012 [task_to_mm] => 09/28/2012 ) ) [5] => Array ( [tbl_tasks] => Array ( [task_ids_mm] => 6 [task_title_mm] => hjk [task_description_mm] => hk [task_from_mm] => 09/05/2012 [task_to_mm] => 09/22/2012 ) ) [6] => Array ( [tbl_tasks] => Array ( [task_ids_mm] => 7 [task_title_mm] => v [task_description_mm] => v [task_from_mm] => 09/03/2012 [task_to_mm] => 09/28/2012 ) ) [7] => Array ( [tbl_tasks] => Array ( [task_ids_mm] => 8 [task_title_mm] => d [task_description_mm] => d [task_from_mm] => 09/03/2012 [task_to_mm] => 09/28/2012 ) ) [8] => Array ( [tbl_tasks] => Array ( [task_ids_mm] => 9 [task_title_mm] => f [task_description_mm] => d [task_from_mm] => 09/04/2012 [task_to_mm] => 09/27/2012 ) ) [9] => Array ( [tbl_tasks] => Array ( [task_ids_mm] => 10 [task_title_mm] => b [task_description_mm] => b [task_from_mm] => 09/05/2012 [task_to_mm] => 09/27/2012 ) ) ) 

In codeigniter there have something like this:

$users = $this->query('select * from tbl_tasks')->result();

Then it displays the correct array without any complication .

So how can i do this in cakephp?

And i need to display the all task_title_mm values from the table result in view page.

How can i do this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T07:05:13+00:00Added an answer on June 11, 2026 at 7:05 am

    Since you expanded your question I’ll elaborate a bit on the anwser.

    It is a good practice to not use $this->query() where a native cake search would work.

    if you don’t have a model file for your tbl_tasks create one:

    <?php
    class Task extends AppModel {
        var $name = 'Task';
        var $displayField = 'task_title_mm';
        var $useTable = 'tbl_tasks';
    }
    

    Load it inside your get_task_all() function. You can load a model dinamically inside another.

    function get_task_all(){
        //load the Task model on the fly if it isnt associated with this one
        //loadModel won't work because we're inside a model. 
        //App:import might work, dunno.
        $this->Task = ClassRegistry::init('Task');
    
        $users = $this->Task->find('list');
    
        return $users ? $users : 1;
    }
    

    find('list') works if you declare 'task_title_mm' as displayField otherwise you can use $this->Task->find('all', array('fields' => array('task_title_mm')));, but the result will be prefixed with ['Task'];

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to retrieve values from CakePHP's config file database.php from one of my
In cakephp I want to be able connect to a different database from one
I'm using CakePHP for the first time and inside my controller I need to
I need to save errors which occur in my application into a database table,
i am using cakephp and i need load Module rewrite , but i can
I need two things Redirect all requests from http://127.0.0.1 to http://127.0.0.1/cakephp Redirect all requests
I have a PHP application using CakePHP. I need to present a table showing
I am developing a cakephp application, I dont need to use any database tables
Please help. I need a CakePHP 1.2 code that needs to export data from
i need to call a cakePHP element in an Ajax function; when the user

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.