<?php
namespace Models;
class Host extends ActiveRecord\Model {}
?>
And here is the output:
Array
(
[ip] => 192.168.1.2
[mac] => 00224d6a1b4d
[last_request] => 2013-04-28 06:10:42
[last_response] => 2013-04-28 06:10:42
[status] =>up
)
Fatal error: Class 'Models\Host' not found in ...DbHosts.php on line 45
My AR is Version 1.0 - June 27, 2010, PHP 5.4.13.
I'd appreciate any suggestions. Thanks.
Megan McVeyThu Jul 18 18:18:31 -0400 2013
Super late to the party.
I believe namespaced classes are expected to be in a directory for the namespace.
Subject: Models Class not found with Namespace
I have a Host class that clashes with the AR Model Host class, so I thought to use a Namespace to fix it.
This is a code snippet:
$h = (array)new Host('192.168.1.2','00224d6a1b4d','2013-04-28 06:10:42','2013-04-28 06:10:42','up'); print_r($h); ActiveRecord\Config::initialize(function($cfg){ $cfg->set_model_directory('dbmodels'); $cfg->set_connections(array( 'development' => 'mysql://root:root@localhost/netmon' )); }); $host = Models\Host::create($h);and dbmodels/host.php
<?php namespace Models; class Host extends ActiveRecord\Model {} ?>And here is the output:
Array ( [ip] => 192.168.1.2 [mac] => 00224d6a1b4d [last_request] => 2013-04-28 06:10:42 [last_response] => 2013-04-28 06:10:42 [status] =>up ) Fatal error: Class 'Models\Host' not found in ...DbHosts.php on line 45My AR is Version 1.0 - June 27, 2010, PHP 5.4.13.
I'd appreciate any suggestions. Thanks.