开发者

PHP SQL Table Creation and Maintenance [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 11 years ago.

What are some good recommendations for managing SQL tables? I want to move away from writing and editing sql tables manually, and therefore was wondering what was peoples standpoint.

I been playing with the idea of creating an up and down function in my conroller class using Kohana's ORM. For example.

Class books_Controller{
   static function up(){
     //create sql database tables;
   }
   static function down(){
     // delete cuurent db table
   }
}

Then I call to up to create the tables and down to remove.

books_Controller::up();
books_Controller::down();

Thats great except when setting up a new server it can become a hastle creating and updating an 'init.php' file. Also sites new specific things on a per site basis.

Proposal

I've thought about creating a simple online php terminal. For example, I could visit domain.com/terminal, enter username and password and be able to eval input. From there I could bring up and down only specific sql tables along with other maintenance. Pros? Cons?

I don't ha开发者_开发技巧te sql, but I find it troublesome to manage/update up to date sql files. Also abstractions are near impossible in sql.


SQL abstractions already exist, but they are oriented toward allowing the same language to interact with multiple flavors of SQL, rather than eliminating it entirely. You might check out PearDB (http://pear.php.net/DB) if that would suit your purposes.

To wit, though, the kind of thing you are talking about isn't really possible - SQL is not very complicated, and if you implemented a series of functions flexible enough to encapsulate SQL's functionality you would only succeed at creating... an abstraction layer for SQL that is just as complicated and with no vendor support. This is very much like setting your car on fire to prevent it being stolen.

With regards to your terminal idea, PHPPGAdmin and PHPMyAdmin do this already for PostgreSQL and MySQL, respectively. In terms of security, both utilities allow (and by default, PHPPGAdmin requires) that the user come from a specific IP range. A purely username-password authentication would open your database up to brute force attacks directly, which is a Bad Thing.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