Update::WhereAdd
Add a requirement to update Sintaxe namespace ProtocolLive\PhpLiveDb; use ProtocolLive\PhpLiveDb\Enums\{
AndOr,
};Operators, Parenthesis, Types function Update::WhereAdd(
string|UnitEnum
$Field,
):self;
string|bool $Value = null, Types $Type = null, Operators $Operator = Operators::Equal, AndOr $AndOr = AndOr::And, Parenthesis $Parenthesis = Parenthesis::None, string $CustomPlaceholder = null, bool $BlankIsNull = true, bool $NoBind = false Parameters
$Field - Field name. Can be null to only add Parenthesis or add Exists operator; $Value - The field value; $Type - The field type; $Operator - The comparing operator; $AndOr - The relation with the previous field; $Parenthesis - The parenthesis operator; $CustomPlaceholder - String to use as placeholder; $BlankIsNull - Replace '' to null; $NoBind - Don't bind in that call. Used with Operators::Sql or to reuse placeholder. (Changed to true if Operators::Sql are used) Notes
- When the $Value is null, the Type are changed to Types::Null; - When the $Operator is Operators::Sql, the $NoBind are changed to true; - When using a SQL expression in $Field, its mandatory to use the $CustomPlaceholder; Return
Return the same object instance for cascading calls See more
- AndOr - Types Examples
$Db->Update('users')
->FieldAdd(
'pwd',
)password_hash($_POST['email'], PASSWORD_DEFAULT), Types::Str ->WhereAdd(
'email',
)$_POST['email'], Types::Str ->Run(); //update users set pwd=:pwd where email=:email //update users set pwd='43v6qtq8otg8otob' where email='foo@bar.com' |