Skip to content
This repository has been archived by the owner on Nov 9, 2021. It is now read-only.

Commit

Permalink
New docs for #82
Browse files Browse the repository at this point in the history
  • Loading branch information
hiddentao committed Jul 24, 2014
1 parent 37b30b3 commit 0f96054
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 26 deletions.
45 changes: 28 additions & 17 deletions api.html
Expand Up @@ -620,12 +620,6 @@
type: 'Boolean',
desc: 'If set and the value is a String then it will not be quoted in the output',
defaultValue: 'false',
},
'options.duplicateKeyUpdate': {
flavours: ['mysql'],
type: 'Any',
desc: 'Value to set for this field using an <code>ON DUPLICATE KEY UPDATE</code> clause if a row for given key already exists within the table.',
defaultValue: 'null',
}
},
returns: 'this'
Expand All @@ -647,12 +641,6 @@
desc: 'When <code>autoQuoteFieldNames</code> is turned on this flag instructs it to ignore the period (.) character within field names.',
defaultValue: 'false',
},
'options.duplicateKeyUpdate': {
flavours: ['mysql'],
type: 'Object',
desc: 'Key-value pairs specifying value to set for fields using an <code>ON DUPLICATE KEY UPDATE</code> clause if a row for given key already exists within the table.',
defaultValue: 'null',
}
},
returns: 'this'
},
Expand All @@ -673,14 +661,37 @@
desc: 'When <code>autoQuoteFieldNames</code> is turned on this flag instructs it to ignore the period (.) character within field names.',
defaultValue: 'false',
},
'options.duplicateKeyUpdate': {
flavours: ['mysql'],
},
returns: 'this'
},
'.onDupUpdate()': {
desc: 'Add an <code>ON DUPLICATE KEY UPDATE</code> clause for given field',
flavours: ['mysql'],
params: {
name: {
desc: 'Name of field.',
type: 'String'
},
value: {
type: 'Any',
desc: 'Value to set to field.'
},
options: {
type: 'Object',
desc: 'Key-value pairs specifying value to set for fields using an <code>ON DUPLICATE KEY UPDATE</code> clause if a row for given key already exists within the table.',
desc: 'Additional options.',
defaultValue: 'null',
},
'options.ignorePeriodsForFieldNameQuotes': {
type: 'Boolean',
desc: 'When <code>autoQuoteFieldNames</code> is turned on this flag instructs it to ignore the period (.) character within field names.',
defaultValue: 'false',
},
'options.dontQuote': {
type: 'Boolean',
desc: 'If set and the value is a String then it will not be quoted in the output',
defaultValue: 'false',
}
},
returns: 'this'
}
},
'.returning()': {
desc: 'Add a RETURNING clause.',
Expand Down
19 changes: 11 additions & 8 deletions index.html
Expand Up @@ -48,7 +48,7 @@
<li><a href="#custom_types" title="Custom value types">Custom types</a></li>
<li><a href="#custom_queries" title="Custom queries">Custom queries</a></li>
<li><a href="#cloning" title="Cloning">Cloning</a></li>
<li><a href="#db_engines" title="Database engine support">Database support</a></li>
<li><a href="#db_engines" title="Database engine support">Database engines</a></li>
</ul>
</nav>
</header>
Expand Down Expand Up @@ -1407,20 +1407,23 @@ <h3>MySQL</h3>
<pre class="brush: js">
squel.useFlavour('mysql');

alert(
alert(JSON.stringify(
squel.insert()
.into('table')
.setFields({
field1: 'abc',
field2: 3
}, {
duplicateKeyUpdate: {
field1: 5
}
})
);
.onDupUpdate('field1', 'upd')
.toParam()
));

/* INSERT INTO table (field1, field2) VALUES ('abc', 3) ON DUPLICATE KEY UPDATE field1 = 5 */
/*
{
text: 'INSERT INTO table (field1, field2) VALUES (?, ?) ON DUPLICATE KEY UPDATE field1 = ?'
values: ['abc', 3, 'upd']
}
*/
</pre>

<p>The <a href="api.html">API docs</a> have more details on the specific features supported by each flavour.</p>
Expand Down

0 comments on commit 0f96054

Please sign in to comment.