[Editor's note: to get short column names there's an undocumented PRAGMA setting. You can exec "PRAGMA short_column_names = ON" to force that behavior.]
I noticed that if you use Joins in SQL queries, the field name is messed up with the dot!
for example if you have this query:
SELECT n.*, m.nickname FROM news AS n, members AS m WHERE n.memberID = m.id;
now if you want to print_r the results returned using SQLITE_ASSOC type, the result array is like this :
array
(
[n.memberID] => 2
[n.title] => test title
[m.nickname] => NeverMind
[tablename.fieldname] => value
)
and I think it looks horriable to use the variable ,for example, $news['m.nickname'] I just don't like it!
so I've made a small function that will remove the table name (or its Alias) and will return the array after its index is cleaned
<?php
function CleanName($array)
{
foreach ($array as $key => $value) {
unset($array[$key]);
$key = substr($key, strpos($key, '.')+1);
$array[$key] = $value;
}
return $array;
}
?>