Welcome Guest, Not a member yet? Register   Sign In
DMZ 1.7.1 (DataMapper OverZealous Edition)

[eluser]OverZealous[/eluser]
@backstack
If you follow the instructions, you'll see there's no need to include it at all. Just place it in the models directory.

[eluser]introvert[/eluser]
Hey,

I have a DATETIME field in my model. I'm not sure how should I set the datetime value to NOW().

I tried doing:
Code:
$this->column_name = 'NOW()';

But it will set datetime to zero.

How should I set the timestamp properly?

I looked at documentation and couldnt find any helpful information.

Thanks for help

[eluser]Atas[/eluser]
Try

$this->column_name = date('Y-m-d H:iConfused);

[eluser]introvert[/eluser]
I think there should be some timestamp function to return the proper time based on the datamapper config file. Any idea?

[eluser]OverZealous[/eluser]
@introvert

Usually the best way to do this is to simply set the default value for the column to NOW(). Then you don't need to set it at all.

Otherwise, there is no built-in functionality for dates. Might be a good thing for an extension.

[eluser]Atas[/eluser]
Hello!

I'm trying to use IF STATMENTS with DMZ...

Code:
$oObject->select("publicacion.*, IF(moneda_id > 1, pub_precio * 1, pub_precio / 3.9) as result");

$oObject->having('result >=', $iMinRange);
$oObject->having('result <=', $iMaxRange);

This works fine if i use $oObject->get() to retrieve the data but if i use $oObject->get_paged($iPage, 10) i receive this error:

Code:
A Database Error Occurred

Error Number: 1054

Unknown column 'result' in 'having clause'

SELECT COUNT(*) AS `numrows` FROM (`publicacion`)
   WHERE `publicacion`.`pub_confirmada` = 1 AND `publicacion`.`pub_tipo` = 'xxx'
HAVING `result` >= 1 AND `result` <= 500

I suppose the count query doesn't add the if statment...

am i doing something wrong ?

Sorry for my english :red:

Thanks !

[eluser]Lucas Alves[/eluser]
You have to set the "escape" to FALSE...

$oObject->select("publicacion.*, IF(moneda_id > 1, pub_precio * 1, pub_precio / 3.9) as result", FALSE);

I think this will solve you problem

[eluser]backstack[/eluser]
I'm having some problems with the validation.

One of my authentication library methods creates a user, and I have a 'password_confirmation' validation item on my user model (obviously a non-database field).

But now, for my other methods (activating a user, for example, where I will just go '$user->activated = 1'), requires that 'password_confirmation' is set, but it obviously has nothing to do with activating a user.

EDIT: And if I want to validate a hash ('activation_hash') passed via the URL (/user/username_here/activate/activation_hash_here), how can I validate that in the model? What rule would I use to compare a user-passed value against the value in the database?

[eluser]OverZealous[/eluser]
@backstack
You always need to first load the object before saving it. It also provides a nice safety net of verifying the input.

Alternatively, look at the update method if you are simply updating one or more objects and don't need validation or verification.

For the last question, you'll just need to be creative. :-)

[eluser]frist44[/eluser]
I'm trying to iterate through an object in a view. So my controller has:

Code:
$o = new Order();
        $o->get();
        $o->product->get();

In my view:

Code:
foreach ($obj as $order){
                echo '<tr>';
                echo '<td>' . $order->id . '</td>';
                echo '<td>' . $order->product->id . $order->product->finish . '</td>';
                echo '<td>' . $order->quantity . '</td>';
                echo '<td>' . $order->reconciled . '</td>';
                echo '<td>' . mysql_datetime_to_php($order->created) . '</td>';                
                echo '</tr>';
            }

But $order->product->id, doesn't show up. if I do :

foreach ($obj->product as $product), I can get the info out. Why isn't the deeper relationships passed through with the foreach variable?




Theme © iAndrew 2016 - Forum software by © MyBB