Comments (10)
Hey Ales, I haven't added anything into the framework to deal with internationalization, but Phreeze should support whatever languages you like as long as it uses a consistent charset in the database (default is UTF8). I'm definitely open to any contributions in that area.
As for the primary and foreign key, it is fine to use varchar. It is a little easier if each table has an auto-increment primary key, but it's not necessary.
The only real issue with the primay key being non-auto-increment is that you have to explicitly tell Phreeze when saving that it must be an insert operation, for example:
$person->Save(true); // <- passing in true argument forces Phreeze to do an insert instead of an update
If you run into any issues though, please feel free to post and I can try to address them.
from phreeze.
Well, I was hoping for some directions as how to start translating the generator modules. Looks like like I'll have to go through each and every file on the builder side to make my own localized version. And patch a new one every time you release it. But, it would be a real pain to translate the many generated files each time I make a new build.
RE: varchar foreign keys. I asked you that because I couldn't get the generator to work correctly on them, INTs are OK, VARCHAR(3) as primaries and foreigns are not. Maybe it's just me, I'll try again.
Thanks,
Ales
from phreeze.
Well, you shouldn't have to worry about framework updates, but like you said - re-generating code would create new views. For the most part I don't normally re-generate my views once I start building my app, but still I would like to see that feature. Since the builder templates use Smarty, I think that there are some solutions for internationalization that could work. And there really is not a huge amount of text in the templates except a few error messages and buttons. Everything else is just the table names and data.
As far as the varchar key thing - this schema seems to work just fine. If you have troubles you could post your schema and I can see if there's a problem with Phreeze or some certain structure.
CREATE TABLE `status_code` (
`sc_id` varchar(3) NOT NULL,
`sc_name` varchar(45) DEFAULT NULL,
PRIMARY KEY (`sc_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
INSERT INTO `status_code` VALUES ('C','Closed'),('O','Open');
CREATE TABLE `purchase` (
`p_id` int(11) NOT NULL AUTO_INCREMENT,
`p_status_code_id` varchar(3) DEFAULT NULL,
`p_description` varchar(45) DEFAULT NULL,
PRIMARY KEY (`p_id`),
KEY `p_status_idx` (`p_status_code_id`),
CONSTRAINT `p_status_code` FOREIGN KEY (`p_status_code_id`) REFERENCES `status_code` (`sc_id`) ON DELETE NO ACTION ON UPDATE NO ACTION
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8;
INSERT INTO `purchase` VALUES (1,'C','Purchase Order A'),(2,'C','Purchase Order B');
from phreeze.
Hmm ... here is the screencast. Server is Ubuntu 12.04.1 LTS with LAMPP 1.8.1, shared web folder is mapped do Z: drive on Windows machine. I copied your schema into test database of MySQL server and ran the builder. Same thing happens, form select shows ID instead of Name. It works with integer IDs, though. Weird.
from phreeze.
ah, i see what you mean. well, basically the builder isn't very smart at determining which field to display in the drop-down. what it does, is it simply looks for the first varchar column that it can find in the table.
this is one thing that you do have to customize the generated code to show the correct column in the case where Phreeze guessed incorrectly. In this example that is done inside ~/scripts/app/purchases.js about half-way inside the function renderModelView. You can see the commented line below i changed "id" to "name"
var statusCodeIdValues = new model.StatusCodeCollection();
statusCodeIdValues.fetch({
success: function(c){
var dd = $('#statusCodeId');
dd.append('<option value=""></option>');
c.forEach(function(item,index)
{
dd.append(app.getOptionHtml(
item.get('id'),
item.get('name'), // <!-- ### CHANGE THIS TO ANOTHER COLUMN ###
page.purchase.get('statusCodeId') == item.get('id')
));
});
},
error: function(collection,response,scope){
app.appendAlert(app.getErrorMessage(response), 'alert-error',0,'modelAlert');
}
});
from phreeze.
Oh, I see. I thought it literally looks for "Name" column and displays that in a select box. At least that is how it seemed after looking at your screencasts and my first few tables which really were set up with integer IDs.
All is well now, I'll adjust my code. Thanks for your time.
Ales
from phreeze.
cool, if you come up with any ideas for il8n let me know
from phreeze.
Sure, I'll just start translating the builder and see where it takes me.
Case closed.
from phreeze.
If you ever want to go international, then I will help getting the Dutch part translated.
from phreeze.
Re: varchar keys. Usually first field is a key and one of the following fields is a descriptor. Would it hurt if you would start looking for description after first field?
/** * Returns name of the first varchar field which could be used as a "label" * * @access public * @return string */ function GetDescriptorName($remove_prefix = true) { $i=0; foreach ($this->Columns as $column) { $i++; if ( ($column->Type == "varchar") and ($i>1) ) { return ($remove_prefix) ? $this->RemovePrefix($column->Name) : $column->Name; } } // give up because there are no varchars in this table return $this->GetPrimaryKeyName($remove_prefix); }
from phreeze.
Related Issues (20)
- Greetings HOT 1
- Error after building
- Its work wordpress 4.8+?
- Phreeze Builder Broken HOT 1
- master-detail / master-detail-detail examples
- builder/analyze gives 404 on Nginx
- Generated code in scripts/model.js displays all tables regardless
- index null HOT 1
- Controler filename / classname containing space character(s)
- Stuck loading tables with varbinary?
- Error Opening MySQL Database HOT 1
- analyze Not Found HOT 1
- after instalation HOT 2
- Undefined offset: 1 in DBTable.php at line 285 HOT 1
- Jason Hinkle 1970-2016 HOT 5
- Security issue : use hash_equals() instead of '===' to compare hashes
- Show on select many-to-one
- http://192.168.32.10/phreeze/builder/analyze HOT 1
- Foreign key issue
- Problem after builder page HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from phreeze.