public function import() { $engine = $this->getEngine(); $job = $engine->getJob(); $job->addNotice("FruityResourceImporter beginning to import Resources."); // Resources $res = $this->dbConn->query("SELECT * FROM nagios_resources"); // Fruity has just one record in the resources, if we get it, import // it. $row = $res->fetch(PDO::FETCH_ASSOC); // Get our resources obj. $resourceCfg = NagiosResourcePeer::doSelectOne(new Criteria()); if (!$resourceCfg) { $resourceCfg = new NagiosResource(); $resourceCfg->save(); } foreach ($row as $key => $val) { unset($name); if ($key == "id") { continue; } // Iterate through and, if we have a valid key, we set it to // the NagiosResource obj. try { $name = NagiosResourcePeer::translateFieldName($key, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_PHPNAME); } catch (Exception $e) { $job->addNotice("Fruity Resource Importer: Was unable to store unsupported value: " . $key); } if (!empty($name)) { $method = "set" . $name; $resourceCfg->{$method}($val); } } $resourceCfg->save(); // Save resources configuration $job->addNotice("FruityResourceImporter finished importing Resources."); }
but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ /* Lilac Resource */ include_once 'includes/config.inc'; require_once 'NagiosResource.php'; $resourceCfg = NagiosResourcePeer::doSelectOne(new Criteria()); if (!$resourceCfg) { $resourceCfg = new NagiosResource(); $resourceCfg->save(); } if (isset($_POST['request'])) { if ($_POST['request'] == 'update') { $resourceCfg->setUser1($_POST['resource_config']['user1']); $resourceCfg->setUser2($_POST['resource_config']['user2']); $resourceCfg->setUser3($_POST['resource_config']['user3']); $resourceCfg->setUser4($_POST['resource_config']['user4']); $resourceCfg->setUser5($_POST['resource_config']['user5']); $resourceCfg->setUser6($_POST['resource_config']['user6']); $resourceCfg->setUser7($_POST['resource_config']['user7']); $resourceCfg->setUser8($_POST['resource_config']['user8']); $resourceCfg->setUser9($_POST['resource_config']['user9']); $resourceCfg->setUser10($_POST['resource_config']['user10']); $resourceCfg->setUser11($_POST['resource_config']['user11']);
/** * Adds an object to the instance pool. * * Propel keeps cached copies of objects in an instance pool when they are retrieved * from the database. In some cases -- especially when you override doSelect*() * methods in your stub classes -- you may need to explicitly add objects * to the cache in order to ensure that the same objects are always returned by doSelect*() * and retrieveByPK*() calls. * * @param NagiosResource $value A NagiosResource object. * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). */ public static function addInstanceToPool(NagiosResource $obj, $key = null) { if (Propel::isInstancePoolingEnabled()) { if ($key === null) { $key = (string) $obj->getId(); } // if key === null self::$instances[$key] = $obj; } }