PHP Classes

anyone successfully using this

Recommend this page to a friend!

      ORM mapping class(like Hibernate), maps database table rows to objects  >  All threads  >  anyone successfully using this  >  (Un) Subscribe thread alerts  
Subject:anyone successfully using this
Summary:Followed the example and am getting nowhere in simple usage
Messages:4
Author:Nick Wilkinson
Date:2008-03-12 03:09:04
Update:2008-03-12 07:52:53
 

  1. anyone successfully using this   Reply   Report abuse  
Picture of Nick Wilkinson Nick Wilkinson - 2008-03-12 03:09:05
Copied the ExampleObject.php and made some changes, now is:

<?php
class Property extends BaseObject {
public function GetTableName() {
return 'properties';
}
public function IdField() {
return 'iden_id';
}
public static function &ById($id) {
self::GetById($id);
}
}
?>

Then trying to use it with:

<?php
require_once 'Mysql.php';
require_once 'BaseObject.php';
require_once '_Property.php';
Mysql::Init('localhost', 'user', 'pass', 'database');
$this_property = Property::ById(484);
echo $this_property->data_name;
echo $this_property->phot_photos;
?>

And nothing comes out with the two echo statements. I've tried messing up the "return 'iden_id';" from the parent object to a non-existent field in my table, and that returns an error, but with the correct field name mapped to id, I get no data from $this_property->some_field.

Any suggestions, or another example that is working?

Thanks!



  2. Re: anyone successfully using this   Reply   Report abuse  
Picture of Indrek Altpere Indrek Altpere - 2008-03-12 07:52:53 - In reply to message 1 from Nick Wilkinson
What is your table structure ? Perhaps you could send it to me if it's just some testing table. Are you sure connection properties are correct ?

To put mysql into query debug mode, after Mysql::Init(); put Mysql::SetDebug(true);
and in the end of script do
echo Mysql::ToString();

That should give out some infotmation about mysql commands processed.

I myself am using it in literally tens of projects, some created by me, in others it is just a coding speedup. Instead of building large queries, I just set object properties and call save function and everytime only actually changed data is sent to database.

  3. Re: anyone successfully using this   Reply   Report abuse  
Picture of Indrek Altpere Indrek Altpere - 2008-03-12 07:52:55 - In reply to message 1 from Nick Wilkinson
What is your table structure ? Perhaps you could send it to me if it's just some testing table. Are you sure connection properties are correct ?

To put mysql into query debug mode, after Mysql::Init(); put Mysql::SetDebug(true);
and in the end of script do
echo Mysql::ToString();

That should give out some infotmation about mysql commands processed.

I myself am using it in literally tens of projects, some created by me, in others it is just a coding speedup. Instead of building large queries, I just set object properties and call save function and everytime only actually changed data is sent to database.

  4. Re: anyone successfully using this   Reply   Report abuse  
Picture of Indrek Altpere Indrek Altpere - 2016-06-18 15:20:46 - In reply to message 1 from Nick Wilkinson
The ById function contents should look like this:
return self::GetById($id, __CLASS__);