예제 #1
0
 static function factoryAll()
 {
     $db = Database::instantiate(Database::TYPE_READ);
     $query = AccountFactory::SELECTLIST . "\n\t\t\t\t\t\t\tFROM  pesapi_account ";
     $tempArray = array();
     if ($result = $db->query($query)) {
         while ($foo = $db->fetchObject($result)) {
             $tempArray[] = AccountFactory::createEntry($foo->type, $foo->id, $foo);
         }
         $db->freeResult($result);
     }
     return $tempArray;
 }
예제 #2
0
 public static function createNew($type, $identifier)
 {
     $type = (int) $type;
     if ($type > 0 and $identifier != "") {
         $db = Database::instantiate(Database::TYPE_WRITE);
         $newSettings = array("PUSH_IN_URL" => "", "PUSH_IN_SECRET" => "", "PUSH_OUT_URL" => "", "PUSH_OUT_SECRET" => "", "PUSH_NEUTRAL_URL" => "", "PUSH_NEUTRAL_SECRET" => "", "SYNC_SECRET" => Utility::generatePassword(8));
         $settings = serialize($newSettings);
         $query = "INSERT INTO   pesapi_account(\n                              type,\n                              name,\n                              identifier,\n                              push_in,\n                              push_out,\n                              push_neutral,\n                              settings)\n                VALUES(\n                              '{$type}',\n                              '',\n                              '" . $db->dbIn($identifier) . "',\n                              0,\n                              0,\n                              0,\n                              '" . $db->dbIn($settings) . "')";
         if ($db->query($query)) {
             return AccountFactory::createEntry($type, $db->insertId());
         }
     }
     return null;
 }