QueryArray() public method

Executes the given SQL query and returns a multi-dimensional array
public QueryArray ( string $sql, integer $resultType = MYSQLI_BOTH ) : array
$sql string The query string should not end with a semicolon
$resultType integer (Optional) The type of array Values can be: MYSQLI_ASSOC, MYSQLI_NUM, MYSQLI_BOTH
return array A multi-dimensional array containing all the data returned from the query or FALSE on all errors
Esempio n. 1
0
 public function login($data)
 {
     $db = new MySQL(true, 'color64', 'localhost', 'color64', 'nu5Jc4JdtZK4RCHH');
     $sql = 'SELECT * FROM `users` WHERE `id` = "' . $data['u'] . '" AND `password` = "' . MD5($data['p']) . '";';
     $result = $db->QueryArray($sql);
     return $result;
 }
Esempio n. 2
0
 function dumpTableData($table)
 {
     $conn = new MySQL(true, DBNAME, DBHOST, DBUSER, DBPASS, "", true);
     $strTables = "SELECT * FROM `{$table}`";
     $conn->QueryArray($strTables);
     $cntTables = $conn->RowCount();
     if ($cntTables) {
         $num_fields = $conn->GetColumnCount($table);
         $this->output .= "\n\n";
         $this->output .= "-- \n";
         $this->output .= "-- Dumping data for table `{$table}` \n";
         $this->output .= "-- \n\n";
         $fields = '';
         $field_type = array();
         $i = 0;
         while ($i < $num_fields) {
             if (!$fields) {
                 $fields = "`" . $conn->GetColumnName($i, $table) . "`";
             } else {
                 $fields .= ", " . "`" . $conn->GetColumnName($i, $table) . "`";
             }
             //                array_push($field_type, $conn->GetColumnDataType($i, $table));
             $i++;
         }
         $conn->MoveFirst();
         while (!$conn->EndOfSeek()) {
             $rsTable = $conn->RowArray();
             $this->output .= "INSERT INTO `{$table}` ({$fields}) VALUES (";
             for ($i = 0; $i < $num_fields; $i++) {
                 if (is_null($rsTable[$i])) {
                     $this->output .= "null";
                 } else {
                     switch ($field_type[$i]) {
                         case 'int':
                             $this->output .= $rsTable[$i];
                             break;
                         case 'string':
                         case 'blob':
                         default:
                             $this->output .= "'" . addslashes($rsTable[$i]) . "'";
                             break;
                     }
                 }
                 if ($i < $num_fields - 1) {
                     $this->output .= ", ";
                 }
             }
             $this->output .= ");\n";
         }
     }
     $this->output .= "\n";
 }
Esempio n. 3
0
<?php

ini_set("display_errors", 0);
include "./classes/mysql.class.php";
if ($_GET['pid'] == "") {
    echo "enter pid in url";
    exit;
} else {
    $reqparam = $_GET['pid'];
}
$db = new MySQL();
$db->Open();
$sql1 = "SELECT p.name,  DATE_FORMAT(p.age,'%d-%b-%Y') as dob, floor((((YEAR(NOW()) - YEAR(p.age)))*12 + (((MONTH(NOW()) - MONTH(p.age)))))/12) as age, place FROM person p where p.personid = '" . $reqparam . "'";
$row1 = $db->QueryArray($sql1);
?>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-type" content="text/html;charset=utf-8" />  
<meta name="viewport" content="width=360, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0,target-densitydpi=device-dpi, user-scalable=no">
<meta http-equiv="cache-control" content="max-age=0" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="expires" content="0" />
<meta http-equiv="expires" content="Tue, 01 Jan 1980 1:00:00 GMT" />
<meta http-equiv="pragma" content="no-cache" />
<title><?php 
echo $row1[0][0];
?>
 - Filmography</title>

