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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T09:04:27+00:00 2026-06-16T09:04:27+00:00

Here is my table description: CREATE TABLE my_table ( id int, name varchar(9), value

  • 0

Here is my table description:
CREATE TABLE my_table
(id int, name varchar(9), value varchar(13))
;

INSERT INTO my_table
(id, name, value)
VALUES
(0, ‘timezone’, ‘Europe/London’),
(0, ‘language’, ‘en’),
(0, ‘country’, ’45’),
(0, ‘something’, ‘x’),
(1, ‘timezone’, ‘Europe/Paris’),
(1, ‘language’, ‘fr’),
(1, ‘country’, ’46’)
;

        id  name       value

        0   timezone    Europe/London
        0   language    en
        0   country     45
        0   something   x
        1   timezone    Europe/Paris
        1   language    fr
        1   country     46

My result should look

  ID     TIMEZONE       LANGUAGE      COUNTRY SOMETHING
  0      Europe/London  en            45      x
  1      Europe/Paris   fr            46      (null)

How can I execute this query in Zend Framework by using Zend_Db_Table or Zend_Db_Select? Thank you so much!

[EDIT Query from comments added]

SELECT CONCAT( 'SELECT table.id', GROUP_CONCAT(CONCAT(' , t_', REPLACE(name, '', ''), '`.value AS `', REPLACE(name, '`', ''), '' ) SEPARATOR ''), ' 
FROM table` ', 
GROUP_CONCAT(CONCAT(' LEFT JOIN table AS t_', REPLACE(name, '', ''), '` ON `table`.id = `t_', REPLACE(name, '`', ''), '.id AND t_', REPLACE(name, '', '``'), '.name = ', 
QUOTE(name) ) SEPARATOR ''), ' 
GROUP BY table.id' ) 
INTO @qry FROM (SELECT DISTINCT name FROM table) t;

 PREPARE stmt FROM @qry;
 EXECUTE stmt; 
  • 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-16T09:04:28+00:00Added an answer on June 16, 2026 at 9:04 am

    here’s a solution that uses Zend_Db_Adapter from a DbTable model:

    /*accepts a string of SQL*/
    public function getQuery($sql) {
        $query = $this->getAdapter->quoteInto($sql);
        $result = $this->getAdapter()->fetchAll($query);
        /*if you want the result as an array instead of an object: $result->toArray()*/
        return $result;
    }
    

    I lack the SQL chops to parse your query and demonstrate the fluent interface. Good Luck.

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

Sidebar

Related Questions

Here is my table: id int(11) name varchar(255) description text highest_bidder int(11) value varchar(255)
Here is my scenario (Tables): Orders ====================== Id (int) description (varchar) Products ====================== Id
Here is my table structure and data: CREATE TABLE event ( EventID INT(11) NOT
http://logging.apache.org/log4net/release/config-examples.html Given the log table here: CREATE TABLE [dbo].[Log] ( [Id] [int] IDENTITY (1,
Here is a table structure (e.g. test): Field Name Data Type id BIGINT (20)
Here is my table | | Name | Vert | Horz | Area |
CREATE TABLE [dbo].[MembershipModule]( [Id] [uniqueidentifier] ROWGUIDCOL NOT NULL, [ParentId] [uniqueidentifier] NULL, [TargetId] [int] NULL,
I am getting strange error while inserting data into mysql table column. Details: Create
I have the following table: CREATE TABLE `events` ( `evt_id` int(11) NOT NULL AUTO_INCREMENT,
Here is my database schema for my MySQL database: create table noticia ( id

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.