Results 1 to 4 of 4

Thread: mysql_fetch_object mystery (php5)

  1. #1

    mysql_fetch_object mystery (php5)

    Hi, folks.

    I am rather new to PHP. I am creating an application where I am using AMFPHP, Flex and MySQL.

    On one of my php methods I am trying to return a value object or a mysql query.

    PHP Code:
    return mysql_fetch_object($result); 
    This returns a simple object with the properties of the object set to that data retrieved in the database (as expected). However I want to be able to do this:

    PHP Code:
    return mysql_fetch_object($result"UserVO"); 
    When doing so it returns the expected object type (a UserVO), however it returns the values of the UserVO to their initialized values which are various strings. It is not setting the values of the properties to that which are found in the database.

    Here is my UserVO php class:
    PHP Code:
    <?php
    class UserVO
    {
        var 
    $_explicitType "UserVO";
        
        var 
    $id 0;
        var 
    $userName 'userName';
        var 
    $password 'password';
    }
    ?>
    What am I missing here? Again I am a complete PHP noob.
    email: jwopitz (at) gmail (dot) com
    blogs: http://jwopitz.wordpress.com
    check out the as3isolib

  2. #2
    i think this function could help:

    function print_vars($obj)
    {
    foreach (get_object_vars($obj) as $prop => $val) {
    echo "\t$prop = $val\n";
    }
    }

    when calling this function with the resulting object you can echo out all member vars of your object.
    The problem that you have could be encountered by case sensitivity because the data binding is case sensitive. Members that are not already in your object are being added...

  3. #3
    Back again. So I figured out what the issue was. You can read the original posting here: http://www.phpfreaks.com/forums/inde...,177189.0.html

    To sum it up, it was my collation and case-insensitive columns assigning the values on properties that were named in camelCase.
    email: jwopitz (at) gmail (dot) com
    blogs: http://jwopitz.wordpress.com
    check out the as3isolib

  4. #4
    So I guess I need to know a bit more about MySQL.

    If I care about my tables' columns' names and their stored values being case-sensitive, what is the best collation to use? UTF8_bin? Also should I just assign the whole DB to use that collation by default or should it be a case by case (or rather a column by column) basis?
    email: jwopitz (at) gmail (dot) com
    blogs: http://jwopitz.wordpress.com
    check out the as3isolib

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

Home About kirupa.com Meet the Moderators Advertise

 Link to Us

 Credits

Copyright 1999 - 2012