Garry's Mod Wiki

Revision Difference

sql.LastError#512885

<function name="LastError" parent="sql" type="libraryfunc">⤶ <description>Returns the last error from a SQLite query.</description>⤶ <realm>Shared and Menu</realm>⤶ <rets>⤶ <ret name="" type="string">error</ret>⤶ </rets>⤶ </function>⤶ ⤶ <example>⤶ <description>Reports all SQL errors into console automatically. Can help on debugging or testing</description>⤶ <code>⤶ sql.m_strError = nil -- This is required to invoke __newindex⤶ setmetatable(sql,{__newindex = function(t,k,v) if k == "m_strError" and v then print("[SQL Error] "..v) end end})⤶ </code>⤶ <output>After running &amp;lt;pre class="inline"&amp;gt;sql.Query("SELECT")&amp;lt;/pre&amp;gt; will print &amp;lt;pre class="inline"&amp;gt;[SQL Error] incomplete input&amp;lt;/pre&amp;gt; in the console.</output>⤶ ⤶ </example>