RowArray() public method

Reads the current row and returns contents as an array or returns false on error
public RowArray ( integer $optional_row_number = null, integer $resultType = MYSQLI_BOTH ) : array
$optional_row_number integer (Optional) Use to specify a row
$resultType integer (Optional) The type of array Values can be: MYSQLI_ASSOC, MYSQLI_NUM, MYSQLI_BOTH
return array Array that corresponds to fetched row or FALSE if no rows
Ejemplo n.º 1
0
 /**
  * returns single expense entry as array
  *
  * @param integer $id ID of entry in table exp
  * @global array $kga kimai-global-array
  * @return array
  * @author sl
  */
 public function get_expense($id)
 {
     $id = MySQL::SQLValue($id, MySQL::SQLVALUE_NUMBER);
     $table = $this->getExpenseTable();
     $projectTable = $this->getProjectTable();
     $customerTable = $this->getCustomerTable();
     $query = "SELECT * FROM {$table}\n\t              LEFT JOIN {$projectTable} USING(projectID)\n\t              LEFT JOIN {$customerTable} USING(customerID)\n\t              WHERE {$table}.expenseID = {$id} LIMIT 1;";
     $this->conn->Query($query);
     return $this->conn->RowArray(0, MYSQLI_ASSOC);
 }
Ejemplo n.º 2
0
 /**
  * checks if a given db row based on the $idColumn & $id exists
  * @param string $table
  * @param array $filter
  * @return bool
  */
 protected function rowExists($table, array $filter)
 {
     $select = $this->conn->SelectRows($table, $filter);
     if (!$select) {
         $this->logLastError('rowExists');
         return false;
     }
     return (bool) $this->conn->RowArray(0, MYSQLI_ASSOC);
 }
Ejemplo n.º 3
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";
 }
Ejemplo n.º 4
0
    die('Error contacting database!' . $sql);
}
$db->TruncateTable("import_tempstock");
//destroy table data
$sql = "CREATE TABLE IF NOT EXISTS `import_categories` (\n  `uid` int(11) NOT NULL AUTO_INCREMENT,\n  `code` varchar(16) NOT NULL,\n  `hkcategory` varchar(50) NULL,\n  `wwwcategory` varchar(254) NULL,\n  `hksupplier` varchar(50) NULL,\n  `wwwsupplier` varchar(254) NULL,\n  PRIMARY KEY (`uid`),\n  KEY `code` (`code`)\n) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1 ";
$results = $db->Query($sql);
if (!$results) {
    die('Error contacting database!' . $sql);
}
// this table is not to be emptied, as it contains a chart of SUBSTITUTE names of categories or suppliers
//
//
$now = time();
$results = $db->Query("SHOW TABLE STATUS WHERE name =  'import_categories'");
// read the timestamp to the table to tell us when it was last updated
$timeres = $db->RowArray();
//print_r($timeres);
$dbtime = $timeres['Comment'];
if ($now > $dbtime + 3600) {
    //last updated an hour ago
    // process the categories first!
    $dbr = new dbf_class('datastore/REFCODES.DBF');
    $num_rec = $dbr->dbf_num_rec;
    $field_num = $dbr->dbf_num_field;
    for ($i = 0; $i < $num_rec; $i++) {
        unset($code);
        //empty our temp array for each iteration
        $row = $dbr->getRow($i);
        switch ($row[0]) {
            case 'Q':
                //category
Ejemplo n.º 5
0
    if ($lang == 'de') {
        echo 'Datenbank hat Zugriff verweigert. Gehen Sie bitte zurück.<br /><button onclick="step_back(); return false;">Zurück</button>';
    } else {
        echo 'The database refused access. Please go back.<br /><button onclick="step_back(); return false;">Back</button>';
    }
    return;
}
// ====================================================================================================================
// if there is any error we have to show this page again, otherwise redirect to the next step
$errors = false;
ob_start();
// get permissions
$showDatabasesAllowed = false;
$createDatabaseAllowed = false;
$result = $con->Query('SHOW GRANTS');
while ($row = $con->RowArray(null, MYSQLI_NUM)) {
    if (strpos($row[0], 'SHOW DATABASES') !== false) {
        $showDatabasesAllowed = true;
    } elseif (strpos($row[0], 'CREATE,') !== false) {
        $createDatabaseAllowed = true;
    } elseif (strpos($row[0], 'ALL PRIVILEGES') !== false) {
        $showDatabasesAllowed = true;
        $createDatabaseAllowed = true;
    }
}
$useDatabases = array();
if ($showDatabasesAllowed) {
    try {
        $con->MoveFirst();
        $result = $con->Query('SHOW DATABASES');
        while ($row = $con->RowArray(-2, MYSQLI_NUM)) {
Ejemplo n.º 6
0
for ($index = 0; $index < $db->RowCount(); $index++) {
    $row = $db->Row($index);
    echo "Index " . $index . ": ";
    echo $row->Color . " and " . $row->Age . "<br />\n";
}
echo "<hr />\n";
// ---------------------------------------------------------
// Now let's just show all the data as an HTML table
// This method is great for testing or displaying simple results
echo $db->GetHTML(false);
echo "<hr />\n";
// ---------------------------------------------------------
// Now let's grab the first row of data as an associative array
// The paramters are completely optional. Every time you grab a
// row, the cursor is automatically moved to the next row. Here,
// we will specify the the first row (0) to reset our position.
// We will also specify what type of array we want returned.
$array = $db->RowArray(0, MYSQL_ASSOC);
// Display the array
echo "<pre>\n";
print_r($array);
echo "</pre>\n";
echo "<hr />\n";
// ---------------------------------------------------------
// And now show the individual columns in the array
echo $array[Color] . " and " . $array[Age] . "<br />\n";
// Grab the next row as an array. Notice how we didn't specify
// a row (0) like above? It's completely optional.
$array = $db->RowArray();
echo $array[Color] . " and " . $array[Age] . "<br />\n";
// There are so many different ways to use the Ultimate MySQL class!