VPN licensing server
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

5 anos atrás
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. MeekroDB -- The Simple PHP MySQL Library
  2. ========
  3. Learn more: http://www.meekro.com
  4. MeekroDB is:
  5. * A PHP MySQL library that lets you **get more done with fewer lines of code**, and **makes SQL injection 100% impossible**.
  6. * Google's #1 search result for "php mysql library" since 2013, with **thousands of deployments worldwide**.
  7. * A library with a **perfect security track record**. No bugs relating to security or SQL injection have ever been discovered.
  8. Installation
  9. ========
  10. When you're ready to get started, see the [Quick Start Guide](http://www.meekro.com/quickstart.php) on our website.
  11. ### Manual Setup
  12. Include the `db.class.php` file into your project and set it up like this:
  13. require_once 'db.class.php';
  14. DB::$user = 'my_database_user';
  15. DB::$password = 'my_database_password';
  16. DB::$dbName = 'my_database_name';
  17. ### Composer
  18. Add this to your `composer.json`
  19. {
  20. "require": {
  21. "sergeytsalkov/meekrodb": "*"
  22. }
  23. }
  24. Code Examples
  25. ========
  26. ### Grab some rows from the database and print out a field from each row.
  27. $accounts = DB::query("SELECT * FROM accounts WHERE type = %s AND age > %i", $type, 15);
  28. foreach ($accounts as $account) {
  29. echo $account['username'] . "\n";
  30. }
  31. ### Insert a new row.
  32. DB::insert('mytable', array(
  33. 'name' => $name,
  34. 'rank' => $rank,
  35. 'location' => $location,
  36. 'age' => $age,
  37. 'intelligence' => $intelligence
  38. ));
  39. ### Grab one row or field
  40. $account = DB::queryFirstRow("SELECT * FROM accounts WHERE username=%s", 'Joe');
  41. $number_accounts = DB::queryFirstField("SELECT COUNT(*) FROM accounts");
  42. ### Use a list in a query
  43. DB::query("SELECT * FROM tbl WHERE name IN %ls AND age NOT IN %li", array('John', 'Bob'), array(12, 15));
  44. ### Nested Transactions
  45. DB::$nested_transactions = true;
  46. DB::startTransaction(); // outer transaction
  47. // .. some queries..
  48. $depth = DB::startTransaction(); // inner transaction
  49. echo $depth . 'transactions are currently active'; // 2
  50. // .. some queries..
  51. DB::commit(); // commit inner transaction
  52. // .. some queries..
  53. DB::commit(); // commit outer transaction
  54. ### Lots More - See: http://www.meekro.com/docs.php
  55. How is MeekroDB better than PDO?
  56. ========
  57. ### Optional Static Class Mode
  58. Most web apps will only ever talk to one database. This means that
  59. passing $db objects to every function of your code just adds unnecessary clutter.
  60. The simplest approach is to use static methods such as DB::query(), and that's how
  61. MeekroDB works. Still, if you need database objects, MeekroDB can do that too.
  62. ### Do more with fewer lines of code
  63. The code below escapes your parameters for safety, runs the query, and grabs
  64. the first row of results. Try doing that in one line with PDO.
  65. $account = DB::queryFirstRow("SELECT * FROM accounts WHERE username=%s", 'Joe');
  66. ### Work with list parameters easily
  67. Using MySQL's IN keyword should not be hard. MeekroDB smooths out the syntax for you,
  68. PDO does not.
  69. $accounts = DB::query("SELECT * FROM accounts WHERE username IN %ls", array('Joe', 'Frank'));
  70. ### Simple inserts
  71. Using MySQL's INSERT should not be more complicated than passing in an
  72. associative array. MeekroDB also simplifies many related commands, including
  73. the useful and bizarre INSERT .. ON DUPLICATE UPDATE command. PDO does none of this.
  74. DB::insert('accounts', array('username' => 'John', 'password' => 'whatever'));
  75. ### Focus on the goal, not the task
  76. Want to do INSERT yourself rather than relying on DB::insert()?
  77. It's dead simple. I don't even want to think about how many lines
  78. you'd need to pull this off in PDO.
  79. // Insert 2 rows at once
  80. DB::query("INSERT INTO %b %lb VALUES %ll?", 'accounts',
  81. array('username', 'password', 'last_login_timestamp'),
  82. array(
  83. array('Joe', 'joes_password', new DateTime('yesterday')),
  84. array('Frank', 'franks_password', new DateTime('last Monday'))
  85. )
  86. );
  87. ### Nested transactions
  88. MySQL's SAVEPOINT commands lets you create nested transactions, but only
  89. if you keep track of SAVEPOINT ids yourself. MeekroDB does this for you,
  90. so you can have nested transactions with no complexity or learning curve.
  91. DB::$nested_transactions = true;
  92. DB::startTransaction(); // outer transaction
  93. // .. some queries..
  94. $depth = DB::startTransaction(); // inner transaction
  95. echo $depth . 'transactions are currently active'; // 2
  96. // .. some queries..
  97. DB::commit(); // commit inner transaction
  98. // .. some queries..
  99. DB::commit(); // commit outer transaction
  100. ### Flexible error and success handlers
  101. Set your own custom function run on errors, or on every query that succeeds.
  102. You can easily have separate error handling behavior for the dev and live
  103. versions of your application. Want to count up all your queries and their
  104. runtime? Just add a new success handler.
  105. ### More about MeekroDB's design philosophy: http://www.meekro.com/beliefs.php
  106. My Other Projects
  107. ========
  108. A little shameless self-promotion!
  109. * [Ark Server Hosting](https://arkservers.io) -- Ark: Survival Evolved server hosting by ArkServers.io!
  110. * [7 Days To Die Server Hosting](https://arkservers.io/7days) -- 7 Days to Die server hosting by ArkServers.io!
  111. * [Best Minecraft Server Hosting](https://bestminecraft.org) -- Ranking and recommendations for minecraft server hosting!
  112. * [ChunkHost](https://chunkhost.com) -- VPS Hosting starting at $5/month! We accept bitcoin!
  113. * [brooce](https://github.com/SergeyTsalkov/brooce) - Language-agnostic job queue written in Go! Write your jobs in any language, schedule them from any language, run them anywhere!