My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
hasRow  
Updated Feb 4, 2010 by kazu....@gmail.com

Method:hasRow

row existance checker

Scans currently loaded dataset and checks if a given row identified by $number exists

sample of a csv file "my_cool.csv"

name,age,skill
john,13,knows magic
tanaka,8,makes sushi
jose,5,dances salsa

load library and csv file

require_once 'File/CSV/DataSource.php';
$csv = new File_CSV_DataSource;
$csv->load('my_cool.csv');

build a relationship and dump it so we can see the rows we will be working with

var_export($csv->connect());

output

array (
0 =>
array (
'name' => 'john',
'age' => '13',
'skill' => 'knows magic',
),
1 =>  // THIS ROW EXISTS!!!
array (
'name' => 'tanaka',
'age' => '8',
'skill' => 'makes sushi',
),
2 =>
array (
'name' => 'jose',
'age' => '5',
'skill' => 'dances salsa',
),
)

now lets check for row existance

var_export($csv->hasRow(1));
var_export($csv->hasRow(-1));
var_export($csv->hasRow(9999));

output

true
false
false
  1. Argument mixed $number a numeric value that identifies the row

you are trying to fetch.

  • Visibility public
  • Returns boolean
  • Also see getRow(), getRows(), appendRow(), fillRow()

Sign in to add a comment
Powered by Google Project Hosting