note 77813 added to function.PDOStatement-fetch
| From: | jdriddle_producer at yahoo dot com | Date: | Thu, 13 Sep 2007 17:50:11 +0000 |
| Subject: | note 77813 added to function.PDOStatement-fetch | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-130479@lists.php.net to get a copy of this message | ||
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.
----
Server IP: 209.41.74.194
Probable Submitter: 38.98.62.2
----
Manual Page -- http://www.php.net/manual/en/function.PDOStatement-fetch.php
Edit -- https://master.php.net/note/edit/77813
Del: integrated -- https://master.php.net/note/delete/77813/integrated
Del: useless -- https://master.php.net/note/delete/77813/useless
Del: bad code -- https://master.php.net/note/delete/77813/bad+code
Del: spam -- https://master.php.net/note/delete/77813/spam
Del: non-english -- https://master.php.net/note/delete/77813/non-english
Del: in docs -- https://master.php.net/note/delete/77813/in+docs
Del: other reasons-- https://master.php.net/note/delete/77813
Reject -- https://master.php.net/note/reject/77813
Search -- https://master.php.net/manage/user-notes.php