note 77813 rejected from function.PDOStatement-fetch by nlopess

From: Date: Thu, 13 Sep 2007 17:56:24 +0000
Subject: note 77813 rejected from function.PDOStatement-fetch by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-130480@lists.php.net to get a copy of this message
Note Submitter: jdriddle_producer at yahoo dot com ---- I have a practical question about the use of PDO::FETCH_CLASSTYPE in trying to determine the classtype of an object retrieved from a database at runtime. What point is there in using this constant? I cannot imagine a single case where a table in an relational database will have the classtype of the object as the FIRST column in the row. In the real world, any item you will be retrieving from a single table using 'SELECT * from table_name' will have 'id' as the first column. The only way I can think of to work around this is to do 'SELECT classtype, id, etc, etc', which would work, but it would require writing custom SELECT code for each query necessary in order to use the designed functionality. I like the idea of automatically determining the Classname from the result, but how about a change to allow specification of the column name to look at? This would allow true object-oriented design, as all queries could return as custom-defined object while maintaining the ability of the query code to not care about the table structure.

« previous php.notes (#130480) next »