[fpc-pascal] The Interface to MySQL has changed on version by version

Andi Purwito andipurwito at yahoo.com
Mon Oct 8 09:01:42 CEST 2007


Hi all. This is my test program to track interface changes in mysql lib.

program MySQLku;

uses
  mysql50; //Before is mysql4

const
   DataBase : Pchar = 'dbtes';
   Query    : Pchar = 'select * from tbl';
   InsertSQL : PChar = 'insert into tbl (a, b) values (''value a'',"value b")';

var
  count,num : longint;
  code : integer;
  sock : PMYSQL;
  qmysql : TMYSQL;
  qbuf : string [160];
  rowbuf : TMYSQL_ROW;
  dummy : string;
  recbuf : PMYSQL_RES;

begin
  if paramcount=1 then
    begin
    Dummy:=Paramstr(1)+#0;
    DataBase:=@Dummy[1];
    end;
  Write ('Connecting to MySQL...');
  mysql_init(PMySQL(@qmysql));
  sock :=  mysql_real_connect(PMysql(@qmysql),nil,'root','',nil,0,nil,0);
  if sock=Nil  then
    begin
    Writeln (stderr,'Couldn''t connect to MySQL.');
    Writeln (stderr,mysql_error(@qmysql));
    halt(1);
    end;
  Writeln ('Done.');
  Writeln ('Connection data:');
{$ifdef Unix}
  writeln ('Mysql_port      : ',mysql_port);
  writeln ('Mysql_unix_port : ',mysql_unix_port);
{$endif}
  writeln ('Host info       : ',mysql_get_host_info(sock));
  writeln ('Server info     : ',mysql_stat(sock));
  writeln ('Client info     : ',mysql_get_client_info);
  Writeln ('Selecting Database ',DataBase,'...');
 if mysql_select_db(sock,DataBase) < 0 then
    begin
    Writeln (stderr,'Couldn''t select database ',Database);
    Writeln  (stderr,mysql_error(sock));
    halt (1);
    end;

  writeln ('Executing query : ',InsertSQL,'...');
    if (mysql_query(sock,InsertSQL) < 0) then
      begin
      Writeln (stderr,'Query failed ');
      writeln (stderr,mysql_error(sock));
      Halt(1);
      end;

  recbuf := mysql_store_result(sock);
  if RecBuf=Nil then
    begin
    Writeln ('Query returned nil result.');
    mysql_close(sock);
    halt (1);
    end;
  Writeln ('Number of records returned  : ',mysql_num_rows (recbuf));
  Writeln ('Number of fields per record : ',mysql_num_fields(recbuf));

  rowbuf := mysql_fetch_row(recbuf);
  while (rowbuf  <>nil) do
       begin
       Write  ('(Id: ', rowbuf[0]);
       Write  (', Name: ', rowbuf[1]);
       Writeln(', Email : ', rowbuf[2],')');
rowbuf := mysql_fetch_row(recbuf);
       end;
  Writeln ('Freeing memory occupied by result set...');
  mysql_free_result (recbuf);
  Writeln ('Closing connection with MySQL.');
  mysql_close(sock);
  halt(0);
end.

 ---------------------------------------------------------------------
 Compiling MySQLku.pas
 
mysqlku.pas(16,18) Error: Identifier not found "TMYSQL"
mysqlku.pas(16,18) Error: Error in type definition
mysqlku.pas(18,22) Error: Identifier not found "TMYSQL_ROW"
mysqlku.pas(18,22) Error: Error in type definition
mysqlku.pas(74,17) Error: Operator is not  overloaded
mysqlku.pas(76,32) Error: Illegal qualifier
mysqlku.pas(76,35) Error: Illegal expression
mysqlku.pas(77,35) Error: Illegal qualifier
mysqlku.pas(77,38) Error: Illegal expression
mysqlku.pas(78,37) Error: Illegal qualifier
mysqlku.pas(78,44) Error: Illegal expression

It's look that the interface has changed. But where can we get and follow its change?
Thanks
       
---------------------------------
Building a website is a piece of cake. 
Yahoo! Small Business gives you all the tools to get online.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20071008/53d3e3ee/attachment.html>


More information about the fpc-pascal mailing list