本文整理汇总了PHP中eZPersistentObject::conditionText方法的典型用法代码示例。如果您正苦于以下问题:PHP eZPersistentObject::conditionText方法的具体用法?PHP eZPersistentObject::conditionText怎么用?PHP eZPersistentObject::conditionText使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类eZPersistentObject
的用法示例。
在下文中一共展示了eZPersistentObject::conditionText方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: newObjectOrder
/**
* Returns an order value which can be used for new items in table,
* for instance placement.
*
* Uses $def, $orderField and $conditions to figure out the currently maximum
* order value and returns one that is larger.
*
* @param array $def A definition array of all fields, table name and sorting (see {@link eZPersistentObject::definition()} for more info)
* @param string $orderField
* @param array $conditions
* @return int
*/
public static function newObjectOrder($def, $orderField, $conditions)
{
$db = eZDB::instance();
$table = $def["name"];
$keys = $def["keys"];
$cond_text = eZPersistentObject::conditionText($conditions);
$rows = $db->arrayQuery("SELECT MAX({$orderField}) AS {$orderField} FROM {$table} {$cond_text}");
if (count($rows) > 0 and isset($rows[0][$orderField])) {
return $rows[0][$orderField] + 1;
} else {
return 1;
}
}
示例2: storeObject
//.........这里部分代码省略.........
if ($field_def['datatype'] == 'float' || $field_def['datatype'] == 'double') {
if ($value === null) {
$use_values_hash[$key] = 'NULL';
} else {
$use_values_hash[$key] = sprintf('%F', $value);
}
} else {
if ($field_def['datatype'] == 'int' || $field_def['datatype'] == 'integer') {
if ($value === null) {
$use_values_hash[$key] = 'NULL';
} else {
$use_values_hash[$key] = sprintf('%d', $value);
}
} else {
// Note: for more colherence, we might use NULL for sql strings if the php value is NULL and not an empty sring
// but to keep compatibility with ez db, where most string columns are "not null default ''",
// and code feeding us a php null value without meaning it, we do not.
$use_values_hash[$key] = "'" . $db->escapeString($value) . "'";
}
}
}
foreach ($doNotEscapeFields as $key) {
$use_values_hash[$key] = $changedValueFields[$key];
}
$use_values = array();
foreach ($use_field_names as $field) {
$use_values[] = $use_values_hash[$field];
}
unset($use_values_hash);
$value_text = implode(", ", $use_values);
$sql = "INSERT INTO {$table} ({$field_text}) VALUES({$value_text})";
$db->query($sql);
if (isset($def["increment_key"]) && is_string($def["increment_key"]) && !($obj->attributeContentToStore($def["increment_key"]) > 0)) {
$inc = $def["increment_key"];
$id = $db->lastSerialID($table, $inc);
if ($id !== false) {
$obj->setAttribute($inc, $id);
}
}
} else {
$use_fields = array_diff(array_keys($fields), array_merge($keys, $exclude_fields));
if (count($use_fields) > 0) {
// If we filter out some of the fields we need to intersect it with $use_fields
if (is_array($fieldFilters)) {
$use_fields = array_intersect($use_fields, $fieldFilters);
}
$use_field_names = array();
foreach ($use_fields as $key) {
if ($db->useShortNames() && is_array($fields[$key]) && array_key_exists('short_name', $fields[$key]) && strlen($fields[$key]['short_name']) > 0) {
$use_field_names[$key] = $fields[$key]['short_name'];
} else {
$use_field_names[$key] = $key;
}
}
$field_text = "";
$field_text_len = 0;
$i = 0;
foreach ($use_fields as $key) {
//$value = $obj->attribute( $key );
$value = $obj->attributeContentToStore($key);
if ($fields[$key]['datatype'] == 'float' || $fields[$key]['datatype'] == 'double') {
if ($value === null) {
$field_text_entry = $use_field_names[$key] . '=NULL';
} else {
$field_text_entry = $use_field_names[$key] . "=" . sprintf('%F', $value);
}
} else {
if ($fields[$key]['datatype'] == 'int' || $fields[$key]['datatype'] == 'integer') {
if ($value === null) {
$field_text_entry = $use_field_names[$key] . '=NULL';
} else {
$field_text_entry = $use_field_names[$key] . "=" . sprintf('%d', $value);
}
} else {
if (in_array($use_field_names[$key], $doNotEscapeFields)) {
$field_text_entry = $use_field_names[$key] . "=" . $changedValueFields[$key];
} else {
$field_text_entry = $use_field_names[$key] . "='" . $db->escapeString($value) . "'";
}
}
}
$field_text_len += strlen($field_text_entry);
$needNewline = false;
if ($field_text_len > 60) {
$needNewline = true;
$field_text_len = 0;
}
if ($i > 0) {
$field_text .= "," . ($needNewline ? "\n " : ' ');
}
$field_text .= $field_text_entry;
++$i;
}
$cond_text = eZPersistentObject::conditionText($key_conds);
$sql = "UPDATE {$table} SET {$field_text}{$cond_text}";
$db->query($sql);
}
}
$obj->setHasDirtyData(false);
}
示例3: newObjectOrder
static function newObjectOrder( $def, $orderField, $conditions )
{
$db = eZDB::instance();
$table = $def["name"];
$keys = $def["keys"];
$cond_text = eZPersistentObject::conditionText( $conditions );
$rows = $db->arrayQuery( "SELECT MAX($orderField) AS $orderField FROM $table $cond_text" );
if ( count( $rows ) > 0 and isset( $rows[0][$orderField] ) )
return $rows[0][$orderField] + 1;
else
return 1;
}