influxdb-php icon indicating copy to clipboard operation
influxdb-php copied to clipboard

Fatal error: Class 'Point' not found

Open hSnow26 opened this issue 7 years ago • 2 comments

hi i had a problem using "point" example code.

// create an array of points
$points = array(
	new Point(
		'test_metric', // name of the measurement
		0.64, // the measurement value
		['host' => 'server01', 'region' => 'us-west'], // optional tags
		['cpucount' => 10], // optional additional fields
		1435255849 // Time precision has to be set to seconds!
	),
    new Point(
    	'test_metric', // name of the measurement
		0.84, // the measurement value
		['host' => 'server01', 'region' => 'us-west'], // optional tags
		['cpucount' => 10], // optional additional fields
		1435255849 // Time precision has to be set to seconds!
	)
);

// we are writing unix timestamps, which have a second precision
$result = $database->writePoints($points, Database::PRECISION_SECONDS);

using this code in php, i got a "Fatal error: Class 'Point' not found". so I wasted a few hours, and found a solution.

"new Point" -> "new InfluxDB\Point"

Plz modify the example code. thanku.

hSnow26 avatar Aug 08 '18 17:08 hSnow26

What exactly did you do with ""new Point" -> "new InfluxDB\Point" to fix the issue?

Sorry for the noob question

Corruptsector avatar Apr 04 '19 10:04 Corruptsector

What exactly did you do with ""new Point" -> "new InfluxDB\Point" to fix the issue?

Sorry for the noob question

Don't know if you're still looking for an answer but it may help others in the future also. But this....

new Point(
    	'test_metric', // name of the measurement
		0.84, // the measurement value
		['host' => 'server01', 'region' => 'us-west'], // optional tags
		['cpucount' => 10], // optional additional fields
		1435255849 // Time precision has to be set to seconds!
	)

Becomes this...

new InfluxDB\Point(
    	'test_metric', // name of the measurement
		0.84, // the measurement value
		['host' => 'server01', 'region' => 'us-west'], // optional tags
		['cpucount' => 10], // optional additional fields
		1435255849 // Time precision has to be set to seconds!
	)

Any time you get that class error, stick InfluxDB\ before the class with the error, and it should fix it!

ghost avatar Jan 23 '20 14:01 ghost