コード例 #1
0
ファイル: db.php プロジェクト: kwstarikanos/Contacts
function Query($sql, $backtrace, $database = "contacts")
{
    /*Show or hide queries*/
    isset($_SESSION['debug']) && $_SESSION['debug'] == "on" ? $debug = 1 : ($debug = 0);
    /*Database connect*/
    include 'connection.php';
    $response = NULL;
    /*Start timer*/
    $msc = microtime(true);
    if ($result = $mysqli->query($sql)) {
        /*Successful Query execution*/
        //dump($mysqli,"mysqli");
        /*Stop timer*/
        $msc = number_format(microtime(true) - $msc, 3);
        /*increasing number of queries*/
        isset($_SESSION['Queries']) ? $_SESSION['Queries']++ : ($_SESSION['Queries'] = 1);
        if ($result !== true) {
            /*For SELECT queries*/
            //dump($result,"result");
            /*If exists records then fetch this.*/
            if ($result->num_rows) {
                $response = resultToArray($result);
            }
            /*Show SELECT query*/
            if ($debug) {
                showQuery("FETCH", $backtrace, $mysqli->host_info, $database, $sql, $result->num_rows ? $result->num_rows : 0, $mysqli->affected_rows, $msc, $result->num_rows ? $response : NULL);
            }
        } else {
            /*For INSERT, UPDATE, DELETE queries*/
            $response = $mysqli->insert_id ? $mysqli->insert_id : $mysqli->affected_rows;
            if ($debug) {
                showQuery("AFFECT", $backtrace, $mysqli->host_info, $database, $sql, $mysqli->insert_id, $mysqli->affected_rows, $msc, $response);
            }
        }
    } else {
        /*Query execution failed!*/
        $msc = number_format(microtime(true) - $msc, 2);
        /*Show failure query*/
        showQuery("FAILURE", $backtrace, $mysqli->host_info, $database, $sql, 0, 0, $msc, $mysqli->error);
        /*Return error message*/
        $response = getSqlErrors($mysqli->error_list);
    }
    /*Close database connection*/
    $mysqli->close();
    /*Return records in tabular, nothing if not exists records or a message if it fails.*/
    return $response;
}
コード例 #2
0
				</select>
				
				<select name="condition2" >
				<option value="">Entrada manual</option>
				<option value="Funcion">Funcion</option>';
foreach ($cols as $k => $v) {
    echo "<option value=\"" . $rows[$k] . "\">" . $cols[$k] . "</option>";
}
echo '<input type="text" name="condition3" id="condition3">
				<a href="#" onclick="window.open(\'' . $SYS["ROOT"] . 'Framework/Extensions/QueryBuilder/Helper.html\',\'helper\')">Ayuda de funciones</a>	
				<br><br><br><input type="submit" name="submit"> 
			</div>
			<input type="hidden" name="views" value=\'' . base64_encode($views) . '\'> 		<input type="hidden" name="views" value=\'' . base64_encode($views) . '\'> 	
		</form>
		';
showQuery($views);
?>
		
<div align="center"><form action="dev.php?command=querybuilder" method="POST" enctype="multipart/form-data">
		<input type="hidden" name="action" value="save">
		<input type="hidden" name="queryb" value="<?php 
echo $views;
?>
">
		Guardar consulta como <input type="text" name="nombre" value="">
		<input type="submit" name="Guardar" value="Guardar">
</form>		
		</div>
</td>
</tr>
</table>
コード例 #3
0
ファイル: view.php プロジェクト: BackupTheBerlios/ascore
        } else {
            PDF_html_2_pdf($data);
        }
    }
} else {
    /* Borramos bufferes */
    if ($print_mode == "yes" || $export_mode == "yes") {
        while (ob_end_clean()) {
        }
    }
    ob_start();
    $q = newObject("queryb", $u->query_id);
    if (strpos($q->queryb, "SELECT * FROM View") === 0) {
        // Es un query de una vista
        require_once "Lib/lib_autoquery.php";
        showQuery(str_replace("SELECT * FROM", "", $q->queryb), $u->reportname);
    } else {
        $res = _query(ereg_replace("AS '([a-zA-z\\|:0-9 ]*)'", "", $q->queryb));
        $bulk = array();
        for ($i = 0, $rows_affected = _affected_rows(); $i < $rows_affected; $i++) {
            $rawres = _fetch_array($res);
            //$p=array_slice($rawres,1);
            $bulk[] = $rawres;
        }
        if (!is_array($bulk) || sizeof($bulk) < 1) {
            die("No hay resultados");
        }
        $q->searchResults = $bulk;
        $res = _query($q->queryb);
        $rawres = _fetch_array($res);
        $titles = array_keys($rawres);
コード例 #4
0
 private function buildQuery($sql)
 {
     if (empty($sql)) {
         return FALSE;
     }
     $query = $sql;
     if ($this->where) {
         $query .= " " . $this->where . " ";
         $this->arrValues = array_merge($this->arrValues, $this->whereVal);
     }
     $query .= !empty($this->orderBy) ? implode(' ', $this->orderBy) . " " : "";
     $query .= !empty($this->limit) ? " LIMIT " . $this->limit . " " : "";
     $query .= !empty($this->offset) ? " OFFSET " . $this->offset . " " : "";
     showQuery($query, $this->arrValues);
     return $query;
 }