Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. Linux, Apache, MySQL, PHP
  4. Integer conversion for dummies

Integer conversion for dummies

Scheduled Pinned Locked Moved Linux, Apache, MySQL, PHP
questiondatabasemysql
2 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    Jack Vanderhorst
    wrote on last edited by
    #1

    I'm successfully calling a mysql stored procedure using PDO with the following line:

    $pdoCmd->fetch(PDO::FETCH_OBJ)

    It returns an object that I need to get converted into an integer, seems straightforward enough but when the object is say "1000" and I cast to an int I get a value of 1. How can I convert an object to an integer and keep my zeroes?

    J 1 Reply Last reply
    0
    • J Jack Vanderhorst

      I'm successfully calling a mysql stored procedure using PDO with the following line:

      $pdoCmd->fetch(PDO::FETCH_OBJ)

      It returns an object that I need to get converted into an integer, seems straightforward enough but when the object is say "1000" and I cast to an int I get a value of 1. How can I convert an object to an integer and keep my zeroes?

      J Offline
      J Offline
      Jack Vanderhorst
      wrote on last edited by
      #2

      Think I figured it out:

      $objResult = $pdoCmd->fetch(PDO::FETCH_OBJ);
      $intValue = (int)$objResult->MyColumnName;

      Cheers

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups