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 8577087
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T20:04:59+00:00 2026-06-11T20:04:59+00:00

Is it possible to ask for all data in my database and make objects

  • 0

Is it possible to ask for all data in my database and make objects from it and save it into an array or something, so I just need to call the database once and afterwards I just use my local array? If yes, how is it done?

public function getAllProjects(){

   $query="SELECT * FROM projects";
   $result=mysql_query($query);
   $num=mysql_numrows($result);
   while ($row = mysql_fetch_object($result)) {
      // save object into array
   }
}

public function fetchRow($row){
  include("Project.php");
  $project = new Project();

  $id=$row->id;
  $project->setId($id); 

  $title=$row->title;
  $project->setTitle($title);   

  $infos=$row->info;
  $project->setInfo($infos);

  $text=$row->text;
  $project->setText($text);

  $cate=$row->category;
  $project->setCategory($cate);

  return $project;
}

If I have for example this code. How do i store the objects correctly into an array, where I grab the data from? And why can’t I make more than one object of type “Project”?

  • 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-11T20:05:00+00:00Added an answer on June 11, 2026 at 8:05 pm

    You should use the $_SESSION vars in php, To use them, add a session_start() at the beginning of your code. Then you can set vars with $_SESSION['selectaname'] = yourvar

    Nothing prevent you to make a sql query like "SELECT username FROM users WHERE id = 1" and then set a $_SESSION['user'] = $queryresult

    Then you’ll have this :

    echo $_SESSION['user'];
    
    "mylogin"
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to ask if it is possible to copy/move all the objects
Hi I would like to ask if its possible get array with clear data
I need to create a field in a database table, already populated with data.
I would like to ask if there is a possible way to select all
I currently have the following code that retrieves data from the database and then
Sorry, if this sounds ignorant. Is it possible to SECURELY upload data from a
Hy all..I want to ask you how is it possible when a checkbox is
I need to consolidate 20 databases that have the same structure into 1 database.
I'd like ask a question about building applications in .NET that use data from
My project has a need to cache on the iOS device data retrieved from

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.