Jump to content

Recommended Posts

Posted

I can't get a select statement to fire up. Admitedly PHP isn't my strong suit, but I've tried everything I can think of. This function is supposed to return results for creating a new package.

 

Here are the related functions:

    private function DBConnection ($host_name, $data_base, $user_name, $pass_word) {
            $db = new PDO ("mysql:host=$host_name;dbname=$data_base", "$user_name", "$pass_word");
    }

    private function getPackages($module_row) {
        if (!isset($this->DataStructure))
            Loader::loadHelpers($this, array("DataStructure"));
        if (!isset($this->ArrayHelper))
            $this->ArrayHelper = $this->DataStructure->create("Array");
        
        try {
            $db = $this->DBConnection($module_row->meta->host_name, $module_row->meta->data_base, $module_row->meta->user_name, $module_row->meta->pass_word);
            $stmt = $db->query("SELECT * FROM Packages");
            $packages = $stmt->fetch(PDO::FETCH_ASSOC);
        }
        catch (PDOException $e) {
        }
         
        return $packages;        
}

Turning on MariaDB's general query log shows the connection going through, but the query isn't executed.

 

Please feel free to throw rotten tomatoes if you see a stupid mistake somewhere.

 

Posted

I still can't get it to fire up the query.

 

A few more details:

The code snippet is from a module I'm developing for a custom control panel at the-place-that-puts-food-on-the-table. The code is supposed to connect to a remote (keyword, NOT the blesta DB) database (which it does correctly) and execute a select query on the *remote* database (which doesn't work). The query is supposed to return packages for the package creation page, using the remote database for their names/specs.

 

I'm basically stuck on this step and don't know how to fix it. Any help is much appreciated.

Posted

FINALLY!

 

    private function getPackages($module_row) {
        try {
            $db = $this->DBConnection($module_row->meta->host_name, $module_row->meta->data_base, $module_row->meta->user_name, $module_row->meta->pass_word);
            $query = $this->DBQuery($db);
        }
        catch (PDOException $e) {
        }

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...