Witango doesn't port easily, untll you build the framework to build php code like witango does, using resultsets and array manipulation. If you don't do that first, its very tough, and I can see the frustration. Here is an example of a class function in php that takes a mysqli connector and a string query, and returns an associative array resultset, just like witango results set from a query, with column names and all.

        /**
         * Query the database and return result set in an assoc. array
         * @author Robert Garcia
         * @param mysqli $myconn
         * @param string $query
         * @return array
         */
        public function getResultSetFromConn($myconn,$query) {
                $resultSet = array();
                if ($myconn)
                {
                        //now result is multidimensional assoc array.
                                if ($result = $myconn->query($query)) {
                                        $fields = $result->fetch_fields();
                                        while ($row = $result->fetch_array()) {
                                                $thisRow = array();
                                                foreach ($fields as $field){
                                                        $thisRow[$field->name] = 
$row[$field->name];
                                                }
                                                $resultSet[] = $thisRow;
                                        };
                                        $result->close();
                                }       
                }
                $temp = $myconn->errno;
                $temp = $myconn->error;
                return $resultSet;
        }

Think of how many times you dump an array in witango to a table. How do you do that in php, well, we build a function that takes IN a resultset type array, and a boolean for header.

        public function arrayToTable($inarray,$bool_header=true){
                if (!count($inarray)){return "";}
                $res = "";
                $res = "<table border=1><tr>";
                if ($bool_header){
                        foreach($inarray[0] as $key => $val){
                                $res .= "<td align=center><b>" . $key . 
"</b></td>";
                        }
                        $res .= "</tr>";
                }
                $res .= "<tr>";
                foreach($inarray as $rows){
                        foreach ($rows as $cols){
                                $res .= "<td>" . $cols . "</td>";
                        }
                        $res .= "</tr>";
                }
                $res .= "</table>";
                return $res;
        }

Here are the functions that we use that mimics the witango <@filter> tag

        /**
         * callback function for filter function
         *
         * @author Robert Garcia
         * @param array $array
         * @return array
         */
        private function filter_thisarray($array){
                $eval = "return ".$this->arrayeval.";";
                $res = eval($eval);
                return ($res);
        }

        /**
* Filter an array ($array = your passed in array, use it for the callback expression) * sample: $status = $global_app->filter($pcustArray,"\ $array['UserID'] == '".$inarray[0]['userId']."'");
         *
         * @author Robert Garcia
         * @param array $array
         * @param array $arrayeval
         * @return array
         */
        public function filter($array,$arrayeval){
                $this->arrayeval = $arrayeval;
return array_values(array_filter($array,array($this,"filter_thisarray")));
        }

And the @distinct tag

        /**
         * Output a distinct array from input array based on fieldname entered
         *
         * @author Robert Garcia
         * @param array $array
         * @param string $fieldname
         * @return array
         */
        public function array_distinct($array, $fieldname)
        {
          foreach ($array as $sub)
           $cmp[] = $sub[$fieldname];
          $unique = array_unique($cmp);
          foreach ($unique as $k => $rien)
           $new[] = $array[$k];
          return ($new);
        }


So basically, I rolled up my sleeves and built all this, then we used it to port. Porting goes much quicker this way, and allows you to still code like you used to in witango. Then as you start new projects, you still use some of these methods, and sometimes you do whatever the heck you want, because PHP is so flexible.

--

Robert Garcia
President - BigHead Technology
VP Application Development - eventpix.com
13653 West Park Dr
Magalia, Ca 95954
ph: 530.645.4040 x222 fax: 530.645.4040
[EMAIL PROTECTED] - [EMAIL PROTECTED]
http://bighead.net/ - http://eventpix.com/

On Jan 25, 2008, at 3:00 PM, Michael Heth wrote:


On Jan 25, 2008, at 2:01 PM, Kent Swisher wrote:

To Robert Garcia

I have started developing in PHP but find it very slow to develop compared to witango. The old witango builder wizard worked for 80% of our stuff and I really miss it in PHP.

Has anyone given much (any) thought to the concept of building your app/site proof of concept in Tango for the ease and speed of building the logical building blocks etc. And then once your FC is working as you want then porting it to PHP. From way back when CF was the big kid on the block I remember that the CF crowd came up with an app paradigm called FUSE (or something) and that when we looked at it it was basically a logic framework which mimic'd the Tango app architecture. You would only have 1 page but in that page was all the logical decisions on what to show the user based on the URL and their user vars.

Anyway, it seems that if this was embraced by the developers then someone on the list could make a nice biz of just porting apps to PHP. The Tango developers could build the porting fee into their original bid etc.

And finally for the sake of reality don't forget that the main (perhaps only) reason that PHP is the defacto standard now was that it was given away from the start and there is no way to effectively compete with free. That's how IE pushed Netscape aside and now NetNewsWire will push all the newsreader apps aside.

I laughed the other day when I saw the new decode for the acronym PHP, I don't remember what it was but they are trying to make you forget that PHP actually stands for "Personal Home Page".

M./

________________________________________________________________________
TO UNSUBSCRIBE: Go to http://www.witango.com/developer/maillist.taf

________________________________________________________________________
TO UNSUBSCRIBE: Go to http://www.witango.com/developer/maillist.taf

Reply via email to