-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
[BUG] Model\Query throws fatal error #1529
Comments
Can this one be closed now? |
Hi, i am currently running stable 1.2.4 and getting this error of course. would it be safe to upgrade to 1.3.0 ? |
@zyxep Those errors are not critical (ie they do not lead to a crash and only happen when the user is misusing the class) and the code in 1.2.x and 1.3.0 has diverged much -- the patch won't apply cleanly, this is why I did not backport the fix into 1.2.5. As for upgrade -- I do use 1.3.0 in the production and it works like a charm, but your mileage may vary and I would suggest to test 1.3.0 on the dev server first. |
then someone should tell me how to use the code then. <?php
// Instantiate the Query
$query = new Phalcon\Mvc\Model\Query("SELECT * FROM Cars", $di);
// Execute the query returning a result if any
$cars = $query->execute(); i use it this way <?php
use Phalcon\Mvc\Model,
Phalcon\Mvc\Model\Query;
class Gallery extends Model
{
public function get_pictures($options = array())
{
$sql = "SELECT p.id, p.filename ";
$sql .= "FROM pictures p WHERE ";
$sql .= "p.status = 'active' ";
$query = new Query($sql);
return $query->execute();
}
} I doesn't see any different from the documentation to my code. |
This is a closed bug report - not the place to ask for help with code. Use the forum for that. |
Try this: <?php
use Phalcon\Mvc\Model,
Phalcon\Mvc\Model\Query;
class Gallery extends Model
{
public function get_pictures($options = array())
{
$sql = "SELECT p.id, p.filename ";
$sql .= "FROM pictures p WHERE ";
$sql .= "p.status = 'active'";
$query = new Query($sql, $this->getDI());
return $query->execute();
}
} or: <?php
use Phalcon\Mvc\Model,
Phalcon\Mvc\Model\Query;
class Gallery extends Model
{
public function get_pictures($options = array())
{
return Pictures::find(array(
'columns' => 'id, filename',
'conditions' => 'status = "active"'
))
}
} |
Thanks it helped, i will not disturb you anymore :) |
how to join two table by using common id? sorry my bad English :( 'question_id', 'questionModuleID' => 'questionModuleID', 'questionText' => 'questionText', 'questionOptions' => 'questionOptions', 'questionMarks' => 'questionMarks' ); } public function initialize() { $this->hasMany("questionModuleID","Module","module_id"); } ``` |
Hi,
When I run this code from a model:
I get this output:
I realize this is because I'm not sending my DI container as the second argument. However, I feel this should trigger an exception.
It would seem the second argument is optional, due to the fact PHP isn't throwing an error saying an argument is missing. However I'm guessing code later in the method NEEDS the DI to be set. This should cause an exception to be thrown.
The text was updated successfully, but these errors were encountered: