logo
Ask your Symfony questions! Pay money and get answers fast! (more info)

Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.

If the asker does not get an answer then they have 10 days to request a refund.

$5
Fatal error: Object of class Criteria could not be converted

I get thiss error:

Warning: Illegal offset type in isset or empty in /usr/share/php/symfony/vendor/propel/util/Criteria.php on line 345

Catchable fatal error: Object of class Criteria could not be converted to string in /usr/share/php/symfony/vendor/propel/util/Criteria.php on line 1212


I just added this to my peeer class:


public static function getViaTextId( $id, $state = null, $con = null) {
if( empty($id) ) return false;

// if ($con === null) {
// $con = Propel::getConnection(self::DATABASE_NAME);
// }

$textid = mysql_real_escape_string($id);

//print_r( $textid);
//$sc = Connector::getInstance();

//if( empty($prefix) )
// $prefix = SF_PRODUCT;
// $website = $prefix;
// Are we in preview mode?
// $preview = $sc->GetForSite($website, 'CONTENT_PREVIEW',1);

$preview = '';

if(SF_ENVIRONMENT != 'prod') $preview = '1';

// echo '<br>preview is: '.$preview;

$c = new Criteria();
$c->add(FireBrickContentPeer::TEXTID, $textid);
$today = date("Y-m-d G:i:s");

if ($preview ) {
$c->add(FireBrickContentPeer::STATE, 'W');
//print_r($criteria1);
} else {
$c->add(FireBrickContentPeer::STATE, 'P');
$criteria2 = $c->getNewCriterion(FireBrickContentPeer::LIVE_DATE, '0000-00-00 00:00:00');
$criteria3 = $c->getNewCriterion(FireBrickContentPeer::LIVE_DATE, $today, Criteria::LESS_EQUAL);
// Perform OR at level 1 ($criteria2 $criteria3 )
$criteria2->addOr($criteria3);

// Perform AND at level 0 ($criteria1 $criteria2 )
$c->addAnd($criteria2);
print_r($c);
}
//echo 'do i even reach here?';
//$criteria0->addAnd($criteria1);
//echo 'here is the problem';
// $criteria1->addDescendingOrderByColumn(FireBrickContentPeer::LIVE_DATE);

print_r($c);

$v = FireBrickContentPeer::doSelectOne($c);

//print_r($v);
return $v;
//return !empty($v) ? $v : null;
}


The errror occurs on this line:

$v = FireBrickContentPeer::doSelectOne($c);

This is on a site runnning Symfony 1.0.

Waht cuase this error?

--------------------------

NEW INFO:

if i comment out everything except:

$c = new Criteria(); 
$v = FireBrickContentPeer::doSelectOne($c);


i still get the error.

I thought this was because the function was declared as 'static', but i changed that it is not static anymore. I still get the error:

Catchable fatal error: Object of class Criteria could not be converted to string in /usr/share/php/symfony/vendor/propel/util/Criteria.php on line 354

This mehtod gets called twice on the page. It works the first time, but it dies the second time.

What happens when a class has static methodss that call non-static methods that instantiate objects?


---------------------------------

update:

The error claims to happen in this core class:

/usr/share/php/symfony/vendor/propel/util/Criteria.php

here:

[CODE] public function getCriterion($column)
{
print_r($this->map);
if (isset($this->map[$column])) {
return $this->map[$column];
}
}[/CODE]


my print_r gives me:



[CODE]Array
(
[firebrick_content.CONTENT_TYPE] => Criterion Object
(
[value:private] => 37
[comparison:private] => =
[table:private] => firebrick_content
[realtable:private] => firebrick_content
[column:private] => CONTENT_TYPE
[ignoreStringCase:private] =>
[db:private] => DBMySQL Object
(
)

[clauses:private] => Array
(
)

[conjunctions:private] => Array
(
)

[parent:private] =>
)

[firebrick_content.STATE] => Criterion Object
(
[value:private] => P
[comparison:private] => =
[table:private] => firebrick_content
[realtable:private] => firebrick_content
[column:private] => STATE
[ignoreStringCase:private] =>
[db:private] => DBMySQL Object
(
)

[clauses:private] => Array
(
)

[conjunctions:private] => Array
(
)

[parent:private] =>
)

[firebrick_content.LIVE_DATE] => Criterion Object
(
[value:private] => 0000-00-00 00:00:00
[comparison:private] => =
[table:private] => firebrick_content
[realtable:private] => firebrick_content
[column:private] => LIVE_DATE
[ignoreStringCase:private] =>
[db:private] => DBMySQL Object
(
)

[clauses:private] => Array
(
[0] => Criterion Object
(
[value:private] => 2010-05-06 15:10:33
[comparison:private] => <=
[table:private] => firebrick_content
[realtable:private] => firebrick_content
[column:private] => LIVE_DATE
[ignoreStringCase:private] =>
[db:private] => DBMySQL Object
(
)

[clauses:private] => Array
(
)

[conjunctions:private] => Array
(
)

[parent:private] =>
)

)

[conjunctions:private] => Array
(
[0] => OR
)

[parent:private] =>
)

)[/CODE]

