Jump to content

cybertick

New Members
  • Posts

    5
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

cybertick's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. I am trying to insert the current Date/Time into mysql database using the following code. I do not understand how $submitDate & $submitTime are to be set. Will this work as coded? <?php class SubmitDateRecord { const DB_TABLE = 'timesheet'; const DB_FIELD_SUBMIT_TIME = 'submit_time'; private $submitDate; private $submitTime; public function setSubmitDate($submitDate) { $this->submitDate = $submitDate; } public function getSubmitDate() { return $this->submitDate; } public function setSubmitTime($submitTime) { $this->submitTime = $submitTime; } public function getSubmitTime() { return $this->submitTime; } public function addRecord() { $insertTable = "`".self::DB_TABLE."`"; $insertFields[] = "`".self::DB_FIELD_SUBMIT_TIME."`"; $insertValues[] = "'{$this->submitDate} {$this->submitTime}'"; $sqlBuilder = new SQLQBuilder(); $query = $sqlBuilder->simpleInsert($insertTable, $insertValues, $insertFields); $dbConnection = new DMLFunctions(); $result = $dbConnection->executeQuery($query); if ($result) { return true; } else { return false; } } private function _buildRecordObjects($result) { while ($row = mysql_fetch_array($result)) { $submitdateObj = new SubmitDateRecord(); $submitdateObj->setAttendanceId($row['attendance_id']); $submitdateObj->setEmployeeId($row['employee_id']); /* $row['submit_time'] comes in '0000-00-00 00:00:00' format. * We want date in '0000-00-00' format and time in '00:00' format. */ $tmpArr = explode(' ', $row['submit_time']); $submitdateObj->setSubmitDate($tmpArr[0]); $submitdateObj->setSubmitTime(substr($tmpArr[1], 0, 5)); // Omiting 'seconds' part is ok since it is always zero $submitdateObj->setStatus($row['status']); $submitdateArr[] = $submitdateObj; } return $submitdateArr; } }
  2. I think I have made some progress, but still have something I cannot quite figure out. From the code below what does this line mean? [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--] if ($row3 = $sql3 -> db_Fetch()){ [/quote] I usually will do an echo to the page to see what is in an array, but this is not an array from what toplay said above and I cannot figure out out how to see what this holds. I am sure it would help me in figuring out my problem to know what is in there. I plan to change the code to look for a new item that is being placed in this e107_user_extended table. [code]           $sql3=new db;           $sql3 -> db_Select("e107_user_extended", "*", "online_user_id='".$user_id.".".$user_name."'");             if ($row3 = $sql3 -> db_Fetch()){               $text .="<img src=\"".e_PLUGIN."bf2buds_menu/images/online.png\" alt=\"online\"> ";                                             } else {               $text .="<img src=\"".e_PLUGIN."bf2buds_menu/images/offline.png\" alt=\"offline\" > ";                    }             if ($urname <> "" ) {             $text.="<a href=\"".e_BASE."user.php?id.$user_id\">".($pref['realname']==1 && $user_login <> "" ? $user_login : $user_name)." [<a href=\"".e_SELF."?delbuddy=".$user_id."\" border=0>".BUDDYLAN_2."</a>]<br>";                                 } else {             $text.="<a href=\"".e_BASE."user.php?id.$user_id\">".($pref['realname']==1 && $user_login <> "" ? $user_login : $user_name)." [<a href=\"".e_SELF."?delbuddy=".$user_id."\" border=0>".BUDDYLAN_2."</a>]<br>";                  } [/code]
  3. Hey thanks toplay. I know I have lots to learn yet. I am using e107 and found that the define("USERID", $result['user_id']); line is located in the class2.php. Well I am about to loose my mind trying to figure this out...so I am back for some more help. I am trying to rewrite the following code to do something a little different than what it does as is. Right now it does as it should, gives me a list of site users and let's me know if they are on the site or not. [code]// Populate the buddy list     $text="";     $sql -> db_Select("bf2buds", "bf2buds_buddy", "bf2buds_user=". USERID);     while(list($bf2buds_id) = $sql-> db_Fetch()){       $sql2=new db;       $sql2 -> db_Select("user", "user_login,user_name,user_id", "user_id=".$bf2buds_id);       if ($row = $sql2 -> db_Fetch()) {             extract($row);         $sql3=new db;             $sql3 -> db_Select("online", "*", "online_user_id='".$user_id.".".$user_name."'");             if ($row3 = $sql3 -> db_Fetch()){               $text .="<img src=\"".e_PLUGIN."bf2buds_menu/images/online.png\" alt=\"online\"> ";                                                            } else {               $text .="<img src=\"".e_PLUGIN."bf2buds_menu/images/offline.png\" alt=\"offline\" > ";                    }             if ($urname <> "" ) {             $text.="<a href=\"".e_BASE."user.php?id.$user_id\">".($pref['realname']==1 && $user_login <> "" ? $user_login : $user_name)." [<a href=\"".e_SELF."?delbuddy=".$user_id."\" border=0>".BUDDYLAN_2."</a>]<br>";                                 } else {             $text.="<a href=\"".e_BASE."user.php?id.$user_id\">".($pref['realname']==1 && $user_login <> "" ? $user_login : $user_name)." [<a href=\"".e_SELF."?delbuddy=".$user_id."\" border=0>".BUDDYLAN_2."</a>]<br>";                  }                                      }                                                  }[/code] What I am trying to have it do is let me know if a person on my list is playing BF2. I have a DB(I'll call it BF2) outside of the DB(I'll call it e107) used by this code that as this information in it that I need. Here is the layout: [b]DB[/b] : [b]Table[/b] : [b]Columns[/b] BF2 : players : playername, playerpid e107 : user : user_id, user_name, login_name e107 : user_extended : user_extended_id, user_pid, userbf2name e107 : buddy : buddy_id, buddy_user, buddy_buddy I think I need at least 2 more $sql -> lines......but have no clue on how to get them working. I know that: e107.user.user_id = e107.user_extended.user_extended_id e107.user_extended.user_pid = BF2.playerpid e107.user_extended.user_extended_id will get me the user_pid If anyone could help I would be most grateful!
  4. I am trying to rework someone elses code to fit my needs. Problem is I do not fully understand the way they wrote the code. See the example: [code]<? $sql -> db_Select("buddy", "*", "buddy_user=". USERID." AND buddy_buddy=".$_POST['buddy']);?>[/code] The way I understand is like this... $sql : is an array -> : says this is how we are filling the array db_Select : select the buddy table int the current DB "*" : get all fields in the row (the table only has 3 columns buddy_id, buddy_user, buddy_buddy) "buddy_user=". USERID." AND buddy_buddy=".$_POST['buddy'] : This is the part that is throwing me Mainly the USERID, can someone explain this for me? Where does it come from? Is it just an undeclared local variable?
×
×
  • 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.