DEFAULT NULL?

Hello,

[php]
$table = “j6l4b_postinstall_messages”;
$result = $mysqlibag->query(“SHOW COLUMNS FROM $table”);
$i
while ($row = $result->fetch_assoc()) {
if($row[‘Null’] == “YES”){
$null_array[$i] = $row[‘Null’];
$i++;
}
}
[/php]
Output:
Array
(
[9] => YES
[10] => YES
[11] => YES
[12] => YES
)

However, only rows 11 and 12 are NULL
9th and 10th lines are blank but not NULL

How can I get only NULLs?
Line 11 and 12, only “DEFAULT NULL”

Thanks

Change the column default. If you are using PHPmyAdmin, it is easy to alter the table scheme.

My purpose is not to change.
How do I get this information with the following code?
[php]
$table = “j6l4b_postinstall_messages”;
$result = $mysqlibag->query(“SHOW COLUMNS FROM $table”);
$i;
while ($row = $result->fetch_assoc()) {
if($row[‘Null’] == “YES”){
$null_array[$i] = $row[‘Null’];
$i++;
}
}
[/php]

You can’t.

Try checking on $row[‘Default’]

I think I’ve solved the problem
[php]
$result = $mysqlibag->query(“SHOW COLUMNS FROM $table”);

$i = 1;
while ($row = $result->fetch_assoc()) {
    echo "<pre>";

    if (! isset($row['Default'])) {
    if($row['Null'] == "YES") {
    $null_array[$i] = $row['Null'];
        }
    }
    echo "</pre>";
 $i++;   
}

print_r($null_array);
[/php]
Output
Array
(
[11] => YES
[12] => YES
)

What is the real problem you are trying to solve? It appears you want to know if certain columns are set to allow NULL or not, but WHY? This appears to be a classic XY Problem. See my signature for an explanation.

I’m beginner,
PHP is not my profession, but hobby, I’m trying to do something for myself

Since you can’t answer the question, I can’t help you.

I solved the problem
Thank you

Sponsor our Newsletter | Privacy Policy | Terms of Service