Author Topic: Can PHP call a C functiont that reyurns a pointer to a structure (a linked list)  (Read 366 times)

0 Members and 1 Guest are viewing this topic.

Offline A.P.Topic starter

  • Irregular
    • View Profile
Can PHP call a C functiont that reyurns a pointer to a structure (a linked list)?

I am a C programmer and am writing C functions to do database access. The results are converted into linked lists.

Currently the PHP programmers are writing their own SQL statements to directly access the datbase, but the intention is for all DB access to be done via the C libraries I am writing. Howver our PHP programmers do not know how to implement this, and I don;t know PHP!

Offline jesirose

  • Fanatic
  • Gender: Female
    • View Profile
Why are you writing C Libraries for a PHP program? It seems like the PHP programmers should be making their library in PHP.

I don't believe PHP can access C this way...
Before posting, read the guidelines. When you do post a topic, post your code. In code tags.
Before you ask me how to do something I suggest, Google it.
Before asking what a function does, check the manual: http://php.net

Offline ShogunWarrior

  • Devotee
  • Gender: Male
  • # IRELAND #
    • View Profile
    • David Doran Media
I think you would need to return a "Resource" type and expore iterator functions to PHP.
E.g:
Code: [Select]
$handle = call_your_query( $input );
while( $row = get_data_row($handle) )
{
    // Echo data etc..
    //echo '';
}

Both call_query and get_data_row for example would be your functions and so the first function would return a resource which PHP supports and the second function would return an array which PHP supports.
<a href="http://www.daviddoranmedia.com/">My New Site/Blog</a> | <a href="http://www.daviddoranmedia.com/check/">Check your page for broken links/images/scripts</a>

Zend Certified Engineer
Follow me on Twitter: http://twitter.com/davidd

PHP Freaks Forums

« on: »

Tired of these ads? Purchase a supporter subscription to get rid of them.