|
Posted by Jerry Stuckle on 04/17/06 21:50
Wescotte wrote:
> Yes, I understand that but I still fail to see how to make it all work.
>
> If I have a base edi file class and a class for each type that inherits
> the base class that contains the 3 functions mentioned above I'd still
> need do have something like
>
> $query = "select class_name, class_source from class_list";
> $result = odbc_exec($connection, $query);
>
> $done = false;
>
> while (odbc_fetch_row($result) || $done) {
> include odbc_result($result, "class_source");
> $test_case = new odbc_result($result, "class_name"); // I can't
> see this working but I haven't specifcally tested it yet
> if ($test_case.Known_File_Format($fillename)) {
> $test_case.Parse_file($filename);
> $done = true;
> }
> }
>
>
> Again, the whole purpose of this was to allow a user to add additional
> EDI file formats (and code to process them) without acessing any code.
> Maybe I'm missing something obvious but I can't think my way around how
> to actually get this to work without hard coding the source names/class
> names.
>
No, you include all the class sources at the beginning. Then you instantiate
the appropriate one as you need it, i.e.
while (odbc_fetch_row($result) || $done) {
// Get the file format here, then
$myObject = null;
switch($fileFormat) {
case "format1" :
$myObject = new MyClass1();
break;
case "format2":
$myObject = new MyClass2();
break;
// etc.
}
if (myObject) {
$myObject->doSomething($odbc_result); // Call function(s) in the class
}
Each class will handle one file format and all classes will have the same
function names. Just determine the file format, instantiate the appropriate
class and let it do the work.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Navigation:
[Reply to this message]
|