private function createPersons()
 {
     $person = new Person();
     $person->drop()->yesImSure();
     $person->createTable();
     $persons = array(array('f' => 'Jane', 'l' => 'Wayne', 'zip' => 1003), array('f' => 'John', 'l' => 'Anderson', 'zip' => 1004), array('f' => 'Mike', 'l' => 'Johnson', 'zip' => 1005), array('f' => 'Katy', 'l' => 'Peterson', 'zip' => 1006));
     foreach ($persons as $person) {
         $p = new Person();
         $p->setFirstname($person['f']);
         $p->setLastname($person['l']);
         $p->setZip($person['zip']);
         $p->commit();
     }
 }
Example #2
0
 public function register($postArr)
 {
     $status = false;
     $firstName = $postArr['firstname'];
     $lastName = $postArr['lastname'];
     if ($postArr['institution'] && !trim(strpos($postArr['institution'], ' ')) && preg_match('/[a-z]+[A-Z]+[a-z]+[A-Z]+/', $postArr['institution'])) {
         if ($postArr['title'] && !trim(strpos($postArr['title'], ' ')) && preg_match('/[a-z]+[A-Z]+[a-z]+[A-Z]+/', $postArr['title'])) {
             return false;
         }
     }
     $person = new Person();
     $person->setPassword($postArr['pwd']);
     $person->setUserName($this->userName);
     $person->setFirstName($firstName);
     $person->setLastName($lastName);
     $person->setTitle($postArr['title']);
     $person->setInstitution($postArr['institution']);
     $person->setCity($postArr['city']);
     $person->setState($postArr['state']);
     $person->setZip($postArr['zip']);
     $person->setCountry($postArr['country']);
     $person->setEmail($postArr['emailaddr']);
     $person->setUrl($postArr['url']);
     $person->setBiography($postArr['biography']);
     $person->setIsPublic(isset($postArr['ispublic']) ? 1 : 0);
     //Add to users table
     $fields = 'INSERT INTO users (';
     $values = 'VALUES (';
     $fields .= 'firstname ';
     $values .= '"' . $this->cleanInStr($person->getFirstName()) . '"';
     $fields .= ', lastname';
     $values .= ', "' . $this->cleanInStr($person->getLastName()) . '"';
     if ($person->getTitle()) {
         $fields .= ', title';
         $values .= ', "' . $this->cleanInStr($person->getTitle()) . '"';
     }
     if ($person->getInstitution()) {
         $fields .= ', institution';
         $values .= ', "' . $this->cleanInStr($person->getInstitution()) . '"';
     }
     if ($person->getDepartment()) {
         $fields .= ', department';
         $values .= ', "' . $this->cleanInStr($person->getDepartment()) . '"';
     }
     if ($person->getAddress()) {
         $fields .= ', address';
         $values .= ', "' . $this->cleanInStr($person->getAddress()) . '"';
     }
     if ($person->getCity()) {
         $fields .= ', city';
         $values .= ', "' . $this->cleanInStr($person->getCity()) . '"';
     }
     $fields .= ', state';
     $values .= ', "' . $this->cleanInStr($person->getState()) . '"';
     $fields .= ', country';
     $values .= ', "' . $this->cleanInStr($person->getCountry()) . '"';
     if ($person->getZip()) {
         $fields .= ', zip';
         $values .= ', "' . $this->cleanInStr($person->getZip()) . '"';
     }
     if ($person->getPhone()) {
         $fields .= ', phone';
         $values .= ', "' . $this->cleanInStr($person->getPhone()) . '"';
     }
     if ($person->getEmail()) {
         $fields .= ', email';
         $values .= ', "' . $this->cleanInStr($person->getEmail()) . '"';
     }
     if ($person->getUrl()) {
         $fields .= ', url';
         $values .= ', "' . $person->getUrl() . '"';
     }
     if ($person->getBiography()) {
         $fields .= ', biography';
         $values .= ', "' . $this->cleanInStr($person->getBiography()) . '"';
     }
     if ($person->getIsPublic()) {
         $fields .= ', ispublic';
         $values .= ', ' . $person->getIsPublic();
     }
     $sql = $fields . ') ' . $values . ')';
     //echo "SQL: ".$sql;
     $editCon = $this->getConnection('write');
     if ($editCon->query($sql)) {
         $person->setUid($editCon->insert_id);
         $this->uid = $person->getUid();
         //Add userlogin
         $sql = 'INSERT INTO userlogin (uid, username, password) ' . 'VALUES (' . $person->getUid() . ', "' . $this->cleanInStr($person->getUserName()) . '", PASSWORD("' . $this->cleanInStr($person->getPassword()) . '"))';
         if ($editCon->query($sql)) {
             $status = true;
             //authenicate
             $this->userName = $person->getUserName();
             $this->displayName = $person->getFirstName();
             $this->reset();
             $this->setCookies();
         } else {
             $this->errorStr = 'FAILED: Unable to create user.<div style="margin-left:55px;">Please contact system administrator for assistance.</div>';
         }
     }
     $editCon->close();
     return $status;
 }
 private function createPeople()
 {
     for ($i = 0; $i < 50; $i++) {
         $person = new Person();
         $person->setFirstname('John');
         $person->setLastname('Wayne');
         $person->setZip(4330);
         $person->setAddress('Somewhere');
         $person->commit();
     }
 }
