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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T19:50:03+00:00 2026-06-14T19:50:03+00:00

App::import(‘model’,’User’); $user_model = new User(); $xxx = $user_model->find(all, array(fields=>array(User.yyy))); $zzz = $user_model->find(count, array(fields =>

  • 0
App::import('model','User');
        $user_model = new User();
        $xxx = $user_model->find("all", array("fields"=>array("User.yyy")));
        $zzz = $user_model->find("count", array("fields" => "User.yyy"));
        $arr = array();
        for($i=0; $i<=$zzz; $i++){
                $rs = $xxx["i"]["User"]["yyy"];
                array_push($arr , $rs);
        }
        print_r($arr);

I am using the above cakephp code to get $xxx as a mysql result set.

I need to store all the values corresponding to “yyy” field in the mysql table into an arrray.

I tried printing the result set and got output like this:-

print_r($zzz)= 1646 // prints the total number of results
print_r($xxx[0]["User"]["yyy"]) = abcde   //the first element of the result set

After I run the code above, It just prints an empty array.

Can someone help me out here??

  • 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-14T19:50:04+00:00Added an answer on June 14, 2026 at 7:50 pm

    The problem is here:

    $xxx["i"]["User"]["yyy"]
    

    It should be:

    $xxx[$i]["User"]["yyy"]
    

    Assuming the code is located in a controller, I would write it like this:

    $this->loadModel('User');
    $arr = $this->User->find("list", array("fields"=>array("User.yyy")));
    

    find(“list”) should return an array indexed by id

    If you want to remove the ids, you can do this:

    $arr = array_values($arr)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I create view for register and send data to controller //app::import('Model','Myprofile'); Class MembersController extends
I was wondering where is the correct location to place the App::import on CakePHP2.
from Tkinter import * app = Tk() text_field = Entry(app) text_field.pack() app.mainloop() I want
I have the following code: <fx:Script> <![CDATA[ import shared.GlobalsManager; import app.Globals; protected var globals:Globals=GlobalsManager.getGlobals();
Code: import com.independentsoft.exchange.Service; import android.app.Activity; import android.os.Bundle; public class ContactsToExchangeActivity extends Activity { @Override
The code- package myusic.app.activity; import java.util.ArrayList; import android.app.Activity; import android.os.Bundle; import android.view.View; import android.widget.ArrayAdapter;
I have a very simple dialog defined as: import android.app.AlertDialog; import android.content.Context; import android.view.LayoutInflater;
Here is my code import org.ksoap2.*; import org.ksoap2.serialization.*; import org.ksoap2.transport.*; import android.app.Activity; import android.os.Bundle;
This is my MyTasteActivity code: package MyTaste; import android.app.Activity; import android.content.Context; import android.os.Bundle; import
I have this code: package com.powergroupbd.timer; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.os.CountDownTimer;

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.