mirror of
https://github.com/parsecsv/parsecsv-for-php.git
synced 2026-02-19 08:36:39 +00:00
@@ -351,11 +351,11 @@ class parseCSV {
|
|||||||
* @param [string] conditions Basic SQL-like conditions for row matching
|
* @param [string] conditions Basic SQL-like conditions for row matching
|
||||||
*/
|
*/
|
||||||
public function __construct ($input = null, $offset = null, $limit = null, $conditions = null, $keep_file_data = null) {
|
public function __construct ($input = null, $offset = null, $limit = null, $conditions = null, $keep_file_data = null) {
|
||||||
if ( $offset !== null ) {
|
if (!is_null($offset)) {
|
||||||
$this->offset = $offset;
|
$this->offset = $offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $limit !== null ) {
|
if (!is_null($limit)) {
|
||||||
$this->limit = $limit;
|
$this->limit = $limit;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -391,16 +391,16 @@ class parseCSV {
|
|||||||
* @return [bool]
|
* @return [bool]
|
||||||
*/
|
*/
|
||||||
public function parse ($input = null, $offset = null, $limit = null, $conditions = null) {
|
public function parse ($input = null, $offset = null, $limit = null, $conditions = null) {
|
||||||
if ( $input === null ) {
|
if (is_null($input)) {
|
||||||
$input = $this->file;
|
$input = $this->file;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($input)) {
|
if (!empty($input)) {
|
||||||
if ( $offset !== null ) {
|
if (!is_null($offset)) {
|
||||||
$this->offset = $offset;
|
$this->offset = $offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($limit !== null ) {
|
if (!is_null($limit)) {
|
||||||
$this->limit = $limit;
|
$this->limit = $limit;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -470,7 +470,7 @@ class parseCSV {
|
|||||||
|
|
||||||
$data = $this->unparse($data, $fields, null, null, $delimiter);
|
$data = $this->unparse($data, $fields, null, null, $delimiter);
|
||||||
|
|
||||||
if ( $filename !== null ) {
|
if (!is_null($filename)) {
|
||||||
header('Content-type: application/csv');
|
header('Content-type: application/csv');
|
||||||
header('Content-Length: '.strlen($data));
|
header('Content-Length: '.strlen($data));
|
||||||
header('Cache-Control: no-cache, must-revalidate');
|
header('Cache-Control: no-cache, must-revalidate');
|
||||||
@@ -494,11 +494,11 @@ class parseCSV {
|
|||||||
*/
|
*/
|
||||||
public function encoding ($input = null, $output = null) {
|
public function encoding ($input = null, $output = null) {
|
||||||
$this->convert_encoding = true;
|
$this->convert_encoding = true;
|
||||||
if ( $input !== null ) {
|
if (!is_null($input)) {
|
||||||
$this->input_encoding = $input;
|
$this->input_encoding = $input;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $output !== null ) {
|
if (!is_null($output)) {
|
||||||
$this->output_encoding = $output;
|
$this->output_encoding = $output;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -518,7 +518,7 @@ class parseCSV {
|
|||||||
* @return [string]
|
* @return [string]
|
||||||
*/
|
*/
|
||||||
public function auto ($file = null, $parse = true, $search_depth = null, $preferred = null, $enclosure = null) {
|
public function auto ($file = null, $parse = true, $search_depth = null, $preferred = null, $enclosure = null) {
|
||||||
if ( $file === null ) {
|
if (is_null($file)) {
|
||||||
$file = $this->file;
|
$file = $this->file;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -526,11 +526,11 @@ class parseCSV {
|
|||||||
$search_depth = $this->auto_depth;
|
$search_depth = $this->auto_depth;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $enclosure === null ) {
|
if (is_null($enclosure)) {
|
||||||
$enclosure = $this->enclosure;
|
$enclosure = $this->enclosure;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $preferred === null ) {
|
if (is_null($preferred)) {
|
||||||
$preferred = $this->auto_preferred;
|
$preferred = $this->auto_preferred;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -629,7 +629,7 @@ class parseCSV {
|
|||||||
* @return [array|bool]
|
* @return [array|bool]
|
||||||
*/
|
*/
|
||||||
public function parse_file ($file = null) {
|
public function parse_file ($file = null) {
|
||||||
if ( $file === null ) {
|
if (is_null($file)) {
|
||||||
$file = $this->file;
|
$file = $this->file;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -884,7 +884,7 @@ class parseCSV {
|
|||||||
$data = null;
|
$data = null;
|
||||||
$file = null;
|
$file = null;
|
||||||
|
|
||||||
if ( $input === null ) {
|
if (is_null($input)) {
|
||||||
$file = $this->file;
|
$file = $this->file;
|
||||||
}
|
}
|
||||||
elseif (file_exists($input)) {
|
elseif (file_exists($input)) {
|
||||||
@@ -1066,7 +1066,7 @@ class parseCSV {
|
|||||||
* @return Processed value
|
* @return Processed value
|
||||||
*/
|
*/
|
||||||
protected function _enclose_value ($value = null, $delimiter = null) {
|
protected function _enclose_value ($value = null, $delimiter = null) {
|
||||||
if ( $delimiter === null ) {
|
if (is_null($delimiter)) {
|
||||||
$delimiter = $this->delimiter;
|
$delimiter = $this->delimiter;
|
||||||
}
|
}
|
||||||
if ($value !== null && $value != '') {
|
if ($value !== null && $value != '') {
|
||||||
@@ -1091,7 +1091,7 @@ class parseCSV {
|
|||||||
*/
|
*/
|
||||||
protected function _check_data ($file = null) {
|
protected function _check_data ($file = null) {
|
||||||
if (empty($this->file_data)) {
|
if (empty($this->file_data)) {
|
||||||
if ( $file === null ) $file = $this->file;
|
if (is_null($file)) $file = $this->file;
|
||||||
|
|
||||||
return $this->load_data($file);
|
return $this->load_data($file);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user