I wrote a script to read the Netflix catalog and populate my DB. Everything worked fine as a web script (except for timeouts) so I shifted to calling directly form the console.
I noticed a few oddities, like __construct() no longer being called (but that was easily remidied using the class name as a function.
Now I can't get my arrays to work as before, here's the general Idea.
(actually Ihave trioed a few combos, so Ill share them all)
1 - this worked in the web script versino just fine, no longer works calling from console
//declare empty
var $genreArray=array();
//later I add values one at a time as the XML is parsed
array_push($this->genreArray,$attrs['term']);
//after I have parsed an entire "title" element, I iterate the array
foreach ($this->genreArray as $value) {
// never gets called - array seen as empty
$this->db->linkGenre($value,$this->title_uid);
}
2 - so I tried the PHP manul; recommendation - nothiong
//declare empty
var $genreArray=array();
//later I add values one at a time as the XML is parsed
$this->genreArray[]=$attrs['term'];
//after I have parsed an entire "title" element, I iterate the array
foreach ($this->genreArray as $value) {
// never gets called - array seen as empty
$this->db->linkGenre($value,$this->title_uid);
}
3 - so finally i tried manually tracking the index
//declare empty array
var $genreArray=array();
var $gi=0;
//later I add values one at a time as the XML is parsed
$this->genreArray[$this->gi++]=$attrs['term'];
//after I have parsed an entire "title" element, I iterate the array
foreach ($this->genreArray as $value) {
// never gets called - array seen as empty
$this->db->linkGenre($value,$this->title_uid);
}
SO I am totally stumped now.
Has anyone declared empty arrays and populated via console?
(all 3 of these work via the web - so I need a console expert here)
Thanks for the support, here are the additonal details requested;
php -v
PHP 4.4.9 (cli) (built: Sep 17 2008 12:02:18) Copyright (c) 1997-2008 The PHP Group Zend Engine v1.3.0, Copyright (c) 1998-2004 Zend Technologies with Zend Extension Manager v1.2.2, Copyright (c) 2003-2007, by Zend Technologies with Zend Optimizer v3.3.3, Copyright (c) 1998-2007, by Zend Technologies
each snippet was tried in a seperate run. what detaisl on the class are you interested in?
I have used echo statements to verify that the code is being called as expected. And if I hit the script through a URL everyhting kicks off fine (for the first few thousand records until the timeout)
No errors are being thrown, I even tried adding
error_reporting(E_ALL);
ini_set('display_errors', true);