Jump to content
  • 0
herwaldi

Sprawdzenie kolumny getInstance();

Question

Szybkie pytanie

potrzebuje sprawdzić w PS 1.7 czy dana kolumna istnieje, jak najprościej to zrobić?

Jeżeli kolumny nie ma to sypie mi błędem: Unknown column 'mojaKolumna' in 'field list'

a chciałbym aby gdy jej nie ma to echo 'nie ma';

 

Mój kod:

$add = Db::getInstance()->getValue("SELECT mojaKolumna FROM pr_orders WHERE id_order=".$order->id);

if ($add) {

echo 'nie ma';

} else return false;

 

Share this post


Link to post
Share on other sites

1 answer to this question

Recommended Posts

  • 0

Spróbuj w ten sposób: SHOW COLUMNS FROM `nazwaTabeli` LIKE 'nazwaPola'

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More