php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #17352 DB::execute in DataBase field name have '-'
Submitted: 2002-05-22 03:21 UTC Modified: 2002-05-23 04:58 UTC
From: tokimeki at pchome dot com dot tw Assigned:
Status: Not a bug Package: PEAR related
PHP Version: 4.2.1 OS: Windows XP
Private report: No CVE-ID: None
 [2002-05-22 03:21 UTC] tokimeki at pchome dot com dot tw
<code>
$DBX=DB::connect($DSN);
$SQL="INSERT INTO League_Base (`?`) VALUES ('?')";
$params=array('zh-twName','foo');
$stmt=$DBX->prepare($SQL);
$Result=$DBX->execute($stmt,$params);
if(DB::isError($Result)) $Message='ERROR';
else $Message='OK';
echo $Message;
</code>

it always show 'ERROR'.
When I change DataBase Field Name from `zh-twName` to `Name`,
it show 'OK'...
now, I use another way to do it...

<code>
  $DBX=DB::connect($DSN);
  $SQL="INSERT INTO League_Base (`%s`) VALUES ('%s')";
  $SQL=sprintf($SQL,'zh-twName','foo');
  $Result=$DBX->query($SQL);
  if(DB::isError($Result)) $Message='ERROR';
  else $Message='OK';
  echo $Message;
</code>
it's OK...

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2002-05-23 04:58 UTC] cox@php.net
Try this way:
$SQL="INSERT INTO League_Base (!) VALUES (?)";
$params=array('zh-twName','foo');

Or if the database field is not going to change directly:
$SQL="INSERT INTO League_Base (zh-twName) VALUES (?)";
$params=array('foo');

Tomas V.V.Cox

PS.- Please for support questions go in the future to pear-general@lists.php.net or pear-dev@lists.php.net
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Mon Oct 14 03:01:27 2024 UTC