{"id":28369818,"url":"https://github.com/dkern/frosted-mysql-library","last_synced_at":"2026-04-30T19:32:17.344Z","repository":{"id":151614190,"uuid":"11815699","full_name":"dkern/frosted-mysql-library","owner":"dkern","description":"The Frosted MySQL Library is an extension to the default mysql and mysqli functions of php. With it you can easily create complex queries and get big advantages while development. Beginners or infrequent developers will get an easy entry to mysql and pro's can do it's work much faster and with more possibilities.","archived":false,"fork":false,"pushed_at":"2013-08-02T09:09:28.000Z","size":119,"stargazers_count":2,"open_issues_count":0,"forks_count":3,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-06-20T02:37:33.211Z","etag":null,"topics":["complex-queries","mysql","mysql-query","php"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dkern.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-08-01T11:55:37.000Z","updated_at":"2021-04-29T21:01:49.000Z","dependencies_parsed_at":"2023-04-06T16:40:36.167Z","dependency_job_id":null,"html_url":"https://github.com/dkern/frosted-mysql-library","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/dkern/frosted-mysql-library","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dkern%2Ffrosted-mysql-library","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dkern%2Ffrosted-mysql-library/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dkern%2Ffrosted-mysql-library/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dkern%2Ffrosted-mysql-library/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dkern","download_url":"https://codeload.github.com/dkern/frosted-mysql-library/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dkern%2Ffrosted-mysql-library/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32475192,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-30T13:12:12.517Z","status":"ssl_error","status_checked_at":"2026-04-30T13:12:06.837Z","response_time":57,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["complex-queries","mysql","mysql-query","php"],"created_at":"2025-05-29T05:45:12.513Z","updated_at":"2026-04-30T19:32:17.338Z","avatar_url":"https://github.com/dkern.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"Frosted MySQL Library for PHP\n=============================\n\nThe `Frosted MySQL Library` is an extension to the default `mysql` and `mysqli` functions of php.\nWith it you can easily create complex queries and get big advantages while development.\nBeginners or infrequent developers will get an easy entry to mysql and pro's can do it's work much faster and with more possibilities.\nJust take a look to the examples or read the little documentation below.\n\nAs of the official mysql documentation, the `Frosted MySQL Library` can create **100%** of all `INSERT`, `UPDATE`, `DELETE`, `REPLACE`, `TRUNCATE` queries and nearly every `SELECT` query you want\n(the only exception are the sql parameters and the file output in the `SELECT` query).\n\nAll classes in the library has fully support for code-completion in IDEs like `PHPStorm` or `Aptana` and are documented with `PHPDoc`.\n\n##Features##\n* support `mysql` and `mysqli`\n* optional persistent connections\n* `read-only` and `write` permissions\n* in-query replacements\n* automatically escaping all values\n* create queries in `oop` way\n* detailed error messages\n* receive results in many formats\n* dynamically create `collections` of results\n* formatted query output if wished\n* dynamic parameters to create queries in many ways\n* many alias methods to write the code as you think\n* fully documented with `PHPDoc`\n* support for auto complete in IDEs like `PHPStorm` or `Aptana`\n* easy to configure, easy to use\n* _and much more ..._\n\n###Installation###\nTo use the `Frosted MySQL Library` just include the `packed` file, or every single file in the `classes/` folder (the `mysql.config.php` is optional) in your scripts.\nWith the `packed` version you receive the full library within one file and is the best solution for the most.\nIf you doesn't use all features you can include all needed files by your own.\n\n```PHP\nrequire_once(\"packed/mysql.class.packed.php\");\ninclude(\"packed/mysql.config.php\")\n```\n\n###Config \u0026 Examples###\nAfter including the `Frosted MySQL Library` you just have to configure the mysql server settings and start using it.\nTake a look to the `examples/02_config.php`, to see which settings are available and how to do this in different ways.\nA manual way to configure the library is seen below.\nIn the `examples/` folder you will find more different examples to get you into the code.\n\n```PHP\n$sql = new mysqlClass();\n$sql-\u003esetHostname(\"localhost\");\n$sql-\u003esetUsername(\"root\");\n$sql-\u003esetPassword(\"Pass1234\");\n$sql-\u003esetDatabase(\"frosted\");\n\n$sql-\u003econnect();\n\n// start using Frosted MySQL Library ...\n```\n\n###Create Queries###\nAs the whole library, creating a query is very simple and straight-forward.\nJust write the code as you would, when writing an mysql query.\nIf you use an IDE like PHPStorm or Aptana you will take advantage of the automatically code-completion which can show you all possible options. \n\n```PHP\n$result = $sql-\u003eselect(\"id\")\n              -\u003efrom(\"users\")\n              -\u003ewhere(\"login = ?\", \"frosted@eisbehr.de\")\n              -\u003elimit(1);\n```\n\nThis example above is equal to the mysql query:\n```MYSQL\nSELECT id FROM users WHERE login = 'frosted@eisbehr.de' LIMIT 1\n```\n\nThe order of query functions is not relevant, you can mix the order as you want or specify some options later.\n```PHP\n$query = $sql-\u003eselect(\"id\")\n             -\u003elimit(1)\n             -\u003efrom(\"users\");\n\n$result = $query-\u003ewhere(\"login = ?\", \"frosted@eisbehr.de\");\n```\n\n###Complex \u0026 Sub-Queries###\nLike possible in usual mysql queries, you can use sub-queries even with `Frosted MySQL Library`.\nFunctions like `columns` (select), `where`, `orWhere`, `having`, `orHaving`, `select` (insert) or `union` can receive mysqlClass instances as well.\nYou can split your queries in many different ones, and use them separately, or write them in-code.\nFollowing an example of an bit complexer query with sub queries in two ways.\n\n```PHP\n// create query with in-code sub-queries\n$result = $sql-\u003eselect(array(\"p.entity_id\", \"p.sku\" =\u003e \"sku\"))\n              -\u003ecolumns(array(\"n.value\" =\u003e \"name\", \"t.value\" =\u003e \"image\", \"s.attribute_set_name\"))\n\t\t\t  -\u003eall()\n\t\t\t  -\u003ehighPriority()\n\t\t\t  -\u003estraight()\n\t\t\t  -\u003efrom(array(\"{DB}.catalog_product_entity\" =\u003e \"p\"))\n\t\t\t  -\u003efrom(array(\"{DB}.eav_attribute\" =\u003e \"a\"))\n\t\t\t  -\u003efrom(array(\"{DB}.eav_attribute_set\" =\u003e \"s\"))\n\t\t\t  -\u003efrom(array(\"{DB}.catalog_product_entity_varchar\" =\u003e \"n\"))\n\t\t\t  -\u003efrom(array(\"{DB}.catalog_product_entity_varchar\" =\u003e \"t\"))\n\t\t\t  -\u003efrom(array(\"{DB}.catalog_product_entity_varchar\" =\u003e \"v\"))\n\t\t\t  -\u003ewhere(\"n.entity_id = p.entity_id\")\n\t\t\t  -\u003ewhere(\"t.entity_id = p.entity_id\")\n\t\t\t  -\u003ewhere(\"v.entity_id = p.entity_id\")\n\t\t\t  -\u003ewhere(\"n.attribute_id = ?\", $sql-\u003eselect(\"s.attribute_id\", true)\n\t\t\t\t\t\t\t\t\t\t\t    -\u003efrom(array(\"eav_attribute\" =\u003e \"s\", \"eav_entity_type\" =\u003e \"e\"))\n\t\t\t\t\t\t\t\t\t\t\t    -\u003ewhere(\"s.attribute_code = 'name'\")\n\t\t\t\t\t\t\t\t\t\t\t    -\u003ewhere(\"s.entity_type_id = e.entity_type_id\")\n\t\t\t\t\t\t\t\t\t\t\t    -\u003ewhere(\"e.entity_type_code = 'catalog_product'\"))\n\t\t\t  -\u003ewhere(\"t.attribute_id = ?\", $sql-\u003eselect(\"s.attribute_id\", true)\n\t\t\t\t\t\t\t\t\t\t\t    -\u003efrom(array(\"eav_attribute\" =\u003e \"s\", \"eav_entity_type\" =\u003e \"e\"))\n\t\t\t\t\t\t\t\t\t\t\t    -\u003ewhere(\"s.attribute_code = ?\", \"image_transparent\")\n\t\t\t\t\t\t\t\t\t\t\t    -\u003ewhere(\"s.entity_type_id = e.entity_type_id\")\n\t\t\t\t\t\t\t\t\t\t\t    -\u003ewhere(\"e.entity_type_code = 'catalog_product'\"))\n\t\t\t  -\u003ewhere(\"v.attribute_id = a.attribute_id\")\n\t\t\t  -\u003ewhere(\"p.attribute_set_id = s.attribute_set_id\")\n\t\t\t  -\u003ewhere(\"s.attribute_set_name NOT IN(?)\", array(\"123456\", \"654321\"))\n\t\t\t  -\u003ewhere(\"a.attribute_code = ?\", \"product_info\")\n\t\t\t  -\u003ewhere(\"t.value != ?\", \"no_selection\")\n\t\t\t  -\u003ewhere(\"v.value = ?\", \"new\")\n\t\t\t  -\u003eorder(\"rand()\")\n\t\t\t  -\u003elimit(10)\n\t\t\t  -\u003elockInShareMode()\n\t\t\t  -\u003eunion($sql-\u003eselect(true)\n\t\t\t\t\t\t  -\u003efrom(\"{DB}.product_buffer_table\")\n\t\t\t\t\t\t  -\u003ewhere(\"product_info = ?\", \"new\"))\n\t\t\t  -\u003erun()\n\t\t\t  -\u003egetCollection();\n```\n\nYou can even split all sub-queries to own instances an use them separately. Just as you like ...\n\n```PHP\n// create and use sub-query\n$nameAttribute =  $sql-\u003eselect(\"s.attribute_id\", true)\n\t\t\t\t\t  -\u003efrom(array(\"eav_attribute\" =\u003e \"s\", \"eav_entity_type\" =\u003e \"e\"))\n\t\t\t\t\t  -\u003ewhere(\"s.attribute_code = 'name'\")\n\t\t\t\t\t  -\u003ewhere(\"s.entity_type_id = e.entity_type_id\")\n\t\t\t\t\t  -\u003ewhere(\"e.entity_type_code = 'catalog_product'\");\n$nameId = $nameAttribute-\u003eshowQuery()-\u003erun();\n\n// create and use sub-query\n$imageAttribute = $sql-\u003eselect(\"s.attribute_id\", true)\n\t\t\t\t\t  -\u003efrom(array(\"eav_attribute\" =\u003e \"s\", \"eav_entity_type\" =\u003e \"e\"))\n\t\t\t\t\t  -\u003ewhere(\"s.attribute_code = ?\", \"image_transparent\")\n\t\t\t\t\t  -\u003ewhere(\"s.entity_type_id = e.entity_type_id\")\n\t\t\t\t\t  -\u003ewhere(\"e.entity_type_code = 'catalog_product'\");\n$imageId = $imageAttribute-\u003eshowQuery()-\u003erun();\n\n// create and use sub-query\n$productBuffer =  $sql-\u003eselect(true)\n\t\t\t\t\t  -\u003efrom(\"{DB}.product_buffer_table\")\n\t\t\t\t\t  -\u003ewhere(\"product_info = ?\", \"new\");\n$buffered = $productBuffer-\u003eshowQuery()-\u003erun();\n\n// create and use main query with all sub-queries as variable\n$products =       $sql-\u003eselect(array(\"p.entity_id\", \"p.sku\" =\u003e \"sku\"))\n\t\t\t\t\t  -\u003ecolumns(array(\"n.value\" =\u003e \"name\", \"t.value\" =\u003e \"image\", \"s.attribute_set_name\"))\n\t\t\t\t\t  -\u003eall()\n\t\t\t\t  \t  -\u003ehighPriority()\n\t\t\t\t\t  -\u003estraight()\n\t\t\t\t\t  -\u003efrom(array(\"{DB}.catalog_product_entity\" =\u003e \"p\"))\n\t\t\t\t  \t  -\u003efrom(array(\"{DB}.eav_attribute\" =\u003e \"a\"))\n\t\t\t\t  \t  -\u003efrom(array(\"{DB}.eav_attribute_set\" =\u003e \"s\"))\n\t\t\t\t  \t  -\u003efrom(array(\"{DB}.catalog_product_entity_varchar\" =\u003e \"n\"))\n\t\t\t\t\t  -\u003efrom(array(\"{DB}.catalog_product_entity_varchar\" =\u003e \"t\"))\n\t\t\t\t\t  -\u003efrom(array(\"{DB}.catalog_product_entity_varchar\" =\u003e \"v\"))\n\t\t\t\t\t  -\u003ewhere(\"n.entity_id = p.entity_id\")\n\t\t\t\t\t  -\u003ewhere(\"t.entity_id = p.entity_id\")\n\t\t\t\t\t  -\u003ewhere(\"v.entity_id = p.entity_id\")\n\t\t\t\t\t  -\u003ewhere(\"n.attribute_id = ?\", $nameAttribute)\n\t\t\t\t\t  -\u003ewhere(\"t.attribute_id = ?\", $imageAttribute)\n\t\t\t\t\t  -\u003ewhere(\"v.attribute_id = a.attribute_id\")\n\t\t\t\t\t  -\u003ewhere(\"p.attribute_set_id = s.attribute_set_id\")\n\t\t\t\t\t  -\u003ewhere(\"s.attribute_set_name NOT IN(?)\", array(\"123456\", \"654321\"))\n\t\t\t\t\t  -\u003ewhere(\"a.attribute_code = ?\", \"product_info\")\n\t\t\t\t\t  -\u003ewhere(\"t.value != ?\", \"no_selection\")\n\t\t\t\t\t  -\u003ewhere(\"v.value = ?\", \"new\")\n\t\t\t\t\t  -\u003eorder(\"rand()\")\n\t\t\t\t\t  -\u003elimit(10)\n\t\t\t\t\t  -\u003elockInShareMode()\n\t\t\t\t\t  -\u003eunion($productBuffer)\n\t\t\t\t\t  -\u003erun()\n\t\t\t\t\t  -\u003egetCollection();\n```\n\n###Run Query###\nYou can create or change a query as long as you want.\nThe instance will be available all the time.\nWhen you finished creating your query, it's time to send them to the mysql server and run them.\nFor doing this, just call `run()` on the query instance, or `run(true)` to receive the raw `mysql resource` or the `mysqli_result`, according to the functions you use.\n\n```PHP\n// create query\n$query = $sql-\u003eselect()-\u003efrom(\"users\");\n\n// add option\n$query-\u003elimit(1000);\n\n// run query\n$result = $query-\u003erun();\n```\n\n###Results###\nWhen using the `Frosted MySQL Library` you don't have to fetch the mysql results by your own anymore, like `while( $row = mysql_fetch_assoc($result) ) { ... }`.\nIt's easy to receive the results in all ways you want and need. The `fetch()` function is all you need from now on.\n\n```PHP\n// create and run query\n$result = $sql-\u003eselect()-\u003efrom(\"users\")-\u003erun();\n\n// mysql_fetch_assoc()\n$assoc = $result-\u003efetch();\n$assoc = $result-\u003efetch(mysqlClass::FETCH_ASSOC);\n\n// mysql_fetch_array()\n$array = $result-\u003efetch(mysqlClass::FETCH_ARRAY);\n\n// mysql_fetch_row()\n$row = $result-\u003efetch(mysqlClass::FETCH_ROW);\n\n// loop trough the results\nforeach( $assoc as $rowNumber =\u003e $row )\n    // do your work\n```\n\nBut if you sill want to use the default php mysql fetch functionality you can receive the raw `mysql resource` or the `mysqli_result`, according to the functions you use, by use `run(true)`.\n```PHP\n// create and run query\n$rawResult = $sql-\u003eselect()-\u003efrom(\"users\")-\u003erun(true);\n\n// loop through the results\nwhile( $row = mysql_fetch_assoc($rawResult) )\n    // do your work\n```\n\n###Collections###\nA `collection` is another result type you can receive for a result.\nIt's a powerful tool to handle mysql results.\nYou can receive specific data from collections, run further filters, replace data, output all rows in different formats and much more.\n\n```PHP\n// create and run query\n$result = $sql-\u003eselect()-\u003efrom(\"users\")-\u003erun();\n\n// get loaded collection\n$collection = $result-\u003egetCollection();\n\n// alternative ways\n$collection = $result-\u003efetch(mysqlClass::FETCH_OBJ);\n$collection = $result-\u003efetch(mysqlClass::FETCH_OBJECT);\n$collection = $result-\u003efetch(mysqlClass::FETCH_COLLECTION);\n\n// loop through collection\nforeach( $collection as $row )\n    // do your work\n\n// get a row by id\n$row = $collection-\u003egetItemById(1);\n\n// get a row by position\n$row = $collection-\u003egetItem(10);\n\n// further filter on collection\n// receive only rows where id is greater than 10\n$collection-\u003eaddColumnToFilter(\"id\", 10, mysqlClass_Collection::LOGIC_GT);\n\n// output all as xml\necho $collection-\u003etoXml();\n```\n\n###Alternative Calls###\nTo support your coding style and to use the classes in many, many different ways, the most query functions have dynamical parameters.\nThe default parameters are more an hint as an strict requirement. An example with select columns:\n\n```PHP\n// this\n$sql-\u003eselect(\"id\", \"name\", \"email\");\n\n// is the same as\n$sql-\u003eselect(array(\"id\", \"name\", \"email\"));\n\n// is the same as\n$sql-\u003eselect(\"id\", array(\"name\", \"email\"));\n\n// is the same as\n$sql-\u003eselect()-\u003ecolumns(\"id\", \"name\", \"email\");\n\n// is the same as\n$sql-\u003eselect()-\u003ecolumns(array(\"id\", \"name\", \"email\"));\n\n// is the same as\nsql-\u003eselect()-\u003ecolumns(array(\"id\"), \"name\", \"email\");\n\n// is the same as\n$sql-\u003eselect(\"id\")-\u003ecolumn(\"name\")-\u003ecolumn(\"email\");\n\n// is the same as\n$sql-\u003eselect()-\u003ecolumn(\"id\")-\u003ecolumn(\"name\")-\u003ecolumn(\"email\");\n\n// is the same as\n$sql-\u003eselect(array(\"id\" =\u003e \"id\", \"name\" =\u003e \"name\", \"email\" =\u003e \"email\");\n\n// and so on ...\n```\n\n###Multiple Query Instances###\nBy default the `Frosted MySQL Library` will create only one instance per query at a time to get the best possible speed.\nThis means that you can only build one query type at once (one `SELECT`, one `INSERT`, one `UPDATE`, ...).\n\nIf you need more instances of a query, like for sub-queries, add an boolean `true` as last parameter of the query construct.\n\n```PHP\n// create a select instance \n$select_1 = $sql-\u003eselect(\"id\");\n\n// this will override the first query instance\n// $select_1 will now be the same as $select_2\n$select_2 = $sql-\u003eselect(\"id\", \"name\");\n\n// create a new instance\n// $select_3 is a whole new query and $select_2 is still available\n$select_3 = $sql-\u003eselect(\"id\", true);\n```\n\n###Debug \u0026 Printing###\nFor easy debugging or if you want to use `exception` instead or errors, set the `verbose` option to the `mysqlClass`.\nAnother help to debug queries is to print them directly with `showQuery()` or receive them as string to use it somewhere else with `getQuery()`.\nIf you want to print the query or maybe show them somewhere enable `setFormat` to the `mysqlClass`, to receive all query formatted for better readability.\n\n```PHP\n// set options\n$sql-\u003esetVerbose(true);\n$sql-\u003esetFormat(true);\n\n// create query\n$queryString = $sql-\u003eupdate(\"table_name\")\n\t\t\t\t   -\u003eset(\"column_1 = ?\", \"colOne\")\n\t\t\t\t   -\u003eset(\"column_2 = ?\", \"colTwo\")\n\t\t\t\t   -\u003eset(\"column_3 = ?\", \"colThree\")\n\t\t\t\t   -\u003eset(\"column_4 = ?\", \"colFour\")\n\t\t\t\t   -\u003ewhere(\"id = ?\", 1337)\n\t\t\t\t   -\u003elimit(1)\n\t\t\t\t   -\u003eshowQuery()\n\t\t\t\t   -\u003egetQuery();\n```\n\nThis will pass the query string to the `$queryString` variable and print the query directly to the browser.\nThe output will look like this:\n\n```MYSQL\nUPDATE \n    table_name\nSET\n    column_1 = 'colOne', \n    column_2 = 'colTwo', \n    column_3 = 'colThree', \n    column_4 = 'colFour'\nWHERE \n    id = 1337 \nLIMIT \n    1\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdkern%2Ffrosted-mysql-library","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdkern%2Ffrosted-mysql-library","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdkern%2Ffrosted-mysql-library/lists"}