Skip to content

sprintf()-like syntax support #123

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
maartenheideman opened this issue May 29, 2021 · 0 comments
Open

sprintf()-like syntax support #123

maartenheideman opened this issue May 29, 2021 · 0 comments

Comments

@maartenheideman
Copy link

maartenheideman commented May 29, 2021

I'll want to use your great work in combination with the WordPress wpdb class. But WordPress prepare ask for a sprintf()-like syntax in their prepare method. Is there a workaround for that? On the moment I'll use something like this

$sql = $builder->write($query);
$values = $builder->getValues();

foreach ($values as $key => $value) {
    if( is_numeric($value) ){
        $sql = str_replace($key, '%d', $sql);
    } else {
        $sql = str_replace($key, '%s', $sql);
    }
};

$results = $wpdb->get_results( $wpdb->prepare($sql,array_values($values)) );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant