EllisLab text mark
Advanced Search
3 of 63
3
   
DataMapper ORM v1.8.2
Posted: 07 December 2011 01:06 PM   [ Ignore ]   [ # 41 ]   [ Rating: 0 ]
Joined: 2011-12-06
10 posts

I really can’t see what’s wrong xD
But thanks for your help anyways wink

I hope you have time for 2 more questions ^^
First, do you know any good alternatives to your DataMapper, I can try wink

and second, and not related to anything CI xD But do you by any chance know any good tutorials or any help on working with GitHub or other good alternatives for online backup and version managing wink

 
Posted: 07 December 2011 01:11 PM   [ Ignore ]   [ # 42 ]   [ Rating: 0 ]
Avatar
Joined: 2008-10-15
147 posts
Martin Dilling - 07 December 2011 01:06 PM

Do you by any chance know any good tutorials or any help on working with GitHub or other good alternatives for online backup and version managing wink

Some nice Git help and articles:
http://progit.org/book/
http://www.vogella.de/articles/Git/article.html
http://sandofsky.com/blog/git-workflow.html
http://nfarina.com/post/9868516270/git-is-simpler

 
Posted: 07 December 2011 01:17 PM   [ Ignore ]   [ # 43 ]   [ Rating: 0 ]
Avatar
Joined: 2008-11-04
4404 posts
Martin Dilling - 07 December 2011 01:06 PM

First, do you know any good alternatives to your DataMapper, I can try wink

No. smile

But if your only selection criteria is an old and outdated piece of example code that hasn’t been supported for two years, which is based on an extension that isn’t supported anymore since v1.7.1, then maybe you should try a little harder. wink

There are plenty of good git tutorials online. Github also has a 101 online to get you started.

 Signature 

Me: WanWizard.eu | My company: Exite | Datamapper: DataMapper ORM

 
Posted: 07 December 2011 02:06 PM   [ Ignore ]   [ # 44 ]   [ Rating: 0 ]
Joined: 2011-12-06
10 posts

Thanks for all the response on GitHub wink

I didn’t know the example was outdated xD must have missed that somewhere xD
I just have easier to learn by looking on full examples, than reading a manual raspberry but if the plugin and the manual is updated? I’ll look at it once more raspberry

 
Posted: 07 December 2011 06:44 PM   [ Ignore ]   [ # 45 ]   [ Rating: 0 ]
Avatar
Joined: 2008-11-04
4404 posts

The manual is fully up to date.

I should find the time to bring the example up to date, it is still build using a lot of PHP4 techniques, common in the CI 1.6-1.7 days. All I did was a quick scan for obvious issues, like PHP short tags.

 Signature 

Me: WanWizard.eu | My company: Exite | Datamapper: DataMapper ORM

 
Posted: 09 December 2011 03:13 PM   [ Ignore ]   [ # 46 ]   [ Rating: 0 ]
Joined: 2010-12-21
25 posts

Quick question (hopefully) is there any way to get Datamapper to utilize the _escape_table() function (from sqlsrv_driver.php)  I guess since it’s not an overloaded function of DB_driver then I’ll have to implement it directly in datamapper.php

Unless there is a way to add it to the model somehow?  But I fear there’s lots of code in datamapper.php that generates SQL and will need to implement same method.

(I have to enclose my [table.Names] b/c there’s a frigging period in the name.  =/

 
Posted: 09 December 2011 06:57 PM   [ Ignore ]   [ # 47 ]   [ Rating: 0 ]
Avatar
Joined: 2008-11-04
4404 posts

You can call any internal method using $this->db->dm_call_method(‘methodname’).
If the method needs arguments, just add them after the methodname.

As to the escaping: the _escape_table() method in the sqlsrv driver is a dummy (in CI 2.1.0), it doesn’t do anything? Maybe it is there that it should be fixed?

 Signature 

Me: WanWizard.eu | My company: Exite | Datamapper: DataMapper ORM

 
Posted: 09 December 2011 07:11 PM   [ Ignore ]   [ # 48 ]   [ Rating: 0 ]
Joined: 2010-12-21
25 posts

#FACT!  But I had added:

$return "[".$table."]"

Which works fine for straight up queries, but in particular the JOIN queries generated by DM do not escape the tables.

I looked in the code, but doesn’t look like there’s a single place to add _escape_table($table) call.  (?)

I mean, I managed to convince others to rename the tables, but, probably it should do this anyway?  =)  (maybe not seeing as no one is complaining =)

Thanks for getting back to me!

 
Posted: 10 December 2011 05:02 AM   [ Ignore ]   [ # 49 ]   [ Rating: 0 ]
Avatar
Joined: 2008-11-04
4404 posts
diZzyCoDeR - 09 December 2011 07:11 PM

Which works fine for straight up queries, but in particular the JOIN queries generated by DM do not escape the tables.

DataMapper calls $this->db->join to create the joins.

Looking into the CI driver code, I see that it uses escape_table() on a few utility calls, and on insert, update and delete queries. But not on any other ones. This particular issue is on DB_active_rec.php#L340 (CI 2.1.0) where the JOIN is constructed. So CI has to abstract the join method so the drivers can deal with the platform specifics. You should create an issue for this in the bug tracker.

diZzyCoDeR - 09 December 2011 07:11 PM

I mean, I managed to convince others to rename the tables, but, probably it should do this anyway?  =)  (maybe not seeing as no one is complaining =)

You’re probably one of the unlucky few that has to work with Microsoft crap… wink

 Signature 

Me: WanWizard.eu | My company: Exite | Datamapper: DataMapper ORM

 
Posted: 13 December 2011 12:21 PM   [ Ignore ]   [ # 50 ]   [ Rating: 0 ]
Joined: 2010-12-21
25 posts

Excellent!  Cheers.

You’re probably one of the unlucky few that has to work with Microsoft crap…

Ha! Ain’t that the truth.  And I’m made to look like the ass who wants to use stupid MySQL. lol.

#ProTip for those that want to use this lovely, lovely ORM for their project but are constrained by the DB design of others.  “Views” are your friends.  Easy to create, you map aliases of your column names and even denormalize where appropriate.  Saved my bacon when I started to ditch DM b/c my DB schema didn’t conform to standard normalization practices.  Persistence FTW!

 
Posted: 14 December 2011 05:56 PM   [ Ignore ]   [ # 51 ]   [ Rating: 0 ]
Joined: 2011-07-15
16 posts

So I fixed the issue that I had with the DSN, I set what I believe is the correct hostname:

$db['default']['hostname''mysql:host=localhost';
$db['default']['username'$username;
$db['default']['password'$password;
$db['default']['database''my_database_name'

, but now I’m getting this error

PHP Fatal error:  Call to a member function field_data() on a non-object in /system/database/DB_driver.php on line 889
 PHP Stack trace
:
 
PHP   1. {main}() /index.php:0
 PHP   2. 
require_once() /index.php:212
 PHP   3. call_user_func_array
() /system/core/CodeIgniter.php:359
 PHP   4. Site
->dashboard() /system/core/CodeIgniter.php:359
 PHP   5. BlogPost
->__construct() /application/controllers/site.php:50
 PHP   6. DataMapper
->__construct() /application/models/blogpost.php:45
 PHP   7. DataMapper
->DataMapper() /application/libraries/Datamapper.php:451
 PHP   8. CI_DB_driver
->field_data() /application/libraries/Datamapper.php:645 

Site.php line 50 has the following code

$Blog_Post = new BlogPost(); 

and blogpost.php (model file) is just the constructor calling the parent

public function __construct($id null{
      parent
::__construct($id);
    

This happens as soon as I try to create any model!

any ideas?

Remember I’m using the PDO driver.

Thank you

 
Posted: 15 December 2011 05:37 AM   [ Ignore ]   [ # 52 ]   [ Rating: 0 ]
Avatar
Joined: 2008-11-04
4404 posts

In your trace I see CI_DB_driver being mentioned. This means that either you’re not using 1.8.2, or you haven’t installed the DataMapper bootloader in your index.php.

edit: I may also mean you’re using a very early 1.8.2, which had an issue with recreating $this->db under certain circumstances, which can also trigger this message.

If so update your DataMapper installation from Bitbucket, download ‘tip’ from https://bitbucket.org/wanwizard/datamapper/downloads to make sure you have the latest code.

 Signature 

Me: WanWizard.eu | My company: Exite | Datamapper: DataMapper ORM

 
Posted: 15 December 2011 11:19 AM   [ Ignore ]   [ # 53 ]   [ Rating: 0 ]
Joined: 2011-07-15
16 posts

When you say bootloader, you are talking about the bootstrap?

require_once APPPATH.'third_party/datamapper/bootstrap.php'

or is it something additional I need?

I downloaded the latest from your bit bucket repo and replace every file manually. According to my DIFF, nothing had changed except for the extension htmlform.php, and the result of my test is the same (I still get the same error message). I upgraded from CI 2.0.2 usign ORM 1.8.1 to CI 2.1 using ORM 1.8.2. It works perfect with the mysql driver!

 
Posted: 15 December 2011 11:51 AM   [ Ignore ]   [ # 54 ]   [ Rating: 0 ]
Avatar
Joined: 2008-11-04
4404 posts

That is indeed the addition I was referring too.

But looking in the PDO driver, I found the issue. Whoever worked on the PDO driver is appearantly a TransactSQL user, because to determine the field data, the PDO driver executes “SELECT TOP 1 FROM tablename”. Which causes an error when you connect to MySQL (which doesn’t speak TSQL), which causes the query result to be FALSE, instead of a result object. Which gives you this error.

A bit more snooping shows that one “timw4mail” is the culprit, so it looks like someone at Ellislab or the Reactor team failed to screen the code properly.

In short, The CI PDO driver is not SQL dialect neutral. Open a ticket on http://github.com/ellislab/codeigniter/issues to have this fixed.

 Signature 

Me: WanWizard.eu | My company: Exite | Datamapper: DataMapper ORM

 
Posted: 15 December 2011 12:08 PM   [ Ignore ]   [ # 55 ]   [ Rating: 0 ]
Joined: 2011-07-15
16 posts

Thanks!

I created this ticket https://github.com/EllisLab/CodeIgniter/issues/788

 
3 of 63
3