7 Replies - 929 Views - Last Post: 19 August 2015 - 04:54 AM Rate Topic: -----

#1 Zel2008   User is offline

  • D.I.C Addict

Reputation: 17
  • View blog
  • Posts: 893
  • Joined: 06-January 09

SQL and query strings with PHP

Posted 18 August 2015 - 02:15 PM

Hi all,

I've been forced into a really bad situation that I can't change. The only way I have to call a PHP script is to call it directly from the browser or in another script inside a Microsoft WebClient object. I also cannot access an SQL database directly -- the only way I can access it is through PHP and mysqli. The application that I'm building must be called from a back end (non PHP) script.

So, my conundrum is this -- my back end script does almost everything I need to do, and it doesn't need to be attached to the browser. But, it needs to make a database call, and the only way to do this is through PHP. I can build the SQL command in my back end script, but then I have no way to call it without somehow moving to PHP.

So, I have 2 options that I can see:
1. Keep the command building logic in the back end script and pass the entire SQL command to PHP with a query string.
2. Move all the command building logic to PHP.

But, this doesn't help the fact that all I can return from PHP to a back end script (as far as I know) is a string, which eliminates the possibility of a data structure like an array.

Can anyone help me figure out what might be a good way to implement this?

Thanks,
Zel2008

This post has been edited by Zel2008: 18 August 2015 - 02:16 PM


Is This A Good Question/Topic? 0
  • +

Replies To: SQL and query strings with PHP

#2 JackOfAllTrades   User is offline

  • Saucy!
  • member icon

Reputation: 6259
  • View blog
  • Posts: 24,028
  • Joined: 23-August 08

Re: SQL and query strings with PHP

Posted 18 August 2015 - 02:23 PM

What's the back-end script? You do know about the MySQL command line client, right?
Was This Post Helpful? 0
  • +
  • -

#3 CTphpnwb   User is online

  • D.I.C Lover
  • member icon

Reputation: 3837
  • View blog
  • Posts: 13,994
  • Joined: 08-August 08

Re: SQL and query strings with PHP

Posted 18 August 2015 - 02:31 PM

I'm confused. Doesn't the solution to your previous question provide an answer to this one?
Was This Post Helpful? 0
  • +
  • -

#4 Zel2008   User is offline

  • D.I.C Addict

Reputation: 17
  • View blog
  • Posts: 893
  • Joined: 06-January 09

Re: SQL and query strings with PHP

Posted 18 August 2015 - 02:50 PM

View PostCTphpnwb, on 18 August 2015 - 03:31 PM, said:

I'm confused. Doesn't the solution to your previous question provide an answer to this one?


Unfortunately, no. As I replied to the other post, it turned out that it was a network problem. My network and server is set up in a really weird way. MySQL can't be accessed directly for any kind of scripting, either from the command line client (yes, I know about it :) ) or from back end scripting. The back end script I'm using is PowerShell, but that's actually not so important to the question. The only way to access an SQL database at all is in a roundabout way through PHP. This isn't my setup, it's a system that I'm currently being shoehorned into, and I can't change it, as much as I'd like to.

I'm pretty much throwing out feelers to any experts I can at the moment -- this system is set up in such a strange way that I have no idea of how to handle it.

This post has been edited by Zel2008: 18 August 2015 - 02:52 PM

Was This Post Helpful? 0
  • +
  • -

#5 CTphpnwb   User is online

  • D.I.C Lover
  • member icon

Reputation: 3837
  • View blog
  • Posts: 13,994
  • Joined: 08-August 08

Re: SQL and query strings with PHP

Posted 18 August 2015 - 03:00 PM

View PostZel2008, on 18 August 2015 - 05:50 PM, said:

My network and server is set up in a really weird way. MySQL can't be accessed directly for any kind of scripting, either from the command line client (yes, I know about it :)/> ) or from back end scripting.

Guess what PHP is? That's right, it's a back end scripting language!

Assuming you can get PHP to access the database, you could try using json_encode() or serialize() to pass an array back.
Was This Post Helpful? 0
  • +
  • -

#6 ArtificialSoldier   User is offline

  • D.I.C Lover
  • member icon

Reputation: 2760
  • View blog
  • Posts: 8,062
  • Joined: 15-January 14

Re: SQL and query strings with PHP

Posted 18 August 2015 - 03:16 PM

You don't need a web server with PHP either, you can call it via the command line also.
Was This Post Helpful? 0
  • +
  • -

#7 astonecipher   User is offline

  • Enterprise Software Architect
  • member icon

Reputation: 3150
  • View blog
  • Posts: 11,955
  • Joined: 03-December 12

Re: SQL and query strings with PHP

Posted 18 August 2015 - 08:20 PM

This seems really odd...

RESTFUL API on the backend using something like slim, or build your own. Can be ran from command line using the router to call the appropriate methods.

They return a json string for parsing with whatever front end or other system being operated.
Was This Post Helpful? 0
  • +
  • -

#8 Zel2008   User is offline

  • D.I.C Addict

Reputation: 17
  • View blog
  • Posts: 893
  • Joined: 06-January 09

Re: SQL and query strings with PHP

Posted 19 August 2015 - 04:54 AM

Thanks all,
I think I've got a good way to do this now, I appreciate all the ideas. :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1