which is weird, since i comment out all code, and the mehtod no longer static

This question has been answered.

art | 05/06/10 at 1:09pm Edit


(11) Responses

See a threaded view of answers?

Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.

  • avatar
    Last edited:
    05/06/10
    1:25pm
    Eduardo Raffoul says:

    ┬┐Would you show me your schema.yml? There's something that may be, but im not sure.

    When you type

    $c->add(FireBrickContentPeer::TEXTID, $textid);


    It may be should be FireBrickContentPeer::TEXT_ID

  • avatar
    Last edited:
    05/06/10
    2:14pm
    Ender Technology says:

    AFAIK there is no need to call

    $textid = mysql_real_escape_string($id);
    because all input is automatically escaped. You may be double-escaping which is resulting in this error. Further, one of the main advantages of using the ORM interface is that it offers you a stronger potential database portability and adding mysql-specific commands to the code essentially destroys that advantage.

    Rob O.
    Ender Tech Corp.
    www.endertech.com

    Previous versions of this answer: 05/06/10 at 2:14pm

  • avatar
    Last edited:
    05/06/10
    3:01pm
    Jakub Zalas says:

    Are you sure it comes from the method you're debugging? Have you tried commenting its calls completely? I feel like fatal error is caused by a different part of your code.

  • avatar
    Last edited:
    05/08/10
    6:44am
    Bill Hunt says:

    I think this might be a bug in the old version of Propel. It looks like there's an issue with calling Criteria->getNewCriterion, the error on 1212 appears to be trying to parse the instance of Criteria as a string, thus the error. If you refactor to skip using that function, and stick to ->add(), I think it'll work.

    The second error is probably because it's trying to call Criteria's iterator against a nonexistant set of criteria, and breaking.

  • avatar
    Last edited:
    05/06/10
    1:43pm
    art says:

    No, it is TEXTID. I wouldd get "No defined CONSTANT" iff otherwise

  • avatar
    Last edited:
    05/06/10
    2:55pm
    Ender Technology says:

    I thought this was because the function was declared as 'static', but i changed that it is not static anymore.


    Those methods need to be static. Assuming that you changed it in the user's version of the model classes please post what that method contains.

    Rob O.
    Ender Tech Corp.
    www.endertech.com

  • avatar
    Last edited:
    05/06/10
    3:10pm
    art says:

    not sure how to test. method called twice. works the first time. if I comment out the code in the method then the page dies on the first call, and i never get to see what the 2nd call would look like

  • avatar
    Last edited:
    05/06/10
    3:12pm
    Jakub Zalas says:

    Are these calls next to each other in code? Or spread somewhere? Try commenting both calls. Maybe it's something else.

  • avatar
    Last edited:
    05/06/10
    3:14pm
    art says:

    Undid 'static'. No more static calls.

    Tried putting line after, code dies, line never gets called. Code dies on that line, for sure. Never makes it past that line.

  • avatar
    Last edited:
    05/06/10
    3:23pm
    Jakub Zalas says:

    How is that your code dies in getCriterion() when you never call it?

  • avatar
    Last edited:
    05/06/10
    9:09pm
    Jakub Zalas says:

    Do you use the latest symfony 1.0 release? If not than try to upgrade.

This question has expired.





Current status of this question: Completed



Warning: Please do not give out any FTP or ssh credentials to anyone, unless you trust them completely. Giving out login details is dangerous.

If the asker does not get an answer then they have 10 days to request a refund.