Jump to content

PDO newbie question?


altergothen

Recommended Posts

IS there an easier way to get a single result from a PDO query than having to run a foreach when I already know that there should only be a single record or value being returned?

I tried using $myresult = $dbh->exec($sql); ...but only returns a 1

 

 

$dbh = new PDO("$Driver1:host=$Server1;dbname=$db1", $User1, $Password1);

try {

 

$sql = "SELECT FileVersion FROM FileVersion WHERE GroupID = $GroupID ORDER BY FileVersion Desc";

foreach ($dbh->query($sql) as $myrow)

{

$FileVersion = $myrow['FileVersion'];

}

 

$dbh = null;

}

catch(PDOException $e)

{

echo $e->getMessage();

}

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

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...