Hi Gavin.

This is exactly what i mean. I can't change the fieldnames, because other
application (not PHP) use this DB too. So i have to find a solution without
renaming the fieldnames.

Escaping with \ doesn't work and results in an exception too.
-> Invalid parameter number: no parameters were bound

I hope ZF will include a functionality to solve problems like this.

Temporarly i have to use my own db class to solve this problem or does there
any other solution exists?



Best regards ... Aycko


-----Ursprüngliche Nachricht-----
Von: Gavin Vess [mailto:[EMAIL PROTECTED] 
Gesendet: Donnerstag, 28. Dezember 2006 20:05
An: [email protected]
Betreff: Re: [fw-general] Problem with Zend_DB an PDO

Bill,

I think Aycko was speaking about a different problem than you described.

Aycko> The fieldname is ':field:name' without table prefix.

In fact what Aycko described is possible, but not with Zend_Db, for the
reasons I gave earlier. I also believe the framework should not impose
conventions on DB schemas used by ZF developers.


For example, the SQL below does work with MySQL

CREATE TABLE `test` (
  `id` tinyint(4) NOT NULL auto_increment,
  `:stuff:more` smallint(6) NOT NULL,
  PRIMARY KEY  (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ;

INSERT INTO `test` (`id`, `:stuff:more`) VALUES (1, 0);

SELECT `:stuff:more`  FROM `test`;


Gavin> This general problem is recognized, and a solution has been
proposed:
Gavin> http://framework.zend.com/wiki/x/RB8
Gavin> See the section titled "Mapping Identifiers between DB and PHP".

Cheers,
Gavin

Bill Karwin wrote:
> Aycko Maerzke wrote:
>> I tried an query like this:
>>
>> $db->query("SELECT `:tablename:filedname` FROM `table`");
>>   
>
> You shouldn't use parameters for table and column names.  Parameters 
> are used in SQL only to supply values, not identifiers or any other 
> part of syntax.
> Also, the identifier delimiter syntax you used above won't work even 
> if you execute it in the MySQL command-line client.  You need to do 
> the delimiters on _each_ of the table name and the column name.
>
> For example, the following doesn't work because it looks for a column 
> called foo.bar in the table foo.
>
>  SELECT `foo.bar` FROM `foo`
>
> You need to delimit each identifier separately to make it clear that 
> they are two separate identifiers:
>
>  SELECT `foo`.`bar` FROM `foo`
>
> If you need to make the table referenced in the select-list depend on 
> the table queried in the FROM clause, you should use a correlation name:
>
>  SELECT f.`bar` FROM `foo` AS f
>
> Regards,
> Bill Karwin
>
>

Reply via email to