Jump to content

Slagar

New Members
  • Posts

    3
  • Joined

  • Last visited

    Never

Posts posted by Slagar

  1. I was just wondering if there is a simple way to find the Primary Key field(s) of a MySQL table.

     

    I've looked it up, and can only seem to find mysql_field_type, which doesn't seem to do what I want, so I thought someone here might know a way :)

    If not I'll likely just do a workaround -- have the last three characters of id fields consistently as "_id" in tables with composite keys or something.

     

    Cheers  ;)

  2. I'm writing class files, and often use the same typical format for each class (think standard database/web form classes). As I'm constantly trying to refine the way I do things, I'm wondering if this would be good practice.

    Basically, I'm thinking of using custom error reporting in my class files. Have a simple constant at the top of the class file, and then within the class at critical places, have some custom errors.

    Here's a silly example of some Person class:

     

    define("DEBUG_MODE", "on");
    
    class Person {
    ...
    function SetName($name) {
       if (strlen($name) > 0) {
          $this->name = $name;
          return true;
       } else {
          if (DEBUG_MODE == "on") {
             echo("<strong>Custom Error:</strong> ".$name." is not a valid name.");
          }
          return false;
    }
    

     

    Ok, it's a trivial example (sorry for any errors in the above; I just made it up). My point is, would something like this be worthwhile, or would it needlessly bloat my class files? I don't usually find debugging to be a problem, and realistically most of the stuff I write isn't super complex... what do you think? :)

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.