Web студия "GrandView"
  Главная   Написать Контакты
   
   
О проекте
Руководство php
 

sqlite_fetch_array

(PHP 5)

sqlite_fetch_array --  Выбирает следующую запись из результата запроса и возвращает массив

Описание

array sqlite_fetch_array ( resource result [, int result_type [, bool decode_binary]] )

Выбирает следующую запись из результата запроса, заданного аргументом result. Если Результат больше не содержит данных, возвращает FALSE, иначе возвращает массив, содержащий данные.

Аргумент result_type позволяет задать вид возвращаемого массива. По умолчанию используется SQLITE_BOTH, при этом для каждого поля массив будет содержать два элемента: с числовым индексом и строковым индексом (имя поля). При использовании SQLITE_ASSOC индексами массива будут только имена полей, а при использовании SQLITE_NUM - порядковые номера полей.

Регистр символов в именах полей зависит от директивы sqlite.assoc_case.

Когда decode_binary имеет значение TRUE, PHP декодирует данные, которые были закодированы функцией sqlite_escape_string(). В большинстве случаев следует использовать значение по умолчанию (TRUE), за исключением работы с базами данных, созданными другими приложениями.

Смотрите также

sqlite_array_query() и sqlite_fetch_string().



add a note add a note User Contributed Notes
sqlite_fetch_array
saleh at sfsj dot net
09-May-2004 06:12
[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) {
   
//if you want to keep the old element with its key remove the following line
     
unset($array[$key]);

  
//now we clean the key from the dot and tablename (alise) and set the new element
     
$key = substr($key, strpos($key, '.')+1);
     
$array[$key] = $value;
  }
  return
$array;
}
?>

sqlite_fetch_column_types> <sqlite_fetch_all
Last updated: Fri, 26 Jan 2007
 
 
Новости
11 июля 2007
Сайт запущен
© 2007 info@grandviewstudio.com

Deprecated: Function set_magic_quotes_runtime() is deprecated in /home/sites/grandviewstudiocom/www/65f67d67a94ad980786580ae69e11c07/sape.php on line 324

Deprecated: Function set_magic_quotes_runtime() is deprecated in /home/sites/grandviewstudiocom/www/65f67d67a94ad980786580ae69e11c07/sape.php on line 330
Z058440144362 Z348613067571