Welcome Guest, Not a member yet? Register   Sign In
IgnitedRecord 1.0 pre-release

[eluser]jinfusion[/eluser]
m4rw3r,

Sorry the work is going slow.

I will be one of the first to upgrade to it if it comes out this year. That functionality, to me, is where an ORM really shines. At least into my world. Smile

Thanks for making your ORM available. I love it. and use it. good luck with the manual. I'd be happy to help if you can think of a way... proofreading?

Joel

[eluser]RobSymonds[/eluser]
After you insert a record with IR, I would expect the id column to reflect the insert id. It doesn't though.

If you look at ./system/application/libraries/ignitedrecord/ignitedrecord.php on line 981, after insert, __id is updated but not id. So if you try to retrieve the id property of the object after you save/insert you will get an error. A quick test hack shows that adding the following on line 982 appears to fix the problem:

$object->id = $query->insert_id();

However I don't know the library very well and I don't have any linked objects yet. So I can't judge the impact of the change. I can always reference __id in my code but it makes me feel dirty and I'd prefer to reference id instead. Any thoughts?

Very nice library. I'm new to CI and finding it makes my PHP coding fun again.

Thanks,

---

EDIT: Nevermind. I downloaded from SVN and the problem is fixed. Duh Smile

Rob

[eluser]gh0st[/eluser]
In this tutorial;
http://www.vimeo.com/2125634

What editor is being used? And is available for Windows? It seems to do a lot of auto completion.

Thanks

[eluser]pistolPete[/eluser]
[quote author="gh0st" date="1234971108"]What editor is being used? And is available for Windows?[/quote]
It's called TextMate and it is Mac OS X only.

[eluser]Paul Apostol[/eluser]
Almost the same features as TextMate are found in E-TextEditor (Windows)

[eluser]m4rw3r[/eluser]
I actually use E-texteditor in that video, it isn't until tomorrow I can use TextMate (my mac will hopefully arrive then Big Grin).
The reason it looks like TextMate is that I use a theme called Flyakite OSX which makes my windows box look like OS X. It makes the pain of using windows easier to bear Smile.

The development on IgnitedRecord has been on a standstill for a while - mainly because of my job and school - but I've been experimenting with a stand-alone DB lib which would be a replacement for CI's db.
This db abstraction will work in a similar fashion as CI's db abstraction, and it seems quite promising, but it is hard to make it beat PDO in performance.
It is impossible when creating stdClass objects, PDO is even faster than mysql_*() functions!
But when creating custom objects (read record objects) I can beat it (strangely, both mysql_*() and PDO is *very* slow at that).

So I hope to be able to release a stand-alone version of IgnitedRecord this year (it will be for both CI and "normal" PHP), and I'll also start to use PHP 5 exclusively (if I deem the benefits are justifiable).

[eluser]m4rw3r[/eluser]
I’m currently debating whether to rewrite IgnitedRecord from scratch (for PHP 5) or not.

CI’s database abstraction isn’t really sufficient to make it perform well (I loose about 10-20% performance on CI’s abstraction, because of DB_result::result() - even with a very streamlined version).
On the other hand is it hard to do a nice remake which still retains backwards compatibility, yet enables IgnitedRecord to interact with it on a very basic level (almost like IR is calling the database functions).

So if anybody has some wishes for what a good ORM should include (syntax, structure, features, focus, etc.) tell me, because that may convince me to make something awesome!

[eluser]voland[/eluser]
Hi. Now i start to look to form generation for CRUD task automations, so i start to find bugs or misconceptions with my mind).

In IR_form (70 line)
if(isset($data['desc']) && $display_tips):

default value for $display_tips is true and $data['desc'] == "" so ? char displayed.
I suggest change code to if(!empty($data['desc']) && $display_tips):

[eluser]RobSymonds[/eluser]
So far I'm loving IR. I do have a design problem I'm having trouble with. I'm struggling to figure out a good way to represent some functionality that was previously implemented in plain SQL in the last version of my site.

My site has a bunch of quotes by famous people. These are stored in a table called quotes:

Code:
CREATE TABLE IF NOT EXISTS `quotes` (
  `id` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `body` text,
  `created_at` timestamp NOT NULL DEFAULT '0000-00-00 00:00:00',
  `updated_at` timestamp  NOT NULL DEFAULT '0000-00-00 00:00:00',
  PRIMARY KEY (`id`)
)

I keep track of which quotes are used for the daily quote in a table called daily_quotes:

Code:
CREATE TABLE IF NOT EXISTS `daily_quotes` (
  `id` int(10) NOT NULL AUTO_INCREMENT,
  `quote_id` int(10) DEFAULT NULL,
  `used_on` timestamp  NOT NULL DEFAULT '0000-00-00 00:00:00',
  PRIMARY KEY (`id`),
  KEY `idx_quote_id` (`quote_id`)
)

Here is the logic I use to get/create daily quotes:

SQL to try and retrieve today's quote:
Code:
SELECT
quotes.*
FROM
quotes
,daily_quotes
WHERE quotes.id = daily_quotes.quote_id
AND Date(daily_quotes.used_on) = Date(Now())

If that doesn't return anything, I generate a new daily quote:
Code:
SELECT
quotes.*
FROM
quotes
WHERE quotes.id NOT IN (
SELECT
  daily_quotes.quote_id
FROM
  daily_quotes
WHERE Date(daily_quotes.used_on) > Date(Now()) - INTERVAL 1 YEAR
)
ORDER BY
RAND()
LIMIT
1

Then take the quote.id from that and use it here:
Code:
INSERT INTO daily_quotes (
  quote_id
  ,used_on
) VALUES (
?
,Now()
)

I'm struggling to replicate this in IR. I could create a daily_quote model/record and do most of the work in the controller but that doesn't seem right. I thought I had it figured out earlier but I was trying to call the daily_quote model from the quote model and it wasn't working. That didn't seem clean either.

Has anybody done this type of thing before? Basically I'm implementing a history table and I don't really know how to model. Any input is very appreciated.

[eluser]m4rw3r[/eluser]
The model instance in IR is actually an instance (grandchild of) IgnitedQuery. So you can use normal CI ActiveRecord methods on the model object (or any other query constructing object).

Example:
Code:
$num = $this->quote->join('daily_quotes', 'quotes.id = daily_quotes.quote_id')->where('DATE(daily_quotes.used_on) = DATE(NOW())', false)->count();
Or better yet, have a relation:
Code:
$this->quote->has_one('daily_quote');
$this->daily_quote->belongs_to('quote');

$num = $this->quote->join_related('daily_quote')->where('DATE(daily_quotes.used_on) = DATE(NOW())', false)->count();

$subquery = new IgnitedQuery();
$subquery->select('quote_id')->from('daily_quotes')->where('Date(daily_quotes.used_on) > Date(Now()) - INTERVAL 1 YEAR', false);
$new = $this->quote->where_not_in('id', $subquery)->order_by('random')->find();

You can put much (all, I think) of this code in your model (which extends IgnitedRecord, use $this instead of $this->quote).




Theme © iAndrew 2016 - Forum software by © MyBB