/** * A shorthand function to call Diagnostics output * @param mixed $mixed * @param string $title Title of the output */ function dump($mixed, $title = 'Variables Dump') { if (is_string($mixed) && substr($mixed, 0, 5) == '<?xml') { // an XML dump if (!headers_sent()) { header('Content-Type:text/xml'); } echo $mixed; } else { // standard dump Fari_ApplicationDiagnostics::dump($mixed, $title); } }
/** * Echo the SQL statement into the view * @param string $statement SQL query string * @param array $values The values to insert, update * @param array/string $where The where clause * @return echo Query string into the view */ private function toString($statement, array $values = NULL, $where = NULL) { // traverse the values and where clause arrays if (is_array($where)) { $binder = 'set'; foreach (array($values, $where) as $array) { if (isset($array)) { // replace bound parametres with actual values $i = 0; foreach ($array as $value) { // determine value type of string or integer $value = Fari_Filter::isInt($value) ? "{$value}" : "'{$value}'"; // we have a variable binding key $statement = preg_replace("/:{$binder}{$i}/", $value, $statement); $i++; } } // a switch to keep track of which array are we traversing $binder = 'id'; } } // echo into the view Fari_ApplicationDiagnostics::dump($statement, 'Fari_Db Query String'); }