<!-- / END -->
    if (isset($_SERVER['HTTP_ACCESS_CONTROL_REQUEST_METHOD'])) {
        header("Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS");
    }
    if (isset($_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS'])) {
        header("Access-Control-Allow-Headers: {$_SERVER['HTTP_ACCESS_CONTROL_REQUEST_HEADERS']}");
    }
}
include "mysql.class.php";
$database = new MySQL();
global $database;
if (!isset($_GET["parametro"])) {
    if ($database->Query("SELECT\n                                    kiiconnect_setting.nombre,\n                                    kiiconnect_setting.tag,\n                                    kiiconnect_setting.descripcion,\n                                    kiiconnect_setting.icono,\n                                    kiiconnect_setting.link,\n                                    kiiconnect_categoria.nombre AS categoria,\n                                    kiiconnect_categoria.id AS id_categoria,\n                                    kiiconnect_categoria.filecategoria,\n                                    kiiconnect_categoria.filecategoria2,\n                                    kiiconnect_categoria.icono AS categoria_icono\n                                FROM\n                                    kiiconnect_setting\n                                INNER JOIN kiiconnect_categoria ON kiiconnect_setting.id_categoria = kiiconnect_categoria.id\n                                WHERE\n                                    activo = 1\n                                ORDER BY\n                                    orden ASC")) {
        echo $database->GetJSON();
    } else {
        echo "<p>Query Failed</p>";
    }
} else {
    $temp = $database->QueryArray("SELECT\n                                    kiiconnect_categoria.nombre AS categoria,\n                                    kiiconnect_categoria.id AS id_categoria,\n                                    kiiconnect_categoria.iconodev AS categoria_icono,\n                                    kiiconnect_categoria.filecategoriadev AS filecategoria\n                                FROM\n                                    kiiconnect_categoria\n                                WHERE\n                                  activo = 1\n                                ORDER BY orden2", MYSQL_ASSOC);
    $temp2 = array();
    foreach ($temp as $index => $categoria) {
        $categoria_id = $categoria['id_categoria'];
        //            CONCAT('" . '<span style="font-weight:bold">' ." ', kiiconnect_setting.nombre, '</span>') AS nombre,
        $itemsCategoria = $database->QueryArray("SELECT\n                                    kiiconnect_setting.nombre,\n                                    kiiconnect_setting.tag,\n                                    kiiconnect_setting.descripcion,\n                                    kiiconnect_setting.icono,\n                                    kiiconnect_setting.file,\n                                    kiiconnect_setting.link\n                                FROM\n                                    kiiconnect_setting\n                                 WHERE\n                                    activo = 1 AND id_categoria = {$categoria_id}\n                                ORDER BY\n                                    orden ASC", MYSQL_ASSOC);
        if ($itemsCategoria != false) {
            $categoria['items'] = $itemsCategoria;
            $temp2[] = $categoria;
        }
    }
    $temp3 = json_encode($temp2);
    echo $temp3;
}
Esempio n. 5
0
 /**
  * Return all rows for the given sql query.
  *
  * @param string $query the sql query to execute
  * @return array
  */
 public function queryAll($query)
 {
     return $this->conn->QueryArray($query);
 }
Esempio n. 6
0
//uid
//prodcode
//descr
//model
//category
//url
//price
//trade
//stocklevel
//updated
//onorder
//webready
//supplier
//brand
$sql = "SELECT * from import_hkstock";
$gethk = $db->QueryArray($sql);
$new_id = $db->InsertRow("webstock", $insert);
if (!$new_id) {
    //print_r ($insert);
    die('Unable to write record to DB.');
}
unset($insert);
echo '</table>';
//echo('<input type="submit" name="submit" value="submit" />');
echo '</form>';
echo '<br><h4>Finished, you may close this page, </h4></body>';
// If there were no errors...
// Commit the transaction and save these records to the database
if ($db->TransactionEnd()) {
    $db->Kill();
    $db->Release();
Esempio n. 7
0
<?php

ini_set("display_errors", 0);
include "./classes/mysql.class.php";
if ($_GET['y'] == "") {
    $reqparam = "2015";
} else {
    $reqparam = $_GET['y'];
}
$db = new MySQL();
$db->Open();
$sql7 = "SELECT  count(*) as cnt FROM movie m;";
$row7 = $db->QueryArray($sql7);
?>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-type" content="text/html;charset=utf-8" />  
<meta name="viewport" content="width=360, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0,target-densitydpi=device-dpi, user-scalable=no">
<meta http-equiv="cache-control" content="max-age=0" />
<meta http-equiv="cache-control" content="no-cache" />
<meta http-equiv="expires" content="0" />
<meta http-equiv="expires" content="Tue, 01 Jan 1980 1:00:00 GMT" />
<meta http-equiv="pragma" content="no-cache" />
<title><?php 
echo $reqparam;
?>
 - Year in Film</title>
<link href="css/helper.css" media="screen" rel="stylesheet" type="text/css" />

<!-- Beginning of compulsory code below -->