Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8017057
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T20:43:36+00:00 2026-06-04T20:43:36+00:00

class for MVC to return fetch_array/object results class DbDriver{ private $connection; private $query; private

  • 0

class for MVC to return fetch_array/object results

  class DbDriver{
    private $connection;
    private $query;
    private $result;
    public function connect()
        {
        $host             = 'localhost';
        $user             = '';
        $password         = '';
        $database         = '';
        $this->connection = mysql_connect($host, $user, $password);
        $this->connection = mysql_select_db($database);
        return TRUE;
        }
    public function disconnect()
        {
        $this->connection->mysql_close();
        return TRUE;
        }
    public function prepare($query)
        {
        $this->query = $query;
        return TRUE;
        }
    public function query()
        {
        if (isset($this->query))
            {
            $this->result = $this->connection->mysql_query($this->query);
            return TRUE;
            }
        return FALSE;
        }
    public function fetch($type = 'object')
        {
        if (isset($this->result))
            {
            switch ($type)
            {
                case 'array':
                    $row = $this->result->mysql_fetch_array();
                    break;
                case 'object':
                default:
                    $row = $this->result->mysql_fetch_object();
                    break;
            }
            return $row;
            }
        return FALSE;
        }
    }

returns

[Wed May 30 11:55:42 2012] [error] [client] PHP Fatal error: Call to a member function mysql_query() on a non-object in /var/www/httpdocs/test/mysql.php on line 30

line 30

        $this->result = $this->connection->mysql_query($this->query);

ill go nuts. >.<

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T20:43:39+00:00Added an answer on June 4, 2026 at 8:43 pm

    Because mysql_query:

    Returns a MySQL link identifier on success or FALSE on failure.

    so $this->connection is not object.

    Please use PDO driver or MySQLi, mysql_* extensions will be deprecated in the future.

    Good PDO examples

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is an example of using ThrowawayController in Spring MVC: public class DisplayCourseController implements
See the following Mock Test by using Spring/Spring-MVC public class OrderTest { // SimpleFormController
This is my MVC model: public class Link { [DatabaseGenerated(DatabaseGeneratedOption.Identity)] public Guid ID {
I got a ASP.NET MVC controller like this [Authorize] public class ObjectController : Controller
I have repository class in asp.net mvc which has this, public Material GetMaterial(int id)
I have a simple class in asp.net mvc that looks like this: public class
I have the following model Person in my UI MVC layer: public class Person
Is there an ASP.NET MVC controller or helper class that can automatically return the
I have a Spring MVC Controller class (bean): @Controller @RequestMapping(/index.jsp) public class EjbCaller {
public class HomeController : Controller { public ActionResult Index() { return View(); } /*

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.