Question

I just asked this question, but have now found that the problem with binding conditions in that method is it's very hard to programatically compile more complex queries...

I think I need to be using the PHP ActiveRecord SQLBuilder but I'm finding the documentation confusing. How do i actually execute a query i've 'built'?

This is their example code, but it doesn't actually show you how to return any data?!

$builder = new ActiveRecord\SQLBuilder($conn, "table_name");     
$builder->where("name = ?", "Hemingway");
echo $builder; /* => SELECT * FROM table_name WHERE name = ? */

Any help really appreciated :)

Était-ce utile?

La solution

If the model corresponding to table table_name is ModelName then:

$result_set = ModelName::find_by_sql($builder->to_s(), $builder->bind_values());

Autres conseils

haven't checked completely but following might be helpful

ADODB Active Records for PHP

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top