Yii Framework Forum: Yii skeleton app - Yii Framework Forum

Jump to content

  • (9 Pages)
  • +
  • 1
  • 2
  • 3
  • 4
  • 5
  • Last »
  • You cannot start a new topic
  • This topic is locked

Yii skeleton app Rate Topic: -----

#41 User is offline   jonah 

  • Advanced Member
  • Yii
  • Group: Yii Dev Team
  • Posts: 733
  • Joined: 27-November 08
  • Location:California (US)

Posted 16 February 2009 - 02:48 PM

*Fixed table name bug

see r12
0

#42 User is offline   mocapapa 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 428
  • Joined: 04-January 09
  • Location:Tokyo, JAPAN

Posted 17 February 2009 - 11:07 PM

Thanks Jonah,

I have tried to use the latest version of your skeleton app. With one exception that I modified the entry script as below, everything including password recovery works fine :D


- $yii = '../yiiRepo/framework/yii.php';
+ $yii = '../../framework/yii.php';

0

#43 User is offline   Maxximus 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 146
  • Joined: 24-November 08
  • Location:Spain

Posted 18 February 2009 - 05:42 AM

@Jonah: Cool, will have a look at my (Linux) box now. For you it doesn't really hurt (mixing LC tablenames in MySQL and UCfirst in source on WAMP), but it will work on *nix too.

Defining tablenames in the model can be a bit confusing, especially when using AR and SQL in your source (or use Modelname::Model()->tableName to address a table in SQL).

So for me: Nice if you have to use legacy tables, but further it's not really workable. Unfortunately there is no other way to address tablenames as a variable as far as I know. There were some requests for it, especially if you want to prefix tablenames.

About the different branches: Well it looks like two different codebases in Googlecode, it feels like two different issuelists,  it taste.. so for me it's two different branches...


0

#44 User is offline   jonah 

  • Advanced Member
  • Yii
  • Group: Yii Dev Team
  • Posts: 733
  • Joined: 27-November 08
  • Location:California (US)

Posted 18 February 2009 - 01:08 PM

There is only one SVN now, the first one it being deleted.  The main one is linked to on the topic post.

What I did is I simply extended CActiveRecord::tableName() to return the lowercase version of what it returned before.  So now it expects tables to be lower-case.  If you want a different table name, overwrite tableName() in your model and have it return what you want the table name to be.

So now all the SQLs generated in the skeleton app should have lowercase table names.  This way there is no problem for anyone, correct?  This seemed like the only solution so it would work on both linux and windoews and os x.
0

#45 User is offline   jonah 

  • Advanced Member
  • Yii
  • Group: Yii Dev Team
  • Posts: 733
  • Joined: 27-November 08
  • Location:California (US)

Posted 19 February 2009 - 12:35 AM

Big update:  Added ParseCachebehavior

To get an understanding of how to use it look at the wiki page:
http://code.google.c...wiki/parsecache

And read the course comments in the behavior file

In the skeleton app it is used on the user 'about' column to cache the CMarkdown

Don't forget to install the table for it

NOTE: Requires the very latest svn build of yii (r707)!
0

#46 User is offline   Maxximus 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 146
  • Joined: 24-November 08
  • Location:Spain

Posted 19 February 2009 - 03:41 PM

I'm getting a CException: User does not have a method named "parseCacheRelation".

Using Yii r712 (trunk) and (stock) skeleton r23. Any ideas?


*edit*: Using Yii r712 1.0 -> all works fine!

About the tables: encoding is set to latin1. Any specific reason not to use utf8?
0

#47 User is offline   jonah 

  • Advanced Member
  • Yii
  • Group: Yii Dev Team
  • Posts: 733
  • Joined: 27-November 08
  • Location:California (US)

Posted 19 February 2009 - 05:21 PM

No, that's just what phpmyadmin did for me.. do you think it should be utf-8 instead?

if so, is it case sensitive (eg UTF8, utf-8)

Right now i'm adding a post feature to the skeleton app.

You should easily be able to extend it to work in anyway you want, as this is just the skeleton of it.  For instance you could modify it to be:

