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

The Archive Base Latest Questions

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

Possible Duplicate: PDO support for multiple queries (PDO_MYSQL, PDO_MYSQLND) i have a statement here..

  • 0

Possible Duplicate:
PDO support for multiple queries (PDO_MYSQL, PDO_MYSQLND)

i have a statement here.. when i ran it from phpmyadmin.. i got my query works.. but it doesnt when i execute it from php..

here’s my query (statement)

SET @sql = NULL;
 SELECT GROUP_CONCAT(DISTINCT CONCAT('MAX(IF(a.Name = ''', a.Name, ''', ca.value, NULL)) AS ', a.Name )) INTO @sql FROM cust_attribute ca INNER JOIN attribute a ON ca.idAttribute = a.idAttribute INNER JOIN customer c ON c.idCustomer = ca.idCustomer WHERE a.publish = 'Y';
 SET @sql = CONCAT('SELECT c.idCustomer, c.namaCustomer, ' ' c.email, c.noTelp, ', @sql, ' FROM cust_attribute ca', ' INNER JOIN attribute a ON ca.idAttribute = a.idAttribute', ' INNER JOIN customer c ON c.idCustomer = ca.idCustomer', ' GROUP BY c.idCustomer');
 SELECT @sql;
 prepare stmt FROM @sql;
 execute stmt;

and here’s my code on php…

<?php 
$uname = 'root'; //nama username database 
$pwd = ''; //Password database 
$dbname = 'eav_latihan'; //nama Database 

/* Initialisasi database */ 
$db = new PDO('mysql:host=localhost;dbname='.$dbname, $uname, $pwd); 
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING); 


$query = "SET @sql = NULL; ". 
" SELECT GROUP_CONCAT(DISTINCT CONCAT('MAX(IF(a.Name = ''', ". 
" a.Name, ''', ca.value, NULL)) AS ', a.Name )) INTO @sql ". 
" FROM cust_attribute ca ". 
" INNER JOIN attribute a ON ca.idAttribute = a.idAttribute ". 
" INNER JOIN customer c ON c.idCustomer = ca.idCustomer ". 
" WHERE a.publish = 'Y'; ". 
" SET @sql = CONCAT('SELECT c.idCustomer, c.namaCustomer, ' ". 
" ' c.email, c.noTelp, ', @sql, ' FROM cust_attribute ca', ". 
" ' INNER JOIN attribute a ON ca.idAttribute = a.idAttribute', ". 
" ' INNER JOIN customer c ON c.idCustomer = ca.idCustomer', ". 
" ' GROUP BY c.idCustomer'); ". 
" SELECT @sql; ". 
" prepare stmt FROM @sql; ". 
" execute stmt;"; 

$result_array = array();
$queryku = $db->query($query);
$result_array = $queryku->fetchAll(PDO::FETCH_OBJ);
var_dump($result_array);
?>

Anyone can help me or give me a suggest 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-13T19:50:11+00:00Added an answer on June 13, 2026 at 7:50 pm

    This issue has come up before with regards to PDO. Not sure if it’s a bug or a security feature (might be related to this: Mysql can't perform more than 1 query at a time).

    Have a look at this solution: http://www.php.net/manual/en/book.pdo.php#96264

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

Sidebar

Related Questions

Possible Duplicate: Retrieve (or simulate) full query from PDO prepared statement I can't figure
Possible Duplicate: Extracting dollar amounts from existing sql data? I have a column in
Possible Duplicate: MySQL INSERT from a SELECT with PDO I've historically used the mysql_*
Possible Duplicate: How do I create a PDO parameterized query with a LIKE statement
Possible Duplicate: Output (echo/print) everything from a PHP Array I have done a query
Possible Duplicate: How do I create a PDO parameterized query with a LIKE statement
Possible Duplicate: PHP PDO bindValue in LIMIT $number=8; try { $topics=$dbh->prepare(SELECT * FROM topictable
Possible Duplicate: PHP PDO bindParam with html content I'm using PDO prepared statement to
Possible Duplicate: How do I use pdo's prepared statement for order by and limit
Possible Duplicate: PHP PDO: Can I bind an array to an IN() condition? I

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.