Need Help!!

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
Beezer
Forum Newbie
Posts: 2
Joined: Sun Jul 31, 2011 9:40 am

Need Help!!

Post by Beezer »

Fatal error: Call to a member function num_rows() on a non-object in /home/a8515087/public_html/application/models/applicationmodel.php on line 91


Heres the complete code

Code: Select all

<?php

/**
 * User Model
 *
 *
 * @copyright Copyright (c) 2008 [x-MoBiLe] Nulled
 * @license
 * @since 1/2/2008
 */
 
 ini_set('display_errors', 1);error_reporting(E_ALL);
 
class Applicationmodel extends Model
{
		//Constructor
		function Applicationmodel()
		{
				parent::Model();
		}
		function getApplications($onlyBasic = false)
		{
				if ($onlyBasic == true) $appQuery = $this->db->query('SELECT * FROM applications WHERE user_id=0');
				else  $appQuery = $this->db->query('SELECT * FROM applications');
				if ($appQuery->num_rows() > 0)
				{
						$applications = array();
						foreach ($appQuery->result_array() as $appRow)
						{
								$applications[$appRow['application_id']] = $appRow;
						}
						return $applications;
				}
				else  return false;
		}
		function getUserApplications()
		{
				$this->db->select('application_ids');
				$this->db->where('user_id', $this->session->userdata('user_id'));
				$this->db->limit(1, 0);
				$userAppQuery = $this->db->get('users_applications');
				if ($userAppQuery->num_rows() > 0)
				{
						$userAppRow = $userAppQuery->result_array();
						$appQuery = $this->db->query('SELECT * FROM applications WHERE application_id IN (' . $userAppRow[0]['application_ids'] . ')');
						if ($appQuery->num_rows() > 0)
						{
								$applications = array();
								foreach ($appQuery->result_array() as $appRow)
								{
										$applications[$appRow['application_id']] = $appRow;
								}
								return $applications;
						}
						else  return false;
				}
				else  return false;
		}
		function isApplication($appName)
		{
				$this->db->where('application_name', $appName);
				$this->db->limit(1, 0);
				$appQuery = $this->db->get('applications');
				if ($appQuery->num_rows() > 0)
				{
						$appRow = $appQuery->result_array();
						return $appRow[0]['application_id'];
				}
				else  return false;
		}
		function isUserCanAccessTheApplication($applicationId)
		{
				$this->db->select('application_ids');
				$this->db->where('user_id', $this->session->userdata('user_id'));
				$this->db->limit(1, 0);
				$userAppQuery = $this->db->get('users_applications');
				if ($userAppQuery->num_rows() > 0)
				{
						$userAppRow = $userAppQuery->result_array();
						$userAppArray = explode(',', $userAppRow[0]['application_ids']);
						if (array_search($applicationId, $userAppArray) === false) return false;
						else  return true;
				}
				else  return false;
		}
		function getLanguages()
{
    $this->db->select('lang_code, lang_name');
    $langQuery = $this->db->get('languages');
    $languages = array();
    if ($langQuery->num_rows() > 0)
    {
        foreach ($langQuery->result_array() as $langRow)
        {
            $languages[] = $langRow;
        }
    }
    return $languages;
  }
}

?>
:(
Last edited by Benjamin on Sun Jul 31, 2011 10:14 am, edited 1 time in total.
Reason: Added [syntax=php|sql|css|javascript] and/or [text] tags.
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

Re: Need Help!!

Post by social_experiment »

Is this the only code that you are using? This looks like that class as opposed to the code that does the work
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
Beezer
Forum Newbie
Posts: 2
Joined: Sun Jul 31, 2011 9:40 am

Re: Need Help!!

Post by Beezer »

Your right theres alot more to the script I'm trying to use. Please let me know if theres anything I can do to make this easier.

Thanx,
Bill
User avatar
social_experiment
DevNet Master
Posts: 2793
Joined: Sun Feb 15, 2009 11:08 am
Location: .za

Re: Need Help!!

Post by social_experiment »

Can you paste the script you run when receiving the error message
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” - Mosher’s Law of Software Engineering
Post Reply