[Mysql-cocoa-commits] CVS: Documentation/website/SMySQL_doc SMySQLConnection.html,NONE,1.1 SMySQLRes
Brought to you by:
sergecohen
From: Serge C. <ser...@us...> - 2002-05-15 12:24:32
|
Update of /cvsroot/mysql-cocoa/Documentation/website/SMySQL_doc In directory usw-pr-cvs1:/tmp/cvs-serv26817 Added Files: SMySQLConnection.html SMySQLResult.html Log Message: Adding the html documentation of the framework to the web site. Serge Cohen; MySQL Cocoa project, May 15th 2002. --- NEW FILE: SMySQLConnection.html --- <HTML><HEAD><TITLE></TITLE></HEAD> <BODY BGCOLOR="#FFFFFF"> <BR><BR><FONT COLOR="#000066"><H1><A NAME="//apple_ref/occ/cl/SMySQLConnection">SMySQLConnection</A></H1></FONT><BR> <blockquote><DL><DT><B>Inherits From:</B></DT> <DD>NSObject</DD> </DL></blockquote> <blockquote><DL><DT><B>Declared In:</B></DT> <DD>SMySQLConnection.h</DD> </DL></blockquote> <BR><BR> <H2>Class Description</H2> This class is used to keep a connection with a MySQL server, it correspond to the MYSQL structure of the C API, or the database handle of the PERL DBI/DBD interface.<P> You have to start any work on a MySQL server by getting a working SMySQLConnection object.<P> Most likely you will use this kind of code:<P> <CODE> <BR> SMySQLConnection *theConnec = [SMySQLConnection alloc]; <BR> SMySQLResult *theRes;<BR> <BR> theConnec = [theConnec initToHost::albert.com withLogin:@"toto" password:@"albert" port:0]; <BR> [theConnec selectDB:@"db1"]; <BR> theRes = [theConnec queryString:@"select * from table1"]; <BR> ... <BR> </CODE> <P><HR WIDTH=50% ALIGN=LEFT> <H2>Symbolic Constants</H2> <blockquote> <H4>Synopsis:</H4> <CODE><B><A NAME="//apple_ref/c/econst/kSMySQL_default_option">kSMySQL_default_option</A></B> CLIENT_COMPRESS</CODE><BR> <CODE><B><A NAME="//apple_ref/c/econst/kSMySQLConnectionDefaultSocket">kSMySQLConnectionDefaultSocket</A></B> MYSQL_UNIX_ADDR</CODE><BR> <CODE><B><A NAME="//apple_ref/c/econst/kSMySQLConnection_error_not_inited">kSMySQLConnection_error_not_inited</A></B> 1000</CODE><BR> </blockquote> <P><HR WIDTH=50% ALIGN=LEFT> <H2>Instance Variables</H2> <blockquote> <CODE>MYSQL *<B>mConnection</B>;</CODE><BR> <CODE>BOOL <B>mConnected</B>;</CODE><BR> <CODE>NSStringEncoding <B>mEncoding</B>;</CODE><BR> <P><TABLE> <TR><TD>mConnection</TD><TD>The inited MySQL connection</TD></TR> <TR><TD>mConnected</TD><TD>Reflect the fact that the connection is already in place or not</TD></TR> <TR><TD>mEncoding</TD><TD>The encoding used by MySQL server, to ISO-1 default</TD></TR> </TABLE> </blockquote> <P><HR WIDTH=50% ALIGN=LEFT> <H2>Method Types</H2> <blockquote> Getting default of MySQL <DL><DT></DT> <DD> <A HREF="#+ getMySQLLocales">+ getMySQLLocales</A></DD> <DD> <A HREF="#+ encodingForMySQLEncoding:">+ encodingForMySQLEncoding:</A></DD> <DD> <A HREF="#+ defaultMySQLEncoding">+ defaultMySQLEncoding</A></DD> </DL> Initialisation <DL><DT></DT> <DD> <A HREF="#- init">- init</A></DD> <DD> <A HREF="#- initToHost:withLogin:password:usingPort:">- initToHost:withLogin:password:usingPort:</A></DD> <DD> <A HREF="#- initToSocket:withLogin:password:">- initToSocket:withLogin:password:</A></DD> <DD> <A HREF="#- setConnectionOption:withArgument:">- setConnectionOption:withArgument:</A></DD> <DD> <A HREF="#- connectWithLogin:password:host:port:socket:">- connectWithLogin:password:host:port:socket:</A></DD> <DD> <A HREF="#- selectDB:">- selectDB:</A></DD> </DL> Errors information <DL><DT></DT> <DD> <A HREF="#- getLastErrorMessage">- getLastErrorMessage</A></DD> <DD> <A HREF="#- getLastErrorID">- getLastErrorID</A></DD> <DD> <A HREF="#- isConnected">- isConnected</A></DD> <DD> <A HREF="#- checkConnection">- checkConnection</A></DD> </DL> Queries <DL><DT></DT> <DD> <A HREF="#- prepareBinaryData:">- prepareBinaryData:</A></DD> <DD> <A HREF="#- queryString:">- queryString:</A></DD> <DD> <A HREF="#- affectedRows">- affectedRows</A></DD> <DD> <A HREF="#- insertId">- insertId</A></DD> </DL> Getting description of the database structure <DL><DT></DT> <DD> <A HREF="#- listDBs">- listDBs</A></DD> <DD> <A HREF="#- listDBsLike:">- listDBsLike:</A></DD> <DD> <A HREF="#- listTables">- listTables</A></DD> <DD> <A HREF="#- listTablesLike:">- listTablesLike:</A></DD> <DD> <A HREF="#- listTablesFromDB:like:">- listTablesFromDB:like:</A></DD> <DD> <A HREF="#- listFieldsFromTable:">- listFieldsFromTable:</A></DD> <DD> <A HREF="#- listFieldsFromTable:like:">- listFieldsFromTable:like:</A></DD> </DL> Server information and control <DL><DT></DT> <DD> <A HREF="#- clientInfo">- clientInfo</A></DD> <DD> <A HREF="#- hostInfo">- hostInfo</A></DD> <DD> <A HREF="#- serverInfo">- serverInfo</A></DD> <DD> <A HREF="#- protoInfo">- protoInfo</A></DD> <DD> <A HREF="#- listProcesses">- listProcesses</A></DD> <DD> <A HREF="#- killProcess:">- killProcess:</A></DD> </DL> Disconnection <DL><DT></DT> <DD> <A HREF="#- disconnect">- disconnect</A></DD> <DD> <A HREF="#- dealloc">- dealloc</A></DD> </DL> String encoding concerns (c string type to NSString). It's unlikely that users of the framework needs to use these methods which are used internally <DL><DT></DT> <DD> <A HREF="#- setEncoding:">- setEncoding:</A></DD> <DD> <A HREF="#- encoding">- encoding</A></DD> <DD> <A HREF="#- cStringFromString:">- cStringFromString:</A></DD> <DD> <A HREF="#- stringWithCString:">- stringWithCString:</A></DD> </DL> </blockquote> <P><HR WIDTH=50% ALIGN=LEFT> <H2>Class Methods</H2> <A NAME="+ defaultMySQLEncoding"></A><H3><A NAME="//apple_ref/occ/clm/SMySQLConnection/defaultMySQLEncoding">defaultMySQLEncoding</A></H3> <CODE>+ (NSStringEncoding)<B>defaultMySQLEncoding</B> </CODE><P> Returns the default charset of the library mysqlclient used. <P><HR WIDTH=25% ALIGN=LEFT> <A NAME="+ encodingForMySQLEncoding:"></A><H3><A NAME="//apple_ref/occ/clm/SMySQLConnection/encodingForMySQLEncoding:">encodingForMySQLEncoding:</A></H3> <CODE>+ (NSStringEncoding)<B>encodingForMySQLEncoding:</B>(const char *)<EM>mysqlEncoding</EM> </CODE><P> Gets a proper NSStringEncoding according to the given MySQL charset.<P> MySQL 4.0 offers this charsets: big5 cp1251 cp1257 croat czech danish dec8 dos estonia euc_kr gb2312 gbk german1 greek hebrew hp8 hungarian koi8_ru koi8_ukr latin1 latin1_de latin2 latin5 sjis swe7 tis620 ujis usa7 win1250 win1251ukr<P> WARNING : incomplete implementation. Please, send your fixes. <P><HR WIDTH=25% ALIGN=LEFT> <A NAME="+ getMySQLLocales"></A><H3><A NAME="//apple_ref/occ/clm/SMySQLConnection/getMySQLLocales">getMySQLLocales</A></H3> <CODE>+ (NSDictionary *)<B>getMySQLLocales</B> </CODE><P> Gets a proper Locale dictionary to use formater to parse strings from MySQL. For example strings representing dates should give a proper Locales for use with methods such as NSDate::dateWithNaturalLanguageString: locales: <HR WIDTH=50% ALIGN=LEFT> <H2>Instance Methods</H2> <A NAME="- affectedRows"></A><H3><A NAME="//apple_ref/occ/instm/SMySQLConnection/affectedRows">affectedRows</A></H3><P> <CODE>- (my_ulonglong)<B>affectedRows</B> </CODE><P> Returns the number of affected rows by the last query. <P><HR WIDTH=25% ALIGN=LEFT> <A NAME="- cStringFromString:"></A><H3><A NAME="//apple_ref/occ/instm/SMySQLConnection/cStringFromString:">cStringFromString:</A></H3><P> <CODE>- (const char *)<B>cStringFromString:</B>(NSString *)<EM>theString</EM> </CODE><P> For internal use only. Transforms a NSString to a C type string (ending with \0) using the character set from the SMySQLConnection. Lossy conversions are enabled. <P><HR WIDTH=25% ALIGN=LEFT> <A NAME="- checkConnection"></A><H3><A NAME="//apple_ref/occ/instm/SMySQLConnection/checkConnection">checkConnection</A></H3><P> <CODE>- (BOOL)<B>checkConnection</B> </CODE><P> Checks if the connection to the server is still on. If not, tries to reconnect (changing no parameters from the MYSQL pointer). This method just uses mysql_ping(). <P><HR WIDTH=25% ALIGN=LEFT> <A NAME="- clientInfo"></A><H3><A NAME="//apple_ref/occ/instm/SMySQLConnection/clientInfo">clientInfo</A></H3><P> <CODE>- (NSString *)<B>clientInfo</B> </CODE><P> Returns a string giving the client library version. <P><HR WIDTH=25% ALIGN=LEFT> <A NAME="- connectWithLogin:password:host:port:socket:"></A><H3><A NAME="//apple_ref/occ/instm/SMySQLConnection/connectWithLogin:password:host:port:socket:">connectWithLogin:password:host:port:socket:</A></H3><P> <CODE>- (BOOL)<B>connectWithLogin:</B>(NSString *)<EM>login</EM> <B>password:</B>(NSString *)<EM>pass</EM> <B>host:</B>(NSString *)<EM>host</EM> <B>port:</B>(int)<EM>port</EM> <B>socket:</B>(NSString *)<EM>socket</EM> </CODE><P> The method used by <B>initToHost:withLogin:password:usingPort:</B> and <B>initToSocket:withLogin:password:</B>. Same information and use of the parameters:<P> - <I>login</I> is the user name - <I>pass</I> is the password corresponding to the user name - <I>host</I> is the hostname or IP adress - <I>port</I> is the TCP <I>port</I> to use to connect. If <I>port</I> = 0, uses the default <I>port</I> from mysql.h - <I>socket</I> is the path to the <I>socket</I> (for the localhost)<P> The <I>socket</I> is used if the <I>host</I> is set to <CODE>@"localhost"</CODE>, to an empty or a <CODE>nil</CODE> string For the moment the implementation might not be safe if you have a <B>nil</B> pointer to one of the NSString* variables (underestand: I don't know what the result will be). <P><HR WIDTH=25% ALIGN=LEFT> <A NAME="- dealloc"></A><H3><A NAME="//apple_ref/occ/instm/SMySQLConnection/dealloc">dealloc</A></H3><P> <CODE>- (void)<B>dealloc</B> </CODE><P> The standard deallocation method for SMySQLConnection objects. <P><HR WIDTH=25% ALIGN=LEFT> <A NAME="- disconnect"></A><H3><A NAME="//apple_ref/occ/instm/SMySQLConnection/disconnect">disconnect</A></H3><P> <CODE>- (void)<B>disconnect</B> </CODE><P> Disconnects a connected SMySQLConnection object; used by <B>-dealloc</B> method. <P><HR WIDTH=25% ALIGN=LEFT> <A NAME="- encoding"></A><H3><A NAME="//apple_ref/occ/instm/SMySQLConnection/encoding">encoding</A></H3><P> <CODE>- (NSStringEncoding)<B>encoding</B> </CODE><P> Gets the encoding for the connection <P><HR WIDTH=25% ALIGN=LEFT> <A NAME="- getLastErrorID"></A><H3><A NAME="//apple_ref/occ/instm/SMySQLConnection/getLastErrorID">getLastErrorID</A></H3><P> <CODE>- (unsigned int)<B>getLastErrorID</B> </CODE><P> Returns the ErrorID of the last MySQL error on the connection. <P><HR WIDTH=25% ALIGN=LEFT> <A NAME="- getLastErrorMessage"></A><H3><A NAME="//apple_ref/occ/instm/SMySQLConnection/getLastErrorMessage">getLastErrorMessage</A></H3><P> <CODE>- (NSString *)<B>getLastErrorMessage</B> </CODE><P> Returns a string with the last MySQL error message on the connection. <P><HR WIDTH=25% ALIGN=LEFT> <A NAME="- hostInfo"></A><H3><A NAME="//apple_ref/occ/instm/SMySQLConnection/hostInfo">hostInfo</A></H3><P> <CODE>- (NSString *)<B>hostInfo</B> </CODE><P> Returns a string giving information on the host of the DB server. <P><HR WIDTH=25% ALIGN=LEFT> <A NAME="- init"></A><H3><A NAME="//apple_ref/occ/instm/SMySQLConnection/init">init</A></H3><P> <CODE>- (id)<B>init</B> </CODE><P> Initialise a MySQLConnection without making a connection, most likely useless, except with <B>setConnectionOption:withArgument:</B>. <P><HR WIDTH=25% ALIGN=LEFT> <A NAME="- initToHost:withLogin:password:usingPort:"></A><H3><A NAME="//apple_ref/occ/instm/SMySQLConnection/initToHost:withLogin:password:usingPort:">initToHost:withLogin:password:usingPort:</A></H3><P> <CODE>- (id)<B>initToHost:</B>(NSString *)<EM>host</EM> <B>withLogin:</B>(NSString *)<EM>login</EM> <B>password:</B>(NSString *)<EM>pass</EM> <B>usingPort:</B>(int)<EM>port</EM> </CODE><P> Initialise a connection using a <B>TCP/IP connection</B> with the given parameters (except if <I>host</I> is set to <CODE>localhost</CODE>, in which case uses the default)<P> - <I>host</I> is the hostname or IP adress - <I>login</I> is the user name - <I>pass</I> is the password corresponding to the user name - <I>port</I> is the TCP <I>port</I> to use to connect. If <I>port</I> = 0, uses the default <I>port</I> from mysql.h <P><HR WIDTH=25% ALIGN=LEFT> <A NAME="- initToSocket:withLogin:password:"></A><H3><A NAME="//apple_ref/occ/instm/SMySQLConnection/initToSocket:withLogin:password:">initToSocket:withLogin:password:</A></H3><P> <CODE>- (id)<B>initToSocket:</B>(NSString *)<EM>socket</EM> <B>withLogin:</B>(NSString *)<EM>login</EM> <B>password:</B>(NSString *)<EM>pass</EM> </CODE><P> Initialise a connection using a <B>unix <I>socket</I></B> with the given parameters<P> - <I>socket</I> is the path to the <I>socket</I> - <I>login</I> is the user name - <I>pass</I> is the password corresponding to the user name <P><HR WIDTH=25% ALIGN=LEFT> <A NAME="- insertId"></A><H3><A NAME="//apple_ref/occ/instm/SMySQLConnection/insertId">insertId</A></H3><P> <CODE>- (my_ulonglong)<B>insertId</B> </CODE><P> If the last query was an insert in a table having a autoindex column, returns the <B>id</B> (autoindexed field) of the last row inserted. <P><HR WIDTH=25% ALIGN=LEFT> <A NAME="- isConnected"></A><H3><A NAME="//apple_ref/occ/instm/SMySQLConnection/isConnected">isConnected</A></H3><P> <CODE>- (BOOL)<B>isConnected</B> </CODE><P> Returns YES if the SMySQLConnection is connected to a DB, NO otherwise. <P><HR WIDTH=25% ALIGN=LEFT> <A NAME="- killProcess:"></A><H3><A NAME="//apple_ref/occ/instm/SMySQLConnection/killProcess:">killProcess:</A></H3><P> <CODE>- (BOOL)<B>killProcess:</B>(unsigned long)<EM>pid</EM> </CODE><P> Kills the process with the given <I>pid</I>. The users needs the <B>Process_priv</B> privilege. <P><HR WIDTH=25% ALIGN=LEFT> <A NAME="- listDBs"></A><H3><A NAME="//apple_ref/occ/instm/SMySQLConnection/listDBs">listDBs</A></H3><P> <CODE>- (SMySQLResult *)<B>listDBs</B> </CODE><P> Just a fast wrapper for the more complex <CODE>listDBsWithPattern:</CODE> method. <P><HR WIDTH=25% ALIGN=LEFT> <A NAME="- listDBsLike:"></A><H3><A NAME="//apple_ref/occ/instm/SMySQLConnection/listDBsLike:">listDBsLike:</A></H3><P> <CODE>- (SMySQLResult *)<B>listDBsLike:</B>(NSString *)<EM>dbsName</EM> </CODE><P> Returns a list of database which name correspond to the SQL regular expression in 'pattern'. The comparison is done with wild card extension : % and _. The result should correspond to the queryString:@"SHOW databases [LIKE wild]"; but implemented with mysql_list_dbs. If an empty string or <B>nil</B> is passed as pattern, all databases will be shown. <P><HR WIDTH=25% ALIGN=LEFT> <A NAME="- listFieldsFromTable:"></A><H3><A NAME="//apple_ref/occ/instm/SMySQLConnection/listFieldsFromTable:">listFieldsFromTable:</A></H3><P> <CODE>- (SMySQLResult *)<B>listFieldsFromTable:</B>(NSString *)<EM>tableName</EM> </CODE><P> Just a fast wrapper for the more complex list <CODE>listFieldsWithPattern:forTable:</CODE> method. <P><HR WIDTH=25% ALIGN=LEFT> <A NAME="- listFieldsFromTable:like:"></A><H3><A NAME="//apple_ref/occ/instm/SMySQLConnection/listFieldsFromTable:like:">listFieldsFromTable:like:</A></H3><P> <CODE>- (SMySQLResult *)<B>listFieldsFromTable:</B>(NSString *)<EM>tableName</EM> <B>like:</B>(NSString *)<EM>fieldsName</EM> </CODE><P> Show all the fields of the table <I>tableName</I> which name correspond to pattern (with wild card expansion : %,_). Indeed, and as recommanded from mysql reference, this method is NOT using mysql_list_fields but the <CODE>queryString:</CODE> method. If an empty string or <B>nil</B> is passed as <I>fieldsName</I>, all fields (of <I>tableName</I>) will be returned. <P><HR WIDTH=25% ALIGN=LEFT> <A NAME="- listProcesses"></A><H3><A NAME="//apple_ref/occ/instm/SMySQLConnection/listProcesses">listProcesses</A></H3><P> <CODE>- (SMySQLResult *)<B>listProcesses</B> </CODE><P> Lists active process <P><HR WIDTH=25% ALIGN=LEFT> <A NAME="- listTables"></A><H3><A NAME="//apple_ref/occ/instm/SMySQLConnection/listTables">listTables</A></H3><P> <CODE>- (SMySQLResult *)<B>listTables</B> </CODE><P> Make sure a DB is selected (with <CODE>selectDB</CODE> method) first. <P><HR WIDTH=25% ALIGN=LEFT> <A NAME="- listTablesFromDB:like:"></A><H3><A NAME="//apple_ref/occ/instm/SMySQLConnection/listTablesFromDB:like:">listTablesFromDB:like:</A></H3><P> <CODE>- (SMySQLResult *)<B>listTablesFromDB:</B>(NSString *)<EM>dbName</EM> <B>like:</B>(NSString *)<EM>tablesName</EM> </CODE><P> List tables in DB specified by <I>dbName</I> and corresponding to pattern. This method indeed issues a <CODE>SHOW TABLES FROM dbName LIKE ...</CODE> query to the server. This is done this way to make sure the selected DB is not changed by this method. <P><HR WIDTH=25% ALIGN=LEFT> <A NAME="- listTablesLike:"></A><H3><A NAME="//apple_ref/occ/instm/SMySQLConnection/listTablesLike:">listTablesLike:</A></H3><P> <CODE>- (SMySQLResult *)<B>listTablesLike:</B>(NSString *)<EM>tablesName</EM> </CODE><P> From within a database, give back the list of table which name correspond to <I>tablesName</I> (with wild card %, _ extension). Correspond to queryString:@"SHOW tables [LIKE wild]"; uses mysql_list_tables function. If an empty string or <B>nil</B> is passed as <I>tablesName</I>, all tables will be shown. WARNING: <B>produce an error if no databases are selected</B> (with <CODE>selectDB:</CODE> for example). <P><HR WIDTH=25% ALIGN=LEFT> <A NAME="- prepareBinaryData:"></A><H3><A NAME="//apple_ref/occ/instm/SMySQLConnection/prepareBinaryData:">prepareBinaryData:</A></H3><P> <CODE>- (NSString *)<B>prepareBinaryData:</B>(NSData *)<EM>theData</EM> </CODE><P> Takes a NSData object and transform it in a proper string for sending to the server in between quotes. <P><HR WIDTH=25% ALIGN=LEFT> <A NAME="- protoInfo"></A><H3><A NAME="//apple_ref/occ/instm/SMySQLConnection/protoInfo">protoInfo</A></H3><P> <CODE>- (NSNumber *)<B>protoInfo</B> </CODE><P> Returns the number of the protocole used to transfer info from server to client <P><HR WIDTH=25% ALIGN=LEFT> <A NAME="- queryString:"></A><H3><A NAME="//apple_ref/occ/instm/SMySQLConnection/queryString:">queryString:</A></H3><P> <CODE>- (SMySQLResult *)<B>queryString:</B>(NSString *)<EM>query</EM> </CODE><P> Takes a <I>query</I> string and return an SMySQLResult object holding the result of the <I>query</I>. The returned SMySQLResult is not retained, the client is responsible for that (it's autoreleased before being returned) Note that if you want to use this method with binary data (in the <I>query</I>), you should use <CODE>prepareBinaryData:</CODE> to include the binary data in the <I>query</I> string. <P><HR WIDTH=25% ALIGN=LEFT> <A NAME="- selectDB:"></A><H3><A NAME="//apple_ref/occ/instm/SMySQLConnection/selectDB:">selectDB:</A></H3><P> <CODE>- (BOOL)<B>selectDB:</B>(NSString *)<EM>dbName</EM> </CODE><P> Selects a database to work with. The SMySQLConnection object needs to be properly inited and connected to a server. If a connection is not yet set or the selection of the database didn't work, returns NO. Returns YES in normal cases where the database is properly selected.<P> So far, if <I>dbName</I> is a <B>nil</B> pointer it will return NO (as if it cannot connect), most likely this will throw an exception in the future. <P><HR WIDTH=25% ALIGN=LEFT> <A NAME="- serverInfo"></A><H3><A NAME="//apple_ref/occ/instm/SMySQLConnection/serverInfo">serverInfo</A></H3><P> <CODE>- (NSString *)<B>serverInfo</B> </CODE><P> Returns a string giving the server version. <P><HR WIDTH=25% ALIGN=LEFT> <A NAME="- setConnectionOption:withArgument:"></A><H3><A NAME="//apple_ref/occ/instm/SMySQLConnection/setConnectionOption:withArgument:">setConnectionOption:withArgument:</A></H3><P> <CODE>- (BOOL)<B>setConnectionOption:</B>(int)<EM>option</EM> <B>withArgument:</B>(id)<EM>arg</EM> </CODE><P> <B>NOT YET IMPLEMENTED</B><P> This method is to be used for getting special <I>option</I> for a connection, in which case the SMySQLConnection has to be inited with the init method, then <I>option</I> are selected, finally connection is done using one of the connect methods:<P> <CODE> <BR> SMySQLConnection *theConnect = [[SMySQLConnection alloc] init]; <BR> [theConnect setConnectionOption: option withArgument: arg]; <BR> [theConnect connectToHost:albert.com withLogin:@"toto" password:@"albert" port:0]; <BR> .... <BR> </CODE> <P><HR WIDTH=25% ALIGN=LEFT> <A NAME="- setEncoding:"></A><H3><A NAME="//apple_ref/occ/instm/SMySQLConnection/setEncoding:">setEncoding:</A></H3><P> <CODE>- (void)<B>setEncoding:</B>(NSStringEncoding)<EM>theEncoding</EM> </CODE><P> Sets the encoding used by the server for data transfert. Used to make sure the output of the query result is ok even for non-ascii characters The character set (encoding) used by the db is passed to the SMySQLConnection object upon connection, so most likely the encoding (from -encoding) method is already the proper one. That is to say : It's unlikely you will need to call this method directly, and <B>if ever you use it, do it at your own risks</B>. <P><HR WIDTH=25% ALIGN=LEFT> <A NAME="- stringWithCString:"></A><H3><A NAME="//apple_ref/occ/instm/SMySQLConnection/stringWithCString:">stringWithCString:</A></H3><P> <CODE>- (NSString *)<B>stringWithCString:</B>(const char *)<EM>theCString</EM> </CODE><P> Returns a NSString from a C style string encoded with the character set of theSMySQLConnection. <P><HR> Version 1.1 Copyright ©2002 by MySQL Cocoa Project. All Rights Reserved. Wed May 15 13:02:11 2002 <P> </BODY></HTML> --- NEW FILE: SMySQLResult.html --- <HTML><HEAD><TITLE></TITLE></HEAD> <BODY BGCOLOR="#FFFFFF"> <BR><BR><FONT COLOR="#000066"><H1><A NAME="//apple_ref/occ/cl/SMySQLResult">SMySQLResult</A></H1></FONT><BR> <blockquote><DL><DT><B>Inherits From:</B></DT> <DD>NSObject</DD> </DL></blockquote> <blockquote><DL><DT><B>Declared In:</B></DT> <DD>SMySQLResult.h</DD> </DL></blockquote> <BR><BR> <H2>Class Description</H2> Hold the results of a query to a MySQL database server. It correspond to the MYSQL_RES structure of the C API, and to the statement handle of the PERL DBI/DBD.<P> Uses the <B>mysql_store_result()</B> function from the C API.<P> This object is generated only by a SMySQLConnection object, in this way (see <B>SMySQLConnection</B> documentation):<P> <CODE> <BR> SMySQLConnection *theConnec = [SMySQLConnection alloc]; <BR> SMySQLResult *theRes; <BR> NSDictionnary *theDict; <BR> NSArray *theColNames; <BR> int i, j;<BR> <BR> theConnec = [theConnec initToHost::albert.com withLogin:@"toto" password:@"albert" port:0]; <BR> [theConnec selectDB:@"db1"]; <BR> theRes = [theConnec queryString:@"select * from table1"]; <BR> theColNames = [theRes fetchFiedlsName]; <BR> i = 0; <BR> while (theDict = [theRes fetchRowAsDictionary]){ <BR> NSLog(@"Row : <I>d</I>\n", i); <BR> for (j=0; j<[theColNames count]; j++) { <BR> NSLog(@" Field : %@, contain : %@\n", [theColNames objectAtInex:j], [theDict objectForKey:[theColNames objectAtIndex:j]]); <BR> }<BR> i++; <BR> }<BR> </CODE> <P><HR WIDTH=50% ALIGN=LEFT> <H2>Instance Variables</H2> <blockquote> <CODE>MYSQL_RES *<B>mResult</B>;</CODE><BR> <CODE>NSArray *<B>mNames</B>;</CODE><BR> <CODE>NSDictionary *<B>mMySQLLocales</B>;</CODE><BR> <CODE>NSStringEncoding <B>mEncoding</B>;</CODE><BR> <P><TABLE> <TR><TD>mResult</TD><TD>The MYSQL_RES structure of the C API</TD></TR> <TR><TD>mNames</TD><TD>An NSArray holding the name of the columns</TD></TR> <TR><TD>mMySQLLocales</TD><TD>A Locales dictionary to define the locales of MySQL</TD></TR> <TR><TD>mEncoding</TD><TD>The encoding used by MySQL server, to ISO-1 default</TD></TR> </TABLE> </blockquote> <P><HR WIDTH=50% ALIGN=LEFT> <H2>Method Types</H2> <blockquote> Init used <B>only</B> by <B>SMySQLConnection</B> <DL><DT></DT> <DD> <A HREF="#- initWithMySQLPtr:encoding:">- initWithMySQLPtr:encoding:</A></DD> <DD> <A HREF="#- initWithResPtr:encoding:">- initWithResPtr:encoding:</A></DD> <DD> <A HREF="#- init">- init</A></DD> </DL> General info on the result <DL><DT></DT> <DD> <A HREF="#- numOfRows">- numOfRows</A></DD> <DD> <A HREF="#- numOfFields">- numOfFields</A></DD> </DL> Getting the rows <DL><DT></DT> <DD> <A HREF="#- dataSeek:">- dataSeek:</A></DD> <DD> <A HREF="#- fetchRowAsDictionary">- fetchRowAsDictionary</A></DD> <DD> <A HREF="#- fetchRowAsArray">- fetchRowAsArray</A></DD> </DL> Getting information on columns <DL><DT></DT> <DD> <A HREF="#- fetchFieldsName">- fetchFieldsName</A></DD> <DD> <A HREF="#- fetchTypesAsArray">- fetchTypesAsArray</A></DD> <DD> <A HREF="#- fetchTypesAsDictionary">- fetchTypesAsDictionary</A></DD> <DD> <A HREF="#- isBlobAtIndex:">- isBlobAtIndex:</A></DD> <DD> <A HREF="#- isBlobForKey:">- isBlobForKey:</A></DD> </DL> Utility method <DL><DT></DT> <DD> <A HREF="#- description">- description</A></DD> </DL> End of the scope... <DL><DT></DT> <DD> <A HREF="#- dealloc">- dealloc</A></DD> </DL> Private methods, internam use only <DL><DT></DT> <DD> <A HREF="#- cStringFromString:">- cStringFromString:</A></DD> <DD> <A HREF="#- stringWithCString:">- stringWithCString:</A></DD> </DL> </blockquote> <HR WIDTH=50% ALIGN=LEFT> <H2>Instance Methods</H2> <A NAME="- cStringFromString:"></A><H3><A NAME="//apple_ref/occ/instm/SMySQLResult/cStringFromString:">cStringFromString:</A></H3><P> <CODE>- (const char *)<B>cStringFromString:</B>(NSString *)<EM>theString</EM> </CODE><P> For internal use only. Transform a NSString to a C type string (ended with \0) using ethe character set from the SMySQLConnection. Lossy conversions are enabled. <P><HR WIDTH=25% ALIGN=LEFT> <A NAME="- dataSeek:"></A><H3><A NAME="//apple_ref/occ/instm/SMySQLResult/dataSeek:">dataSeek:</A></H3><P> <CODE>- (void)<B>dataSeek:</B>(my_ulonglong)<EM>row</EM> </CODE><P> Go to a precise <I>row</I> in the selected result. 0 is the very first <I>row</I> <P><HR WIDTH=25% ALIGN=LEFT> <A NAME="- dealloc"></A><H3><A NAME="//apple_ref/occ/instm/SMySQLResult/dealloc">dealloc</A></H3><P> <CODE>- (void)<B>dealloc</B> </CODE><P> No method description. <P><HR WIDTH=25% ALIGN=LEFT> <A NAME="- description"></A><H3><A NAME="//apple_ref/occ/instm/SMySQLResult/description">description</A></H3><P> <CODE>- (NSString *)<B>description</B> </CODE><P> Return a (long) string containing the table of results, first line being the fields name, next line(s) the row(s). Useful to have NSLog logging a SMySQLResult (example). <P><HR WIDTH=25% ALIGN=LEFT> <A NAME="- fetchFieldsName"></A><H3><A NAME="//apple_ref/occ/instm/SMySQLResult/fetchFieldsName">fetchFieldsName</A></H3><P> <CODE>- (NSArray *)<B>fetchFieldsName</B> </CODE><P> Generate the mNames if not already generated, and return it.<P> mNames is a NSArray holding the names of the fields(columns) of the results <P><HR WIDTH=25% ALIGN=LEFT> <A NAME="- fetchRowAsArray"></A><H3><A NAME="//apple_ref/occ/instm/SMySQLResult/fetchRowAsArray">fetchRowAsArray</A></H3><P> <CODE>- (NSArray *)<B>fetchRowAsArray</B> </CODE><P> Return the next row of the result as an array, the index in select field order, the object a proper object for handling the information in the field (NSString, NSNumber ...). <P><HR WIDTH=25% ALIGN=LEFT> <A NAME="- fetchRowAsDictionary"></A><H3><A NAME="//apple_ref/occ/instm/SMySQLResult/fetchRowAsDictionary">fetchRowAsDictionary</A></H3><P> <CODE>- (NSDictionary *)<B>fetchRowAsDictionary</B> </CODE><P> Return the next row of the result as a dictionary, the key being the field name, the object a proper object for handling the information in the field (NSString, NSNumber ...). <P><HR WIDTH=25% ALIGN=LEFT> <A NAME="- fetchTypesAsArray"></A><H3><A NAME="//apple_ref/occ/instm/SMySQLResult/fetchTypesAsArray">fetchTypesAsArray</A></H3><P> <CODE>- (NSArray *)<B>fetchTypesAsArray</B> </CODE><P> Return an array of the fields' types. <P><HR WIDTH=25% ALIGN=LEFT> <A NAME="- fetchTypesAsDictionary"></A><H3><A NAME="//apple_ref/occ/instm/SMySQLResult/fetchTypesAsDictionary">fetchTypesAsDictionary</A></H3><P> <CODE>- (NSDictionary *)<B>fetchTypesAsDictionary</B> </CODE><P> Return a dictionnary of the fields' types (keys are the fields' names). <P><HR WIDTH=25% ALIGN=LEFT> <A NAME="- init"></A><H3><A NAME="//apple_ref/occ/instm/SMySQLResult/init">init</A></H3><P> <CODE>- (id)<B>init</B> </CODE><P> Empty init, normaly of NO use to the user, again, SMySQLResult should be made through calls to SMySQLConnection <P><HR WIDTH=25% ALIGN=LEFT> <A NAME="- initWithMySQLPtr:encoding:"></A><H3><A NAME="//apple_ref/occ/instm/SMySQLResult/initWithMySQLPtr:encoding:">initWithMySQLPtr:encoding:</A></H3><P> <CODE>- (id)<B>initWithMySQLPtr:</B>(MYSQL *)<EM>mySQLPtr</EM> <B>encoding:</B>(NSStringEncoding)<EM>theEncoding</EM> </CODE><P> initialise a SMySQLResult, it is used internally by SMySQLConnection <B>queryString:</B> method: the only proper way to get a running SMySQLResult object. <P><HR WIDTH=25% ALIGN=LEFT> <A NAME="- initWithResPtr:encoding:"></A><H3><A NAME="//apple_ref/occ/instm/SMySQLResult/initWithResPtr:encoding:">initWithResPtr:encoding:</A></H3><P> <CODE>- (id)<B>initWithResPtr:</B>(MYSQL_RES *)<EM>mySQLResPtr</EM> <B>encoding:</B>(NSStringEncoding)<EM>theEncoding</EM> </CODE><P> This metod it is used internally by SMySQLConnection object when it have already a MYSQL_RES object to initialise SMySQLResult object. Initialise a SMySQLResult with the MYSQL_RES pointer (returned by such a function as mysql_list_dbs). NB: SMySQLResult should be made by using one of the method of SMySQLConnection. <P><HR WIDTH=25% ALIGN=LEFT> <A NAME="- isBlobAtIndex:"></A><H3><A NAME="//apple_ref/occ/instm/SMySQLResult/isBlobAtIndex:">isBlobAtIndex:</A></H3><P> <CODE>- (BOOL)<B>isBlobAtIndex:</B>(unsigned int)<EM>index</EM> </CODE><P> Return YES if the field with the given <I>index</I> is a BLOB. It should be used to discriminates between BLOBs and TEXTs.<P> <B>NOT YET IMPLEMENTED</B>, return YES for both BLOBs and TEXTs... <P><HR WIDTH=25% ALIGN=LEFT> <A NAME="- isBlobForKey:"></A><H3><A NAME="//apple_ref/occ/instm/SMySQLResult/isBlobForKey:">isBlobForKey:</A></H3><P> <CODE>- (BOOL)<B>isBlobForKey:</B>(NSString *)<EM>key</EM> </CODE><P> Return YES if the field (by name) with the given index is a BLOB. It should be used to discriminates between BLOBs and TEXTs.<P> <B>NOT YET IMPLEMENTED</B>, return YES for both BLOBs and TEXTs... <P><HR WIDTH=25% ALIGN=LEFT> <A NAME="- numOfFields"></A><H3><A NAME="//apple_ref/occ/instm/SMySQLResult/numOfFields">numOfFields</A></H3><P> <CODE>- (unsigned int)<B>numOfFields</B> </CODE><P> Return the number of fields selected by the query. <P><HR WIDTH=25% ALIGN=LEFT> <A NAME="- numOfRows"></A><H3><A NAME="//apple_ref/occ/instm/SMySQLResult/numOfRows">numOfRows</A></H3><P> <CODE>- (my_ulonglong)<B>numOfRows</B> </CODE><P> Return the number of rows selected by the query. <P><HR WIDTH=25% ALIGN=LEFT> <A NAME="- stringWithCString:"></A><H3><A NAME="//apple_ref/occ/instm/SMySQLResult/stringWithCString:">stringWithCString:</A></H3><P> <CODE>- (NSString *)<B>stringWithCString:</B>(const char *)<EM>theCString</EM> </CODE><P> Return a NSString from a C style string encoded with the character set of theSMySQLConnection. <P><HR> Version 1.1 Copyright ©2002 by MySQL Cocoa Project. All Rights Reserved. Wed May 15 13:02:12 2002 <P> </BODY></HTML> |