{"id":22308957,"url":"https://github.com/vti/perl-sql-bind","last_synced_at":"2025-03-26T01:29:22.191Z","repository":{"id":56839963,"uuid":"259600261","full_name":"vti/perl-SQL-Bind","owner":"vti","description":"SQL flexible placeholders","archived":false,"fork":false,"pushed_at":"2020-05-27T12:47:43.000Z","size":20,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-30T22:55:00.200Z","etag":null,"topics":["bind","perl","sql"],"latest_commit_sha":null,"homepage":"","language":"Perl","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/vti.png","metadata":{"files":{"readme":"README.md","changelog":"Changes","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":"2020-04-28T10:08:22.000Z","updated_at":"2020-07-05T19:20:23.000Z","dependencies_parsed_at":"2022-08-28T22:00:14.734Z","dependency_job_id":null,"html_url":"https://github.com/vti/perl-SQL-Bind","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vti%2Fperl-SQL-Bind","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vti%2Fperl-SQL-Bind/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vti%2Fperl-SQL-Bind/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vti%2Fperl-SQL-Bind/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vti","download_url":"https://codeload.github.com/vti/perl-SQL-Bind/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245571428,"owners_count":20637343,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["bind","perl","sql"],"created_at":"2024-12-03T20:16:14.584Z","updated_at":"2025-03-26T01:29:22.168Z","avatar_url":"https://github.com/vti.png","language":"Perl","readme":"# NAME\n\nSQL::Bind - SQL flexible placeholders\n\n# SYNOPSIS\n\n    use SQL::Bind qw(sql);\n\n    # Scalars\n    my ($sql, @bind) =\n      sql 'SELECT foo FROM bar WHERE id=:id AND status=:status',\n      id     =\u003e 1,\n      status =\u003e 'active';\n\n    # Arrays\n    my ($sql, @bind) = sql 'SELECT foo FROM bar WHERE id IN (:id)', id =\u003e [1, 2, 3];\n\n    # Hashes\n    my ($sql, @bind) = sql 'UPDATE bar SET :columns', columns =\u003e {foo =\u003e 'bar'};\n\n    # Raw values (!)\n    my ($sql, @bind) = sql 'INSERT INTO bar (:keys!) VALUES (:values)',\n      keys   =\u003e [qw/foo/],\n      values =\u003e [qw/bar/];\n\n    # Recursive binding (*)\n    my ($sql, @bind) =\n      sql 'SELECT foo FROM bar WHERE :recursive_query*',\n      recursive_query =\u003e 'name = :name',\n      name            =\u003e 'hello';\n\n# DESCRIPTION\n\n[SQL::Bind](https://metacpan.org/pod/SQL%3A%3ABind) simplifies SQL queries maintenance by introducing placeholders. The behavior of the replacement depends on\nthe type of the value. Scalars, Arrays and Hashes are supported.\n\n## `Configuration`\n\n### `$PlaceholderPrefix`\n\nPlaceholder prefix (`:` by default) can be changed by setting the `$PlaceholderPrefix` global variable:\n\n    local $SQL::Bind::PlaceholderPrefix = '@';\n\n    my ($sql, @bind) =\n      sql 'SELECT foo FROM bar WHERE id=@id',\n      id =\u003e 1;\n\n## `Placeholders`\n\nA placeholders is an alphanumeric sequence that is prefixed with `:` (by default) and can end with `!` for raw values\nor `*` for recursive binding. Some examples:\n\n    :name\n    :status\n    :CamelCase\n    :Value_123\n    :ThisWillBeInsertedAsIs!\n    :recursive*\n\n## `Scalar values`\n\nEvery value is replaced with a `?`.\n\n    my ($sql, @bind) =\n      sql 'SELECT foo FROM bar WHERE id=:id AND status=:status',\n      id     =\u003e 1,\n      status =\u003e 'active';\n\n    # SELECT foo FROM bar WHERE id=? AND status=?\n    # [1, 'active']\n\n## `Array values`\n\nArrays are replaced with a sequence of `?, ?, ...`.\n\n    my ($sql, @bind) = sql 'SELECT foo FROM bar WHERE id IN (:id)', id =\u003e [1, 2, 3];\n\n    # SELECT foo FROM bar WHERE id IN (?, ?, ?)\n    # [1, 2, 3]\n\n## `Hash values`\n\nHahes are replaced with a sequence of `key1=?, key2=?, ...`.\n\n    my ($sql, @bind) = sql 'UPDATE bar SET :columns', columns =\u003e {foo =\u003e 'bar'};\n\n    # UPDATE bar SET foo=?\n    # ['bar']\n\n## `Raw values`\n\nSometimes raw values are needed be it another identifier, or a list of columns (e.g. `INSERT, UPDATE`). For this case\na placeholder should be suffixed with a `!`.\n\n    my ($sql, @bind) = sql 'INSERT INTO bar (:keys!) VALUES (:values)',\n      keys   =\u003e [qw/foo/],\n      values =\u003e [qw/bar/];\n\n    # INSERT INTO bar (foo) VALUES (?)\n    # ['bar']\n\n## `Recursive binding`\n\nRecursive binding allows you to recursively parse already replaced values. This helps building complex subqueries.\n\n    my ($sql, @bind) =\n      sql 'SELECT foo FROM bar WHERE :recursive_query*',\n      recursive_query =\u003e 'name = :name',\n      name            =\u003e 'hello';\n\n    # 'SELECT foo FROM bar WHERE name = ?\n    # ['hello']\n\n# DEVELOPMENT\n\n## Repository\n\n    http://github.com/vti/sql-bind\n\n# CREDITS\n\n# AUTHOR\n\nViacheslav Tykhanovskyi, `vti@cpan.org`.\n\n# COPYRIGHT AND LICENSE\n\nCopyright (C) 2020, Viacheslav Tykhanovskyi\n\nThis program is free software, you can redistribute it and/or modify it under\nthe terms of the Artistic License version 2.0.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvti%2Fperl-sql-bind","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvti%2Fperl-sql-bind","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvti%2Fperl-sql-bind/lists"}