Query builder

for debugging, I had to go CDbCommand and echo _text to find what sql i am calling. I think great idea

When can we expect it to be released? It looks very very good.

You can take it for a spin already if you grab the nightly build, or pull from the SVN repository. :)

As Qiang said: the more people test this and the more feedback you give, the better it’s going to get.

I love the idea! I come from a .NET background, and this reminds me of LINQ, which I loved :)

it is not necessary! To write SQL as ‘SELECT NAME,PASSWOR FROM TBL_USER FROM ID = ??’ is more clear than what you written.

why not refer to IBATIS ?

many frameworks do like you do, for example,CI

If you don’t like it, don’t use it.

It’s really that simple.

If writing raw SQL is your thing, then by all means…

To me, the new Query Builder is going to be a much appreciated tool.

Who doesn’t want to be able to do more with less work? :)

On the other side of that fence: if you like Doctrine and RoR inspired stuff, then why not use a heavier framework which makes use of it?

There’s always a trade-off between features and performance, and I find that Yii has stricken the perfect balance.

You are looking at that tool, actually.

Migration functionality is going to be part of query builder.

Having said what I said at the beginning of this thread, I would like to apologize for those who pointing me how good this new feature could be.

You were all right, I just had a look into the code and I am truly impress with it. This will easy the tasks for those who are planning to create installation features into their web software, creating tables ‘on-the-fly’ as required ( no more create this tables or that tables for my extension -yes, we could do it before but no one did it because it was easier to say it that create it on the fly :) ), jquery-like CDbCommand mechanism… woah

I know is not stable but I think I wont be able to wait

Its okay idea, personally I use CActiveRecord since you get all the nice features of model, validation, callbacks etc. I disagree with the person saying that using activerecord is for noobs…its should be the opposite. I can sql very well, but I also like OOP and code reuse and code enscapulation.

I also like CDbCriteria used in activerecord, and its basically a query builder.

So…i guess for the people who doesn’t use activerecord, this would make sense then.

Diff topic but, anyone benchmark how much faster it is by not using CActiveRecord? Wouldn’t using some opcode cache make cactiverecord just as fast as using the CommandBuilder or PDO?

I like it very much :)

It will be perfect to match my case :)

What about implementing a simple Active Record pattern on top of Query Builder? Any plans? Thoughts?

There is some question regarding like() method. From the guide I see that like() automatically append % in the beginning and the ending of the word


// WHERE `name` LIKE '%Qiang%'

where(array('like', 'name', 'Qiang'))

What must I do if for example I just want to query like this

WHERE name LIKE ‘Qiang%’

or

WHERE name LIKE %Qiang

Hmm … I think that automatic appending should be turned off.

This should be the choise of the User/Developer.

Even in Doctrine you have to do this manually.

It’s cool, I like it very much.

But,how can I use "REPLACE INTO…"?

Thank you for your suggestion. I have made the change.

Waiting for release …

imho the orm is quite stable, but I don´t think that an release should be

too fast. If you look at the tickts with the milestone 1.1.6, there are a lot of tickets

to make, before a release could get out.

More important may be the question, if the code generator (crud) can be made with the

orm, too? Are there any plans?

I would also have preferred the CDbCriteria syntax for creating queries. I’m not a fan of chaning. :)

Even though i don’t understand why (i’m a fan of jQuery’s “write less, do more” slogan), i think the current implementation does also allow you to write:




$cmd=$db->createCommand();

$cmd->select('name, password');

$cmd->from('tbl_user');

$cmd->where('id=:id', array(':id'=>$id));

$result=$cmd->queryRow();