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 7625793
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T05:14:20+00:00 2026-05-31T05:14:20+00:00

In my controller I have two functions that pull all records from the db

  • 0

In my controller I have two functions that pull all records from the db with a status = 4. In one function it works fine. I copied the find all statement from the working function:

$this->set('completed', $this->Topic->find('all', array('fields' => array(
                    'Topic.creator','Topic.link','Topic.id', 'Topic.topic_name', 'Topic.info', 'Topic.priority', 'Topic.user_id',
                    'Topic.completed','Topic.created', 'Topic.status','User.name','User.id','Topic.category','Topic.tags'),'conditions' => array(
                    'Topic.status' => 4))));

But in the new function the $completed array doesn’t seem to exist. The debug statement is just a blank line. If I debug the sql log using debug($this->Topic->getDataSource()->getLog()); this is the returned array:

Array
(
[log] => Array
    (
        [0] => Array
            (
                [query] => SELECT `Topic`.`creator`, `Topic`.`link`, `Topic`.`id`, `Topic`.`topic_name`, `Topic`.`info`, `Topic`.`priority`, `Topic`.`user_id`, `Topic`.`completed`, `Topic`.`created`, `Topic`.`status`, `User`.`name`, `User`.`id`, `Topic`.`category`, `Topic`.`tags` FROM `topics` AS `Topic` LEFT JOIN `users` AS `User` ON (`Topic`.`user_id` = `User`.`id`) LEFT JOIN `events` AS `Event` ON (`Event`.`topic_id` = `Topic`.`id`)  WHERE `Topic`.`status` = 4
                [affected] => 9
                [numRows] => 9
                [took] => 0
            )

    )

[count] => 1
[time] => 0
)

The SQL statement in the log works. If I plug in into mySQL it produces results. And the affected and numRows field show the correct number of records. But the produced data isn’t being set to variables. Any ideas would be greatly appreciated. My boss and I are stumped. Here are both complete functions:

         public function dashboard(){
            $this->set('completed', $this->Topic->find('all', array('fields' => array(
                    'Topic.creator','Topic.link','Topic.id', 'Topic.topic_name', 'Topic.info', 'Topic.priority', 'Topic.user_id',
                    'Topic.completed','Topic.created', 'Topic.status','User.name','User.id','Topic.category','Topic.tags'),'conditions' => array(
                    'Topic.status' => 4))));
            $this->set('total_inprogress_release', $this->Topic->find('count', array('conditions' => array(
                    'OR' => array('status <>' => 4,'status <>' => 0),
                    'priority' => 4))));
    $this->set('upcoming_events', $this->Topic->Event->find('all'));
            $this->Topic->virtualFields['count'] = 'COUNT(*)';
            $this->set('graph_data', $this->Topic->find('chart', array('fields' => array('status_txt', 'priority_txt', 'count'), 'group' => array('status', 'priority'),
                    'chart' => array(
                            'xaxisTitle' => 'Status',
                            'yaxisLabels' => array('Release', 'Company', 'News'),
                            'xaxisLabels' => array('Open','In Progress','Completed'),
                            'yaxis' => 'Topic.priority_txt',
                            'xaxis' => 'Topic.status_txt',
                            'data' => 'Topic.count'
            ))));
    }

And here’s the nonworking function:

        public function completed(){
            $foo = $this->Topic->find('all', array('fields' => array(
                    'Topic.creator','Topic.link','Topic.id', 'Topic.topic_name', 'Topic.info', 'Topic.priority', 'Topic.user_id',
                    'Topic.completed','Topic.created', 'Topic.status','User.name','User.id','Topic.category','Topic.tags'),'conditions' => array(
                    'Topic.status' => 4)));
            debug($foo);
            debug($this->Topic->getDataSource()->getLog());


    }
  • 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-05-31T05:14:20+00:00Added an answer on May 31, 2026 at 5:14 am

    After several hours of tracking the data until we figured out where it was being lost, we found that the problem was some of the data in the database. It was encoded and it was causing a while statement in the core cake files to reset when it encountered said data. The solution was to alter Config/database.php as such:
    class DATABASE_CONFIG {

        public $default = array(
                'datasource' => 'Database/Mysql',
                'persistent' => false,
                'host' => 'localhost',
                'login' => 'login',
                'password' => 'Password',
                'database' => 'database',
                'prefix' => '',
                'encoding' => 'utf8',//this line allows the database to read utf8 data.
        );
    

    }

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

Sidebar

Related Questions

I have two view controller classes in my application delegate. I can change from
Can somebody explain me one thing. I have two methods in my controller :
I have a number of functions in my controller logic and for every one
How do you put two different function outputs from the same controller into the
I have two jQuery autocomplete textboxes on a mvc web page. One that returns
I have code that is part of an $.ajax call to MVC. Two functions
I have two Doctrine entities that have a one-to-many relationship, like this: License class
Do i have to list all controller functions in Global.asax.cs file? Im creating a
I have a Controller with two Edit methods (see below). When I submit the
I have a NIB with two NSWindow objects. The controller class has two IBOutlets,

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.