Ejemplo n.º 1
0
Archivo: data.php Proyecto: milkae/Php
     }
     $q =& $req['query'];
     $p =& $req['params'];
     if ($req['limited']) {
         $pageSize = $config['queryPageSize'];
         $cellSize = $config['queryMaxCellSize'];
         $dataSize = $config['queryMaxDataSize'];
         $rowsAmnt = $config['queryMaxRows'];
     } else {
         $pageSize = $cellSize = $dataSize = $rowsAmnt = 0;
     }
     $a = new MySQLQuery($c, $req['limited'] ? new QueryResultJSONWriter($pageSize) : NULL, $cellSize, $dataSize, $rowsAmnt);
     if (is_array($q)) {
         $aff = 0;
         for ($i = 0; $i < count($q); $i++) {
             $r = $a->query($q[$i], $p[$i], $req['flags']);
             $aff += $r['affectedRows'];
         }
         $a = array('affectedRows' => $aff);
     } else {
         $a = $a->query($q, $p, $req['flags']);
     }
     if ($req['toFile'] && $a['results']) {
         $f = new TempFile();
         $f->write($a['results'][0]['data'][0][0]);
         $a = array('file' => $f->name, 'alias' => 'cell-' . date('Ymd-His') . '.data');
     }
     respond($a);
     break;
 case 'get_query_result':
     $f = $req['file'] . '-' . $req['result'] . '-' . $req['page'];
Ejemplo n.º 2
0
 function query($sql)
 {
     // Pass it an SQL query and if the query was successful
     // it returns a MySQLQuery object which you can get results from.
     $start = getmicrotime();
     $q = new MySQLQuery($this->conn);
     $q->query($sql);
     $duration = getmicrotime() - $start;
     global $mysqltotalduration;
     $mysqltotalduration += $duration;
     twfy_debug("SQL", "Complete after {$duration} seconds.");
     // We could also output $q->mysql_info() here, but that's for
     // PHP >= 4.3.0.
     return $q;
 }
Ejemplo n.º 3
0
    public function handleResultStarted(&$fields)
    {
        $this->fields = $fields;
        $this->file->write($this->encl[0]);
    }
    public function handleResultEnded(&$result)
    {
        $this->file->write("\n" . $this->encl[1] . ";\n");
    }
    public function handleQueryEnded(&$response)
    {
        $response = array('result' => $this->file->name);
    }
}
/////
switch (strtolower($ARGS['format'])) {
    case 'csv':
    case 'txt':
        $handler = new QueryResultExportCSV($LINK, $ARGS);
        break;
    case 'sql':
        $handler = new QueryResultExportSQL($LINK, $ARGS);
        break;
    case 'json':
    case 'php':
        $handler = new QueryResultExportArrArr($LINK, $ARGS);
        break;
}
$q = new MySQLQuery($LINK, $handler);
return $q->query($ARGS['query'], NULL, 0, $ARGS['fields'], $ARGS['offset'], $ARGS['limit']);