db/sqlite::tableinfo() stub method
| From: | dave mausner | Date: | Mon, 12 Apr 2004 04:53:04 +0000 |
| Subject: | db/sqlite::tableinfo() stub method | ||
| Groups: | php.pear.dev | ||
| Request: | Send a blank email to pear-dev+get-27481@lists.php.net to get a copy of this message | ||
db/sqlite::tableinfo() is missing, so for minimal compatibility (column
names only) i added the following code to sqlite.php:
// {{{ tableInfo()
/**
* Returns information about a table or a result set
*
* The sample output below is based on this query:
* <pre>
* SELECT tblFoo.fldID, tblFoo.fldPhone, tblBar.fldId
* FROM tblFoo
* JOIN tblBar ON tblFoo.fldId = tblBar.fldId
* </pre>
*
* <ul>
* <li>
*
* <kbd>null</kbd> (default)
* <pre>
* [0] => Array (
* [name] => fldId
* )
* [1] => Array (
* [name] => fldPhone
* )
* [2] => Array (
* [name] => fldId
* )
* </pre>
*
* </li>
* </ul>
*
* @param object|string $result DB_result object from a query or a
* string containing the name of a table.
* While this also accepts a query result
* resource identifier, this behavior is
* deprecated.
* @param int $mode unused
* @return array an associative array with the information requested.
*
* @see DB_common::setOption()
* @access public
*/
function tableInfo($handle, $mode = null)
{
$info = array();
for ($index = 0; $index < sqlite_num_fields($handle->result); $index++) {
$info[$index] = array('name' => sqlite_field_name($handle->result,
$index));
}
return $info;
}
// }}}