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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T06:08:10+00:00 2026-05-29T06:08:10+00:00

So I have defined a model like this: class Model extends Zend_Db_Table_Abstract { $_primary

  • 0

So I have defined a model like this:

class Model extends Zend_Db_Table_Abstract
{
    $_primary = 'modelID';


    /**
     *
     * @param mixed $primaryKey
     * @return int 
     */
    public function delete($primaryKey)
    {
        $where = $this->getAdapter()->quoteInto($this->_primary.' = ?', $primaryKey);
        return parent::delete($where);
    }
}

When calling the delete method, I get a warning telling me $this->_primary is an array. Why? I have assigned a string value to $_primary property.

From logs:

2012-02-05T17:41:03+00:00 INFO (6): Array
(
    [1] => modelID
)
  • 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-29T06:08:12+00:00Added an answer on May 29, 2026 at 6:08 am

    Zend_Db_Table stores primary keys as an array in case a compound key is used, so strictly speaking, it is best (not compulsory) to declare them like this:-

    class Model extends Zend_Db_Table_Abstract
    {
        public function __construct(array $config = null)
        {
            $this->_primary[1] = 'modelId';
            parent::__construct($config);
            //.............
    

    From the docblock in Zend_Db_Table_Abstract:-

    /**
     * The primary key column or columns.
     * A compound key should be declared as an array.
     * You may declare a single-column primary key
     * as a string.
     *
     * @var mixed
     */
    protected $_primary = null;
    

    And from the dockblock for $_identity:-

    /**
     * If your primary key is a compound key, and one of the columns uses
     * an auto-increment or sequence-generated value, set _identity
     * to the ordinal index in the $_primary array for that column.
     * Note this index is the position of the column in the primary key,
     * not the position of the column in the table.  The primary key
     * array is 1-based.
     *
     * @var integer
     */
    protected $_identity = 1;
    

    So you could probably use that instead.
    If you have only one column in your primary key then it will be at $_primary[1].

    I think this would work for you:-

    public function delete($primaryKey)
    {
    
        $where = $this->getAdapter()->quoteInto($this->_primary[1] .' = ?', $primaryKey);
        return parent::delete($where);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a model defined this way class Lga < ActiveRecord::Base validates_uniqueness_of :code validates_presence_of
I have a rails model that looks something like this: class Recipe < ActiveRecord::Base
I got a model defined like this: class LogEntry(models.Model): text = models.CharField(max_length = 20)
I have a model class like this: namespace Models { public struct Localization {
I have a model that looks something like this: public class SampleModel { public
I have a model defined as below: class Example(models.Model): user = models.ForeignKey(User, null=True) other
All, i have the following model defined, class header(models.Model): title = models.CharField(max_length = 255)
Lets say I have model inheritance set up in the way defined below. class
Let's say I've defined this model: class Identifier(models.Model): user = models.ForeignKey(User) key = models.CharField(max_length=64)
I have a Review Model like the one defined below (I removed a bunch

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.