LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 06-27-2013, 11:04 PM   #1
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,278

Rep: Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694
Is there a mysql query validation library for php?


Writing some php that will allow a user to dump out some mysql for an administrator to run.

It would be very nice to be able to validate the mysql statements before dumping them out to be run. Obviously an admin can run the sql against an offline slave db or something -- but for the sake of trying, is there a lib out there to validate sql?

So this would return a value of 0 or ok!

select * from some_table;

And this would return a value of 1 or noway!

sex * from some_table;

Anyone have any good libraries?
 
Old 06-27-2013, 11:27 PM   #2
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,862
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
Perhaps you could try "EXPLAIN SELECT ..." -- if it gives an error, the SELECT might be wrong.
 
1 members found this post helpful.
Old 06-27-2013, 11:55 PM   #3
szboardstretcher
Senior Member
 
Registered: Aug 2006
Location: Detroit, MI
Distribution: GNU/Linux systemd
Posts: 4,278

Original Poster
Rep: Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694Reputation: 1694
Thank you. I've considered that. But the reason the sql is being plopped out in the first place is because it can't be run directly on the prod DB server. So EXPLAIN will not work for me.
 
Old 06-28-2013, 01:01 AM   #4
dugan
LQ Guru
 
Registered: Nov 2003
Location: Canada
Distribution: distro hopper
Posts: 11,223

Rep: Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320Reputation: 5320
Quote:
Originally Posted by szboardstretcher View Post
Writing some php that will allow a user to dump out some mysql for an administrator to run.

sex * from some_table;
The SQL is being generated by the PHP that you're writing, right?

Why would your PHP output that in the first place?
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Please help: Your PHP MySQL library version 5.0.92 differs from your MySQL server ver DarkSlayer Linux - Server 3 04-12-2011 03:03 AM
query mysql using PHP for Persian mohtasham1983 Programming 2 07-08-2007 09:56 PM
php: Why Can't I Query Mysql DB?? flamesrock Programming 7 11-16-2004 12:36 AM
PHP MySQL Query Question vi0lat0r Programming 1 07-15-2004 05:02 AM
Form validation problem (PHP+MySQL) linuxfond Programming 13 09-08-2003 12:11 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:43 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration