2
<?php

 include("PEAR/MDB2.php");
      $dsn = 'mysqli://root@localhost/heart_hugger';
$options = array(
    'debug' => 2,
    'result_buffering' => false,
);

$mdb2 =& MDB2::singleton($dsn, $options);
if (PEAR::isError($mdb2)) {
    die($mdb2->getMessage());
}


$table_name = 'cms';

// if left as a non array all fields of the table will be fetched using '*'
// in that case this variable can be set to true, to autodiscover the types
$result_types = "";

$mdb2->loadModule('Extended');
$res = $mdb2->extended->autoExecute($table_name, null,
                        MDB2_AUTOQUERY_SELECT, 'cmsId = '.$mdb2->quote(1, 'integer'),
                        null, true, $table_name);

if (PEAR::isError($res)) {
    die($res->getMessage());
}

$row = $res->fetchRow();
echo "value from fetchrow = ".$row[2];


$mdb2->disconnect();
?>

i am getting the following error

MDB2 Error: not supported

and i have no idea what exactly is not supported. The above code is an example given by pear in MDB2 manual. can any one please suggest what i am missing ? thanks

Khurram Ijaz
  • 1,844
  • 5
  • 24
  • 43

1 Answers1

3

First, debug which of the die calls are echoing the message:

die('first: ' . $res->getMessage());

After that, check the extended user information:

die($res->getMessage() . "\n" . $res->getUserInfo());

This should give you a hint about the real problem.

cweiske
  • 30,033
  • 14
  • 133
  • 194
  • this is what i am gettingMDB2 Error: not supported checkResultTypes: [Error message: cms for 0 is not a supported column type] [Last executed query: SELECT * FROM cms WHERE cmsId = 1] [Native code: 0] – Khurram Ijaz Jun 07 '11 at 16:54
  • Seems the `autoExecute´ parameters do not match what the API says. Check it with http://pear.php.net/package/MDB2/docs/2.4.1/MDB2/MDB2_Extended.html#methodautoExecute – cweiske Jun 07 '11 at 19:43
  • thanks i have fixed it the docs are abstract some one need to inherit them and provide more details...thanks @cweiske. – Khurram Ijaz Jun 08 '11 at 15:54