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

  • SEARCH
  • Home
  • 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 8346861
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T07:09:34+00:00 2026-06-09T07:09:34+00:00

This is the original code I am trying to write in object oriented form..

  • 0

This is the original code I am trying to write in object oriented form..

$posResult = mysql_query("SELECT MAX(position)+1 FROM todo");

        if(mysql_num_rows($posResult))
            list($position) = mysql_fetch_array($posResult);

This is where I am at…. I think I need to bind_result? also, I have an issue with the mysql_fetch_array…

if($stmt = $this->HH->Database->prepare("SELECT MAX(position)+1 FROM todo")) {
        $stmt->execute();
        $stmt->store_result();

        if($stmt->num_rows != FALSE) {
            list($position) = mysql_fetch_array($posResult);
        }
    }

Can someone advise on how to correct this?

  • 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-09T07:09:36+00:00Added an answer on June 9, 2026 at 7:09 am

    It looks like you are moving over to PDO, which is great, it is a much better way to connect, but you are still trying to use some of the older mysql_* commands which won’t work. While there are a number of ways to get the data, but this is the approach that I most commonly use:

    if($stmt = $this->HH->Database->prepare("SELECT MAX(position)+1 FROM todo")) {
        $stmt->execute();
    
        $stmt->setFetchMode(PDO::FETCH_INTO, new yourClassName);
        foreach($stmt as $yourClassObject)
        {
            $someVar=$yourClassObject->QueryColumnName;
            // or
            $this->someProperty=$yourClassObject->QueryColumnName;
        }
        }
    

    I do generally have a class that matches the results of the query, so I use FETCH_INTO but you can use a different method such as return an indexed array, associated array or others.

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

Sidebar

Related Questions

I'm trying to write this as LINQ, Original code: For Each CurrentForm As Form
from this code will show in original color how can i change it to
Original SQL query is this; SELECT id,post_title,post_date FROM wp_posts where id='1' When I retrieve
I am trying to write a simple parallel_for using pthreads. Original code is something
String product = Integer.toString(w); char[] original = String.toCharArray(product); This is the code I have
I have this original formula from a medical research book: Log(e) (EFW) = (-4.564+(0.282*AC)-(0.00331*AC^2))*1000
I got the JSON from apple like this { original-purchase-date-pst = 2012-06-28 02:46:02 America/Los_Angeles;
So I'm trying to write an Objective-C macro that takes an object and a
First of all I did not write this code. I found it on somebody
I am trying to write a Monte Carlo code where I optimize the elements

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.