Jump to content

xjermx

Members
  • Posts

    35
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

xjermx's Achievements

Member

Member (2/5)

0

Reputation

  1. I've recently picked up CodeIgniter 2 + Doctrine 2, which is incredibly powerful. I'm learning as I go. I have what someone told me is called a 'join table'. Two tables that only have useful information when linked together. Its a messaging system in my webapp. You send a message to three other users, it writes to two tables. One table contains who its from, the message text, a timestamp and a primary key. The second table contains a primary key, a "to" field, and a msg_id that is meant to join back to the primary key in the other table. If I was just using native sql statements, here's what this would look like: SELECT * FROM mail_links a INNER JOIN mail_msgs b ON a.msg_id = b.id But I'm trying to figure out what the "right" way is to do this in Doctrine2. Is it Associative Mapping? Is it something else?
  2. Here is what I ended up with: private function _registration_validate() { $this->form_validation->set_rules('email', 'E-mail', 'required|valid_email|min_length[8]|trim|callback_email_check'); return $this->form_validation->run(); } public function email_check($str) { $user = $this->doctrine->em->getRepository('ORM\Dynasties2\Users')->findOneBy(array('email' => $str)); if (isset($user)) { $this->form_validation->set_message('email_check', 'This email address is already in use'); return FALSE; } else { return TRUE; } }
  3. I am running Doctrine 2.2.1 and CodeIgniter 2.1.0 I am attempting to do a simple unique validation to make sure that a field does not already exist in the database. I have tried this: $this->form_validation->set_rules('email', 'E-mail', 'required|valid_email|is_unique[users.email]'); which gives me the following output: I have also tried this (cribbed directly from codeigniter's user manual, along with an email_check function): $this->form_validation->set_rules('email', 'E-mail', 'callback_email_check'); Which gives this output: Can anyone tell me the best/correct way to do unique validation in this setup? Can anyone help me make either of the above methods work? Thanks!
  4. As part of my learn-as-I-go game project, I've created a rudimentary map: http://www.dixieandtheninjas.net/dynasties/images/dynasties_map_2.jpg I want to do a couple of things with it, and I'm unsure of whether javascript/jquery can do this or not. 1. I want to be able to shade cells based on some criteria - for instance, make all enemy provinces red, or all allied provinces blue. 2. I want to be able to put an icon on a specific region to indicate the presence of the player. In both cases, I can generate this kind of information from SQL via PHP, but I don't know where to begin with regards to having a map that I can manipulate in this manner. Any pointers? Thanks!
  5. I'm posting in this thread again, as I'm still stuck at a dead end on this problem. I'm not sure if there is simply an error in my code that makes the long-polling not work, or if I'm just trying the wrong solution here. Any suggestions or help is most welcome!
  6. As a "learn while I build it" project, I'm attempting to construct a fairly simple tic-tac-toe game using mysql, php, jquery and ajax. It lives here: http://www.dixieandtheninjas.net/test/tictactoe (don't be surprised that you can't even play tic tac toe yet, I'm learning) My question is related specifically to doing long polling with ajax. I've "borrowed" from this thread: http://stackoverflow.com/questions/333664/simple-long-polling-example-code But I have to get it to work correctly. It seems to just timeout without successfully completing. I'm also curious how I can get it to .hide() a user's span when they logout (via window.unload). [edit: or do I need to hide them? will the ajax, when working correctly, only load people who are logged in, hence when someone logs out, they will simply no longer get displayed.. or will their span have to be specifically removed?] You can check out my jquery at http://www.dixieandtheninjas.net/test/tictactoe/tictactoe.js some of my PHP: if (isset ($_POST['myname'])) { $name = strtolower(mysql_real_escape_string(filter_input(INPUT_POST, "myname"))); //echo $name; $_SESSION['name'] = $name; //see if its in the db already $result = mysql_query("select * from tictac_names where name='$name'", $db); $rowCheck = mysql_num_rows($result); echo $name; if ($rowCheck > '0') { // name is already in the db //log them in mysql_query("UPDATE tictac_names SET logged_on = '1' WHERE name ='$name'") or die(mysql_error()); } else if ($rowCheck < '1') { // register them $sql = <<< END INSERT INTO tictac_names (name, logged_on, in_game) VALUES ('$name', 1, 0) END; $result2 = mysql_query($sql) or die(mysql_error()); // then log them in } } if (isset ($_POST['logout'])) { if (filter_input(INPUT_POST,'logout') == '1') { $name = $_SESSION['name']; mysql_query("UPDATE tictac_names SET logged_on = '0' WHERE name ='$name'") or die(mysql_error()); echo "blarg"; } } if (isset ($_POST['longpoll'])) { if (filter_input(INPUT_POST,'longpoll') == '1') { $result = mysql_query("select name from tictac_names where logged_on='1'", $db); $rowCheck = mysql_num_rows($result); if ($rowCheck > '0') { while ($row = mysql_fetch_assoc($result)){ foreach ($row as $val){ $spanid = 'sp_' . $val; echo "<br><span id=\"$spanid\">$val</span></br>"; } } } // end rowcheck } } Can anyone help me fix my polling? Can anyone give me some pointers on how I make it smart enough to both add names when they login, and remove names when they logout?
×
×
  • 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.