*a news system (where only admins can post)
*a multi-user or single user blogging system

By default it will behave like a a multi-user blog system.

It will take use of the ParseCachebehavior to deal with the markdown (i was very happy on how easy it was to install and use)

I also set up bare-bones for extending yiic and having your own template files

&does anyone think I should remove Loggablebehavior from the skeleton?  It's not used and i don't see many common uses for it
0

#48 User is offline   jonah 

  • Advanced Member
  • Yii
  • Group: Yii Dev Team
  • Posts: 733
  • Joined: 27-November 08
  • Location:California (US)

Posted 19 February 2009 - 08:15 PM

Added posts.

http://code.google.c...rce/detail?r=24
0

#49 User is offline   mocapapa 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 428
  • Joined: 04-January 09
  • Location:Tokyo, JAPAN

Posted 20 February 2009 - 12:05 AM

1. I got a following error,
~~~
PHP Error
Description
Trying to get property of non-object
Source File
/var/www/html/yii/demos/skeleton-app/protected/views/post/list.php(17)
~~~
when I clicked the button of posts (http://localhost/dem...n-app/post/list).

2. I got an following error,
~~~
Please fix the following input errors:
    * Username is incorrect.
~~~
when I tried to 'Login' (http://localhost/dem...-app/user/login) after I registerd my account using 'Register'.

I am using app-skeleton r29, on Yii r715.

0

#50 User is offline   jonah 

  • Advanced Member
  • Yii
  • Group: Yii Dev Team
  • Posts: 733
  • Joined: 27-November 08
  • Location:California (US)

Posted 20 February 2009 - 01:59 AM

Ah, my bad.  The test data supplied had corrupted foreign keys.  That was the first error.. should be fixed now... the second error should also be fixed now.

Thanks,
Jonah

EDIT: BTW also the foreign key ON DELETE option for the post table was incorrect an should be changed to CASCADE
0

#51 User is offline   Maxximus 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 146
  • Joined: 24-November 08
  • Location:Spain

Posted 20 February 2009 - 09:24 AM

You can adjust the table encoding format easily with PHPMyAdmin, so your export dump will have the right encoding enclosed (utf8).

To actually be able to use the encoding, add: 'charset'=>'utf8', to the db array in the config file main.php

About LoggableBehaviour, didn't use it yet, but perhaps its nice to enable this for certain groups, like admin. For logging common users its a bit much perhaps.
0

#52 User is offline   jonah 

  • Advanced Member
  • Yii
  • Group: Yii Dev Team
  • Posts: 733
  • Joined: 27-November 08
  • Location:California (US)

Posted 20 February 2009 - 12:57 PM

When I go to PHPMyAdmin there are like 20 different versions of utf8 i can switch to, how do I know which one to use?

And actually using the log for admin is a good idea.  Didn't think of that...
0

#53 User is offline   Maxximus 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 146
  • Joined: 24-November 08
  • Location:Spain

Posted 21 February 2009 - 04:32 AM

Ok true about the utf-8 in phpMyAdmin. I use utf8_general_ci, think that's one of the most common ones.

A mysql tabledump will add CHARSET=utf8 to it.

Another thought about logging: Maybe make it so we can 'attach' it to a user or group to monitor that user or group?
0

#54 User is offline   wei 

  • Advanced Member
  • Yii
  • Group: Yii Dev Team
  • Posts: 147
  • Joined: 04-October 08

Posted 21 February 2009 - 08:25 AM

use utf8_unicode_ci if possible see, http://forums.mysql....8748#msg-188748
0

#55 User is offline   Mike 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 3,016
  • Joined: 06-October 08
  • Location:Upper Palatinate

Posted 21 February 2009 - 08:28 AM

Just a sidenote: Be careful not to mix up charset with collation in MySQL. What you can change with phpMyAdmin easily is collation. It only affects sorting of results when using ORDER BY. To change the CHARSET of a table, you need to export and re-import it. At least i don't know of any other way.

Edit: I think, Unicode was worth a cookbook article ;)
0

#56 User is offline   gib 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 17
  • Joined: 08-February 09

Posted 22 February 2009 - 08:59 AM

Hi all,
Great idea this skeleton app... thanks for you efforts.

Why don't you make available download files for the latest nightly snapshot or something? In extensions or in Google code. This would make downloads easy if no svn access is available.

Cheers
0

#57 User is offline   jonah 

  • Advanced Member
  • Yii
  • Group: Yii Dev Team
  • Posts: 733
  • Joined: 27-November 08
  • Location:California (US)

Posted 24 February 2009 - 05:40 PM

Thanks mike for the cookbook article, I will switch it to utf in the next version.

@gib Your right, the next version will have a downloadable version

I've been thinking about the ParseCachebehavior that is included.

Right now it stores the parsed data in a separate table, unlike in the blog tutorial where it is stored in the same table but under a different column.  Storing the cache in a separate table seemed like a good idea because you could then add the behavior to a model without adding columns to that table to hold the caches.

But now I'm looking at downsides
* Slower as it requires extra mysql queries
* You can only store the parsed data in a column of type `text`
* you have to worry about eager-loading the cache in your queries
* you can't access the cache directly but have to use a behavior method

I'm thinking about changing the behavior to store the parsed data in the same table, and under the column with the same name as the source column but with the configurable suffix 'Parsed' (like the blog but with a different suffix)

So the parsed content of `content` would be stored in `contentParsed` in the same table

It would be able to be any type of data - even numerical.

This could be used to even cache an average (star) rating and store it in an int column.

Also you wouldn't have to worry about eager-loading the cache which was a hassle for me.

Any thoughts before I do this?
0

#58 User is offline   Maxximus 

  • Standard Member
  • PipPip
  • Yii
  • Group: Members
  • Posts: 146
  • Joined: 24-November 08
  • Location:Spain

Posted 24 February 2009 - 06:34 PM

To be honest, I wasn't convinced that the separate parsecache table is the best solution, for the reasons you already mentioned.
I personally think the idea to store the display/cached data in a separate column at the time of insert/update is the way to go. But only for certain, very specific 'parsed' data.

Don't really see the need for other data in a cached column, one of the main reasons is that for other data (like ints, vars, averages etc) Yii does have very nice cache options built in.

- If you want speed and flexibility, put the output in memcache.
- Yet another option can be to use fragment cache in the view.

But if you want more speed, you could make the (separate) parsecache table a MySQL 'memory' table. Needs to be rebuild after a restart, but can be pretty fast. Make the column a blob if you want to store other stuff in it as well.

Storing and regularly updating average star ratings in a furthermore quite static table doesn't feel so good to me. better to use one of the other Yii options for that probably.

0

#59 User is offline   jonah 

  • Advanced Member
  • Yii
  • Group: Yii Dev Team
  • Posts: 733
  • Joined: 27-November 08
  • Location:California (US)

Posted 24 February 2009 - 07:03 PM

You define which columns to parse and cache in the behavior settings.  You also define the method to parse it in the behavior settings.

Your right, it wouldn't do much for a rating system, but this is what you could do:
Say you store ratings for `articles`
You might have a `totalRating` column, `numberRatings` column, and `averageRating` column.

Say if someone votes a 6:
`totalRating` += 6
`numberRatings` += 1

And the ParseCacheBahavior could then be set up to to calculate `averageRating` in beforeSave(), which would be:
`averageRating` = `totalRating` / `numberRatings`

This however is much more useful for parsing such as Markdown, which is what it does by default.  And now if you want markdown in a varchar column, that would be easy
0

#60 User is offline   carlj 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 23-February 09

Posted 25 February 2009 - 03:27 AM

Great job with the skeleton. Its a great way to start working with the framework.
However i´m having an issue with the /post/list page. It wont load the "body" of the page and the css. Im not getting any error messages. Everything else works fine!

This is what it looks like: http://skitch.com/ca...mozilla-firefox

Anybody else having the same problem?
0

Share this topic:


  • (9 Pages)
  • +
  • 1
  • 2
  • 3
  • 4
  • 5
  • Last »
  • You cannot start a new topic
  • This topic is locked

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users