Example #4
0
     $city = array_key_exists("city", $_REQUEST) ? $_REQUEST["city"] : "";
     $state = array_key_exists("state", $_REQUEST) ? $_REQUEST["state"] : "";
     $zip = array_key_exists("zip", $_REQUEST) ? $_REQUEST["zip"] : "";
     $country = array_key_exists("country", $_REQUEST) ? $_REQUEST["country"] : "";
     $url = array_key_exists("url", $_REQUEST) ? $_REQUEST["url"] : "";
     $biography = array_key_exists("biography", $_REQUEST) ? $_REQUEST["biography"] : "";
     $isPublic = array_key_exists("ispublic", $_REQUEST) ? $_REQUEST["ispublic"] : "";
     $newPerson = new Person();
     $newPerson->setUid($userId);
     $newPerson->setFirstName($firstname);
     $newPerson->setLastName($lastname);
     $newPerson->setTitle($title);
     $newPerson->setInstitution($institution);
     $newPerson->setCity($city);
     $newPerson->setState($state);
     $newPerson->setZip($zip);
     $newPerson->setCountry($country);
     $newPerson->setEmail($email);
     $newPerson->setUrl($url);
     $newPerson->setBiography($biography);
     $newPerson->setIsPublic($isPublic);
     if (!$pHandler->updateProfile($newPerson)) {
         $statusStr = "Profile update failed!";
     }
     $person = $pHandler->getPerson();
     if ($person->getIsTaxonomyEditor()) {
         $tabIndex = 3;
     } else {
         $tabIndex = 2;
     }
 } elseif ($action == "Change Password") {
 $url->address = $row['address'];
 $parsed = new SimpleXMLElement($url, null, true);
 if ($parsed->street_number && $parsed->street_name) {
     // Look up their address in Master Address
     $url = new URL(ADDRESS_SERVICE . '/home.php');
     $url->queryType = 'address';
     $url->format = 'xml';
     $url->query = $row['address'];
     echo $url->query . " ==> ";
     $xml = new SimpleXMLElement($url, null, true);
     if (count($xml) == 1) {
         // Set the address
         $person->setAddress($xml->address->streetAddress);
         $person->setCity($xml->address->city);
         $person->setState($xml->address->state);
         $person->setZip($xml->address->zip);
         // $person->setStreet_address_id($xml->address->id);
         // See if there's a subunit
         if ($parsed->subunitIdentifier) {
             $subunit = $xml->xpath("//subunit[identifier='{$parsed->subunitIdentifier}']");
             if ($subunit) {
                 // $person->setSubunit_id($subunit[0]['id']);
                 $person->setAddress("{$person->getAddress()} {$subunit[0]->type} {$subunit[0]->identifier}");
             }
         }
         echo "{$person->getAddress()} ==>";
     }
 }
 if (!$person->getAddress()) {
     $person->setAddress(ucwords(strtolower($row['address'])));
     $person->setCity(ucwords(strtolower($row['city'])));
 /**
  * @test
  */
 public function shouldCreateRecordsInAcceptableTime_MYSQLI()
 {
     LudoDB::setConnectionType('MYSQLI');
     $this->startTimer();
     for ($i = 0; $i < 500; $i++) {
         $person = new Person();
         $person->setFirstname('John');
         $person->setLastname('Wayne');
         $person->setAddress('Somewhere');
         $person->setZip(4330);
         $person->commit();
     }
     $time = $this->getElapsed(__FUNCTION__);
     // then
     $this->assertLessThan(1.5, $time);
 }
 private function getPersonWithPhone($firstname = '', $phoneNumbers = array())
 {
     $person = new Person();
     $person->setFirstname($firstname);
     $this->createCity();
     $person->setZip(4330);
     $person->commit();
     $id = $person->getId();
     foreach ($phoneNumbers as $number) {
         $this->addPhone($id, $number);
     }
     return new Person($id);
 }
 /**
  * @test
  */
 public function shouldGetValueFromJoinsOnNewObjects()
 {
     $person = new Person();
     $person->setZip('7001');
     $city = new City();
     $city->setZip('7001');
     $city->setCity('Somewhere');
     $city->commit();
     // then
     $this->assertEquals('Somewhere', $person->getCity());
 }