On Nov 11, 2011, at 4:57 AM, atelier wrote:
Hi Walter
Just for my understanding, I see in your index and in the save_sort_order.php file this code
require_once('lib/MyActiveRecord.php');
Question: is this another PHP file, and if yes, what is the content, and where does it live on the server?
Yes. This is the Object/Relational wrapper that I use. You can see a screencast about it on Freewaycast, and you can also read the source code here: https://github.com/walterdavis/activerecord
What does lib mean, is it the serverpath?
That’s just the name of the folder that contains the file, no special importance or significance to that filename.
Where does the file save_sort_order.php live, is it on root level? Or in the directory of the Freeway templates?
It lives wherever you put it and call to it. In my example, it is on the same file level as index.php. If you move it somewhere else, just remember to update the Ajax call to reflect its relative location from the page that’s calling it (index.php, again).
Also I see in the top part of the index template person and people, like here:
if($person = MyActiveRecord::FindFirst('people',
and
$person = MyActiveRecord::Create('people');
For my understanding, do I have to replace people with Member like in my MSQL setup?
These are MyActiveRecord calls, so if you are translating, you would want to find the nearest equivalent to these, conceptually:
FindFirst finds the first ‘people’ record that matches the second argument when that’s used as the WHERE clause in a SQL query. This method call: MyActiveRecord::FindFirst('people', 'name = "' . $name . '"')
would translate into this: SELECT * FROM people WHERE name = "$name";
.
The result is returned as either null (no results found) or a single instance of the People class. In addition, MyActiveRecord also retrieves the schema from that table, and knows what each of the columns are named and what sort of data they like to receive. It then creates “getter” and “setter” functions, so all I have to do to change the resulting People object and call save(), and the database is back in step with my in-memory copy of that object.
Create first loads the schema, so it knows what all of the columns are called and what type of data they default to. Then it creates a new instance of the People class in memory, and if any of the setters are called, sets the value of that attribute to the value passed. When save() is called, the object is persisted in the database as a new row.
My problem is that I have to transform your script so it works for me. One small error in writing, and this does not work, and I have no idea where to look for debugging.
I am sorry about this, maybe it takes too long after all…
That depends on how abstracted your code is. If EE offers you a nice object-oriented view of the database, this could be very easy. The latest EE is based on CodeIgniter, which is a very high-quality attempt to clone Ruby on Rails into PHP. While PHP (the language) does not include all the magic that Ruby does, and therefore any clone of Rails that doesn’t run in Ruby will be inherently less capable than the original, CodeIgniter is a very complete toolkit and provides a very similar data model to MyActiveRecord. MAR is a deliberately limited port of only the ActiveRecord library from Rails, and it does not even try to go as far as CodeIgniter does toward feature parity with Rails.
Walter
freewaytalk mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options