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

  • Home
  • SEARCH
  • 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 1066031
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T19:57:18+00:00 2026-05-16T19:57:18+00:00

I have a static method ‘findAll’ on a model which basically gets all rows

  • 0

I have a static method ‘findAll’ on a model which basically gets all rows with certain criteria. This method works fine and I can call it using:

$m::findAll();

Where $m is the model name as a variable. I can output this and it returns correct results. However, when assigning this to a variable in the Zend_View object, as:

$this->view->viewvariable = $m::findAll();

I get the error:

Zend_Db_Table_Exception: Too many
columns for the primary key

Any ideas why?

Find all function:

final public static function findAll($where = false, array $options = array()) {
  $object = new static();

  if (!empty($options)) $options = array_merge($object->options, $options);
  else $options = $object->options;

  $run = $object->buildDefaultSelect($where, $options);
  $rows = $run->fetchAll();
  if ($options['asObject'] == true) {
   $result = array();
   foreach ($rows as $r) {
    $class = new static();
    $class->setInfo($r);
    $result[] = $class;
   }
   return $result;
  } else {
   if (count($rows) > 0) return $rows;
   else return array();
  }
 }

Note: This function works fine everywhere apart from when assigning to a view variable. If I run the below (not assigning it to a view variable), it shows the correct array data.

   var_dump($m::findAll($module['where'], $module['options']));
   exit;

In my view (I have replaced the actual name with viewvariable for the sake of this post):

<?php foreach($this->viewvariable as $item) { ?>
//Do some echoing of data in $item
//Close foreach
  • 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-16T19:57:19+00:00Added an answer on May 16, 2026 at 7:57 pm

    I doubt the issue is with Zend_View. It’s hard to tell without seeing your code, but my guess is that findAll() is using the Zend_Table_Db find() function incorrectly.

    To my knowledge, the only place that throws that exception is the find() function on Zend_Db_Table_Abstract.

    Perhaps, inside the findAll() function (or in a function it calls) you’re doing one of these:

    $zendDbTable->find(1,2) //is looking for a compound key
    $zendDbTable->find(array(1,2)) //is looking for two rows
    

    When you really want the opposite.

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

Sidebar

Related Questions

Subject line basically says it all. I have a static method I want to
I have static method which plays music. How to return value from this method
I have static method which returns me as it's name says data from domain
I have a static method which sets a variable: static String[] playersNames; public static
I currently have this working but it requires me to have a static method
I have a static method [Method1] in my class, which calls another method [Method2]
I have a static method like this public static string DoSomethingToString(string UntrustedString) { //parse
If I have a static method like this private static bool TicArticleExists(string supplierIdent) {
I wanted to make a class Draw which will have static method ConsoleSquare() and
I have a static method I have no control over: MyUtils.getServiceURL() which returns a

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.